Report fatal vs transient errors when initializing contexts

Currently context creation and initialization reports back just true/false
for if the process succeeded. This expands that information to a tri-state
of success, fatal error, transient error. In the latter case, the client
should retry making the context as it may succeed next time. This happens
when, for instance, another client crashes the gpu process at the same
time the context is being constructed. In the case of a fatal error, the
context can not be made given the current inputs so either the gpu is not
usable, or the client has a bug and is requesting an invalid context of
some sort, but it will not make progress by retrying. So in this case the
client should not retry and just fail back to a non-gpu mode.

This information will allow us to remove the retry count when making the
compositor context for the display compositor, removing the state machine
in that code (as retry becomes a local decision from the result).

TBR=raymes

Bug: 772574
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ic3574de9fccae42ac34ff8a5755d4cfa5f0dd2b0
Reviewed-on: https://chromium-review.googlesource.com/717548
Reviewed-by: danakj <[email protected]>
Reviewed-by: Sadrul Chowdhury <[email protected]>
Reviewed-by: Ken Buchanan <[email protected]>
Reviewed-by: Antoine Labour <[email protected]>
Commit-Queue: danakj <[email protected]>
Cr-Commit-Position: refs/heads/master@{#509836}
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc
index f29f744..6e172ec9 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper.cc
@@ -150,9 +150,14 @@
   }
 }
 
-bool CommandBufferHelper::Initialize(int32_t ring_buffer_size) {
+gpu::ContextResult CommandBufferHelper::Initialize(int32_t ring_buffer_size) {
   ring_buffer_size_ = ring_buffer_size;
-  return AllocateRingBuffer();
+  if (!AllocateRingBuffer()) {
+    // This would fail if CreateTransferBuffer fails, which will not fail for
+    // transient reasons such as context loss. See http://crrev.com/c/720269
+    return gpu::ContextResult::kFatalFailure;
+  }
+  return gpu::ContextResult::kSuccess;
 }
 
 CommandBufferHelper::~CommandBufferHelper() {