Reland of current program can be null in ES2/ES3 contexts. (patchset #1 id:1 of https://codereview.chromium.org/2181193002/ )

Reason for revert:
I don't think this is related.  See crbug.com/631316 and here the conversion between me and Mark.

Original issue's description:
> Revert of current program can be null in ES2/ES3 contexts. (patchset #2 id:20001 of https://codereview.chromium.org/2174173002/ )
>
> Reason for revert:
> Caused webkit test failure on WebKit Win7 (dbg)
> https://build.chromium.org/p/chromium.webkit/builders/WebKit%20Win7%20%28dbg%29/builds/6624
>
> unexpected_failures:
> printing/webgl-oversized-printing.html
> virtual/threaded/printing/webgl-oversized-printing.html
>
> https://storage.googleapis.com/chromium-layout-test-archives/WebKit_Win7__dbg_/6624/layout-test-results/results.html
>
> ---
> --- E:\b\rr\tmpymgexl\w\layout-test-results\printing/webgl-oversized-printing-expected.txt
> +++ E:\b\rr\tmpymgexl\w\layout-test-results\printing/webgl-oversized-printing-actual.txt
> @@ -1,5 +1,5 @@
> -PASS successfullyParsed is true
> +CONSOLE ERROR: line 13: Uncaught TypeError: Cannot read property 'clearColor' of null
> +FAIL successfullyParsed should be true. Was false.
>
>  TEST COMPLETE
> -PASS Printed without crashing.
> ---
>
> ---
> --- E:\b\rr\tmpymgexl\w\layout-test-results\virtual/threaded/printing/webgl-oversized-printing-expected.txt
> +++ E:\b\rr\tmpymgexl\w\layout-test-results\virtual/threaded/printing/webgl-oversized-printing-actual.txt
> @@ -1,5 +1,5 @@
> -PASS successfullyParsed is true
> +CONSOLE ERROR: line 13: Uncaught TypeError: Cannot read property 'clearColor' of null
> +FAIL successfullyParsed should be true. Was false.
>
>  TEST COMPLETE
> -PASS Printed without crashing.
> ---
>
> Original issue's description:
> > current program can be null in ES2/ES3 contexts.
> >
> > They are only required to be non null in WebGL.
> >
> > This also did some clean up and a minor optimization.
> >
> > BUG=630802
> > TEST=fuzzer case in the bug
> > [email protected]
> > CQ_INCLUDE_TRYBOTS=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
> >
> > Committed: https://crrev.com/14ef40159115ca5059907835a34bcd1667af7631
> > Cr-Commit-Position: refs/heads/master@{#407659}
>
> [email protected],[email protected],[email protected]
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=630802
>
> Committed: https://crrev.com/e9c2cd979c8114b75bbc2640a43a1371d64f502b
> Cr-Commit-Position: refs/heads/master@{#407711}

[email protected],[email protected],[email protected]
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=630802

Review-Url: https://codereview.chromium.org/2186473002
Cr-Commit-Position: refs/heads/master@{#407713}
diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h
index 6e2d293..2378eeb3 100644
--- a/gpu/command_buffer/service/context_state.h
+++ b/gpu/command_buffer/service/context_state.h
@@ -243,30 +243,27 @@
   void SetBoundBuffer(GLenum target, Buffer* buffer);
   void RemoveBoundBuffer(Buffer* buffer);
 
-  void InitGenericAttribBaseType(GLuint max_vertex_attribs) {
-      max_vertex_attribs_ = max_vertex_attribs;
+  void InitGenericAttribs(GLuint max_vertex_attribs) {
+    attrib_values.resize(max_vertex_attribs);
 
-      uint32_t packed_size = max_vertex_attribs_ / 16;
-      packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1;
-      generic_attrib_base_type_mask_.resize(packed_size);
-      for (uint32_t i = 0; i < packed_size; ++i) {
-        // All generic attribs are float type by default.
-        generic_attrib_base_type_mask_[i] = 0x55555555u * SHADER_VARIABLE_FLOAT;
-      }
+    uint32_t packed_size = max_vertex_attribs / 16;
+    packed_size += (max_vertex_attribs % 16 == 0) ? 0 : 1;
+    generic_attrib_base_type_mask_.resize(packed_size);
+    for (uint32_t i = 0; i < packed_size; ++i) {
+      // All generic attribs are float type by default.
+      generic_attrib_base_type_mask_[i] = 0x55555555u * SHADER_VARIABLE_FLOAT;
+    }
   }
 
   void SetGenericVertexAttribBaseType(GLuint index, GLenum base_type) {
-    DCHECK(index < max_vertex_attribs_);
+    DCHECK_LT(index, attrib_values.size());
     int shift_bits = (index % 16) * 2;
     generic_attrib_base_type_mask_[index / 16] &= ~(0x3 << shift_bits);
     generic_attrib_base_type_mask_[index / 16] |= (base_type << shift_bits);
   }
 
-  // Return 16 attributes' base types, in which the generic attribute
-  // specified by argument 'index' located.
-  uint32_t GetGenericVertexAttribBaseTypeMask(GLuint index) {
-    DCHECK(index < max_vertex_attribs_);
-    return generic_attrib_base_type_mask_[index / 16];
+  const std::vector<uint32_t>& generic_attrib_base_type_mask() const {
+    return generic_attrib_base_type_mask_;
   }
 
   void UnbindTexture(TextureRef* texture);
@@ -346,10 +343,9 @@
 
   bool framebuffer_srgb_;
 
-  uint32_t max_vertex_attribs_;
   // Generic vertex attrib base types: FLOAT, INT, or UINT.
   // Each base type is encoded into 2 bits, the lowest 2 bits for location 0,
-  // the highest 2 bits for location (max_vertex_attribs_ - 1).
+  // the highest 2 bits for location (max_vertex_attribs - 1).
   std::vector<uint32_t> generic_attrib_base_type_mask_;
 
   FeatureInfo* feature_info_;