Add a helper method GetInfoForTarget() to TextureUnit.

In addition to eliminating some redundant code, this fixes a bug in
RestoreStateForTextures() where the texture being restored was assumed to be
either bound_texture_2d or bound_texture_cube_map.

BUG=533617

Review URL: https://codereview.chromium.org/1529343002

Cr-Commit-Position: refs/heads/master@{#365722}
diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h
index 911879e..7a44edc5 100644
--- a/gpu/command_buffer/service/context_state.h
+++ b/gpu/command_buffer/service/context_state.h
@@ -80,6 +80,26 @@
     NOTREACHED();
     return NULL;
   }
+
+  scoped_refptr<TextureRef>& GetInfoForTarget(GLenum target) {
+    switch (target) {
+      case GL_TEXTURE_2D:
+        return bound_texture_2d;
+      case GL_TEXTURE_CUBE_MAP:
+        return bound_texture_cube_map;
+      case GL_TEXTURE_EXTERNAL_OES:
+        return bound_texture_external_oes;
+      case GL_TEXTURE_RECTANGLE_ARB:
+        return bound_texture_rectangle_arb;
+      case GL_TEXTURE_3D:
+        return bound_texture_3d;
+      case GL_TEXTURE_2D_ARRAY:
+        return bound_texture_2d_array;
+    }
+
+    NOTREACHED();
+    return bound_texture_2d;
+  }
 };
 
 class GPU_EXPORT Vec4 {