Adds GLContext::LosesAllContextsOnContextLost.

GLContext::LosesAllContextsOnContextLost specifies whether or not all contexts need to be destroyed when recovering from lost context condition.  GpuCommandBufferStub::OnFlush and GpuCommandBufferStub::OnAsyncFlush will instruct soon-to-be-renamed GpuRenderThread to close all channels when the context is lost and LosesAllContextsOnContextLost returns true.  From the EGL 1.4 spec:

"...On detection of this error, the application must destroy all contexts (by calling eglDestroyContext for each context). To continue rendering the application must recreate any contexts it requires, and subsequently restore any client API state and objects it wishes to use."

However even with this change Angle still doesn't recover correctly.

BUG=76753
TEST=breakpoint on eglDestroyContext

Review URL: http://codereview.chromium.org/6813010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81437 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 97029028..a1eab92 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -2516,9 +2516,6 @@
     // must release the ContextGroup before destroying the context as its
     // destructor uses GL.
     group_ = NULL;
-
-    context_->Destroy();
-    context_.reset();
   } else {
     if (offscreen_target_frame_buffer_.get())
       offscreen_target_frame_buffer_->Invalidate();
@@ -2536,6 +2533,10 @@
       offscreen_saved_color_texture_->Invalidate();
   }
 
+  if (context_.get())
+    context_->Destroy();
+  context_.reset();
+
   offscreen_target_frame_buffer_.reset();
   offscreen_target_color_texture_.reset();
   offscreen_target_color_render_buffer_.reset();