Rename RasterDecoderContextState to DecoderContextState

Also convert RasterDecoderContextState from struct to class.

TODO:
 * rename raster_decoder_context_state.h to decoder_context_state.h

Bug: 919865
Change-Id: I77cb8d369c1e0c736434da6bbb144c863d9ec3f6
Reviewed-on: https://chromium-review.googlesource.com/c/1426060
Commit-Queue: Peng Huang <penghuang@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Reviewed-by: Jonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625194}
diff --git a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc
index 702069a9..e301bb5 100644
--- a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc
+++ b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc
@@ -687,7 +687,7 @@
       context_lost_callback_.Run();
       return false;
     }
-    context_state_->need_context_state_reset = true;
+    context_state_->set_need_context_state_reset(true);
   }
   return true;
 }
diff --git a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h
index 9e875cf7..5c382b7 100644
--- a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h
+++ b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h
@@ -155,7 +155,7 @@
   // It will do nothing when Vulkan is used.
   bool MakeCurrent();
 
-  GrContext* gr_context() { return context_state_->gr_context; }
+  GrContext* gr_context() { return context_state_->gr_context(); }
 
   const gpu::CommandBufferId command_buffer_id_;
   GpuServiceImpl* const gpu_service_;
@@ -173,7 +173,7 @@
   gpu::GpuPreferences gpu_preferences_;
   scoped_refptr<gl::GLSurface> gl_surface_;
   sk_sp<SkSurface> sk_surface_;
-  scoped_refptr<gpu::raster::RasterDecoderContextState> context_state_;
+  scoped_refptr<gpu::SharedContextState> context_state_;
   const gl::GLVersionInfo* gl_version_info_ = nullptr;
   OutputSurface::Capabilities capabilities_;
   std::unique_ptr<gpu::SharedImageRepresentationFactory>
diff --git a/components/viz/service/gl/gpu_service_impl.cc b/components/viz/service/gl/gpu_service_impl.cc
index a2cd11ef..f6ae8566 100644
--- a/components/viz/service/gl/gpu_service_impl.cc
+++ b/components/viz/service/gl/gpu_service_impl.cc
@@ -291,13 +291,12 @@
   (*gpu_host_)->DisableGpuCompositing();
 }
 
-scoped_refptr<gpu::raster::RasterDecoderContextState>
+scoped_refptr<gpu::SharedContextState>
 GpuServiceImpl::GetContextStateForGLSurface(gl::GLSurface* surface) {
   DCHECK(main_runner_->BelongsToCurrentThread());
   DCHECK(!is_using_vulkan());
   gpu::ContextResult result;
-  auto context_state =
-      gpu_channel_manager_->GetRasterDecoderContextState(&result);
+  auto context_state = gpu_channel_manager_->GetSharedContextState(&result);
   // TODO(penghuang): https://crbug.com/899740 Support GLSurface which is not
   // compatible.
   DCHECK_EQ(surface->GetCompatibilityKey(),
@@ -305,12 +304,12 @@
   return context_state;
 }
 
-scoped_refptr<gpu::raster::RasterDecoderContextState>
+scoped_refptr<gpu::SharedContextState>
 GpuServiceImpl::GetContextStateForVulkan() {
   DCHECK(main_runner_->BelongsToCurrentThread());
   DCHECK(is_using_vulkan());
   gpu::ContextResult result;
-  return gpu_channel_manager_->GetRasterDecoderContextState(&result);
+  return gpu_channel_manager_->GetSharedContextState(&result);
 }
 
 gpu::ImageFactory* GpuServiceImpl::gpu_image_factory() {
diff --git a/components/viz/service/gl/gpu_service_impl.h b/components/viz/service/gl/gpu_service_impl.h
index 160a73f..08fd68d 100644
--- a/components/viz/service/gl/gpu_service_impl.h
+++ b/components/viz/service/gl/gpu_service_impl.h
@@ -51,9 +51,7 @@
 }
 
 namespace gpu {
-namespace raster {
-struct RasterDecoderContextState;
-}  // namespace raster
+class SharedContextState;
 }  // namespace gpu
 
 namespace viz {
@@ -89,10 +87,9 @@
       base::WaitableEvent* shutdown_event = nullptr);
   void Bind(mojom::GpuServiceRequest request);
 
-  scoped_refptr<gpu::raster::RasterDecoderContextState>
-  GetContextStateForGLSurface(gl::GLSurface* surface);
-  scoped_refptr<gpu::raster::RasterDecoderContextState>
-  GetContextStateForVulkan();
+  scoped_refptr<gpu::SharedContextState> GetContextStateForGLSurface(
+      gl::GLSurface* surface);
+  scoped_refptr<gpu::SharedContextState> GetContextStateForVulkan();
 
   // Notifies the GpuHost to stop using GPU compositing. This should be called
   // in response to an error in the GPU process that occurred after
diff --git a/gpu/command_buffer/service/gr_cache_controller.cc b/gpu/command_buffer/service/gr_cache_controller.cc
index 787ef40..1196a992 100644
--- a/gpu/command_buffer/service/gr_cache_controller.cc
+++ b/gpu/command_buffer/service/gr_cache_controller.cc
@@ -13,7 +13,7 @@
 namespace raster {
 
 GrCacheController::GrCacheController(
-    RasterDecoderContextState* context_state,
+    SharedContextState* context_state,
     scoped_refptr<base::SingleThreadTaskRunner> task_runner)
     : context_state_(context_state), task_runner_(std::move(task_runner)) {}
 
@@ -23,7 +23,7 @@
   DCHECK(task_runner_->BelongsToCurrentThread());
   DCHECK(context_state_->IsCurrent(nullptr));
 
-  if (!context_state_->gr_context)
+  if (!context_state_->gr_context())
     return;
 
   current_idle_id_++;
@@ -35,8 +35,8 @@
   // a long while even if it is under budget. Below we set a call back to
   // purge all possible GrContext resources if the context itself is not being
   // used.
-  context_state_->need_context_state_reset = true;
-  context_state_->gr_context->performDeferredCleanup(
+  context_state_->set_need_context_state_reset(true);
+  context_state_->gr_context()->performDeferredCleanup(
       std::chrono::seconds(kOldResourceCleanupDelaySeconds));
 
   constexpr int kIdleCleanupDelaySeconds = 1;
@@ -63,8 +63,8 @@
     return;
   }
 
-  context_state_->need_context_state_reset = true;
-  context_state_->gr_context->freeGpuResources();
+  context_state_->set_need_context_state_reset(true);
+  context_state_->gr_context()->freeGpuResources();
 }
 
 }  // namespace raster
diff --git a/gpu/command_buffer/service/gr_cache_controller.h b/gpu/command_buffer/service/gr_cache_controller.h
index 2c0b044a..d207a923 100644
--- a/gpu/command_buffer/service/gr_cache_controller.h
+++ b/gpu/command_buffer/service/gr_cache_controller.h
@@ -10,8 +10,10 @@
 #include "gpu/gpu_gles2_export.h"
 
 namespace gpu {
+
+class SharedContextState;
+
 namespace raster {
-struct RasterDecoderContextState;
 
 // Manages clearing the GrContext cache after a period of inactivity.
 // TODO(khushalsagar): This class replicates the ContextCacheController used in
@@ -19,7 +21,7 @@
 // gpu::Scheduler, since it can better identify when we are in an idle state.
 class GPU_GLES2_EXPORT GrCacheController {
  public:
-  GrCacheController(RasterDecoderContextState* context_state,
+  GrCacheController(SharedContextState* context_state,
                     scoped_refptr<base::SingleThreadTaskRunner> task_runner);
   ~GrCacheController();
 
@@ -36,7 +38,7 @@
   // cache.
   uint64_t current_idle_id_ = 0u;
   base::CancelableOnceClosure purge_gr_cache_cb_;
-  RasterDecoderContextState* context_state_;
+  SharedContextState* context_state_;
   scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
 
   DISALLOW_COPY_AND_ASSIGN(GrCacheController);
diff --git a/gpu/command_buffer/service/gr_cache_controller_unittest.cc b/gpu/command_buffer/service/gr_cache_controller_unittest.cc
index cee2e53..f6b9626 100644
--- a/gpu/command_buffer/service/gr_cache_controller_unittest.cc
+++ b/gpu/command_buffer/service/gr_cache_controller_unittest.cc
@@ -36,8 +36,8 @@
         share_group.get(), surface.get(), gl::GLContextAttribs());
     ASSERT_TRUE(context->MakeCurrent(surface.get()));
 
-    task_runner_ = new base::TestMockTimeTaskRunner();
-    context_state_ = new raster::RasterDecoderContextState(
+    task_runner_ = base::MakeRefCounted<base::TestMockTimeTaskRunner>();
+    context_state_ = base::MakeRefCounted<SharedContextState>(
         std::move(share_group), std::move(surface), std::move(context),
         false /* use_virtualized_gl_contexts */, base::DoNothing());
     context_state_->InitializeGrContext(workarounds, nullptr);
@@ -56,10 +56,10 @@
     gl::init::ShutdownGL(false);
   }
 
-  GrContext* gr_context() { return context_state_->gr_context; }
+  GrContext* gr_context() { return context_state_->gr_context(); }
 
  protected:
-  scoped_refptr<RasterDecoderContextState> context_state_;
+  scoped_refptr<SharedContextState> context_state_;
   scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
   std::unique_ptr<GrCacheController> controller_;
 };
diff --git a/gpu/command_buffer/service/raster_decoder.cc b/gpu/command_buffer/service/raster_decoder.cc
index 762f0905..25105c22 100644
--- a/gpu/command_buffer/service/raster_decoder.cc
+++ b/gpu/command_buffer/service/raster_decoder.cc
@@ -200,12 +200,11 @@
                                 public gles2::ErrorStateClient,
                                 public ServiceFontManager::Client {
  public:
-  RasterDecoderImpl(
-      DecoderClient* client,
-      CommandBufferServiceBase* command_buffer_service,
-      gles2::Outputter* outputter,
-      gles2::ContextGroup* group,
-      scoped_refptr<RasterDecoderContextState> raster_decoder_context_state);
+  RasterDecoderImpl(DecoderClient* client,
+                    CommandBufferServiceBase* command_buffer_service,
+                    gles2::Outputter* outputter,
+                    gles2::ContextGroup* group,
+                    scoped_refptr<SharedContextState> shared_context_state);
   ~RasterDecoderImpl() override;
 
   gles2::GLES2Util* GetGLES2Util() override { return &util_; }
@@ -349,14 +348,12 @@
       NOTREACHED();
       return nullptr;
     }
-    return raster_decoder_context_state_->context_state();
+    return shared_context_state_->context_state();
   }
   gl::GLApi* api() const { return api_; }
-  GrContext* gr_context() const {
-    return raster_decoder_context_state_->gr_context;
-  }
+  GrContext* gr_context() const { return shared_context_state_->gr_context(); }
   ServiceTransferCache* transfer_cache() {
-    return raster_decoder_context_state_->transfer_cache.get();
+    return shared_context_state_->transfer_cache();
   }
 
   const gles2::FeatureInfo::FeatureFlags& features() const {
@@ -369,7 +366,7 @@
 
   bool IsRobustnessSupported() {
     return has_robustness_extension_ &&
-           raster_decoder_context_state_->context()
+           shared_context_state_->context()
                ->WasAllocatedUsingRobustnessExtension();
   }
 
@@ -530,7 +527,7 @@
 
   // The ContextGroup for this decoder uses to track resources.
   scoped_refptr<gles2::ContextGroup> group_;
-  scoped_refptr<RasterDecoderContextState> raster_decoder_context_state_;
+  scoped_refptr<SharedContextState> shared_context_state_;
   std::unique_ptr<Validators> validators_;
   scoped_refptr<gles2::FeatureInfo> feature_info_;
 
@@ -599,9 +596,9 @@
     CommandBufferServiceBase* command_buffer_service,
     gles2::Outputter* outputter,
     gles2::ContextGroup* group,
-    scoped_refptr<RasterDecoderContextState> raster_decoder_context_state) {
+    scoped_refptr<SharedContextState> shared_context_state) {
   return new RasterDecoderImpl(client, command_buffer_service, outputter, group,
-                               std::move(raster_decoder_context_state));
+                               std::move(shared_context_state));
 }
 
 RasterDecoder::RasterDecoder(CommandBufferServiceBase* command_buffer_service,
@@ -649,7 +646,7 @@
     CommandBufferServiceBase* command_buffer_service,
     gles2::Outputter* outputter,
     gles2::ContextGroup* group,
-    scoped_refptr<RasterDecoderContextState> raster_decoder_context_state)
+    scoped_refptr<SharedContextState> shared_context_state)
     : RasterDecoder(command_buffer_service, outputter),
       raster_decoder_id_(g_raster_decoder_id.GetNext() + 1),
       client_(client),
@@ -660,7 +657,7 @@
               group->gpu_preferences().disable_gl_error_limit),
       error_state_(gles2::ErrorState::Create(this, &logger_)),
       group_(group),
-      raster_decoder_context_state_(std::move(raster_decoder_context_state)),
+      shared_context_state_(std::move(shared_context_state)),
       validators_(new Validators),
       feature_info_(group_->feature_info()),
       service_logging_(
@@ -669,7 +666,7 @@
           TRACE_DISABLED_BY_DEFAULT("gpu.decoder"))),
       font_manager_(base::MakeRefCounted<ServiceFontManager>(this)),
       weak_ptr_factory_(this) {
-  DCHECK(raster_decoder_context_state_);
+  DCHECK(shared_context_state_);
 }
 
 RasterDecoderImpl::~RasterDecoderImpl() {
@@ -688,7 +685,7 @@
     const gles2::DisallowedFeatures& disallowed_features,
     const ContextCreationAttribs& attrib_helper) {
   TRACE_EVENT0("gpu", "RasterDecoderImpl::Initialize");
-  DCHECK(raster_decoder_context_state_->IsCurrent(surface.get()));
+  DCHECK(shared_context_state_->IsCurrent(surface.get()));
   DCHECK(!context_.get());
 
   api_ = gl::g_current_gl_context;
@@ -705,8 +702,8 @@
   if (group_->gpu_preferences().enable_gpu_command_logging)
     SetLogCommands(true);
 
-  DCHECK_EQ(surface.get(), raster_decoder_context_state_->surface());
-  DCHECK_EQ(context.get(), raster_decoder_context_state_->context());
+  DCHECK_EQ(surface.get(), shared_context_state_->surface());
+  DCHECK_EQ(context.get(), shared_context_state_->context());
   context_ = context;
 
   // Create GPU Tracer for timing values.
@@ -741,7 +738,7 @@
       return ContextResult::kFatalFailure;
     }
 
-    supports_oop_raster_ = !!raster_decoder_context_state_->gr_context;
+    supports_oop_raster_ = !!shared_context_state_->gr_context();
     if (supports_oop_raster_)
       paint_cache_ = std::make_unique<cc::ServicePaintCache>();
     use_ddl_ = group_->gpu_preferences().enable_oop_rasterization_ddl;
@@ -754,8 +751,7 @@
   if (!initialized())
     return;
 
-  DCHECK(!have_context ||
-         raster_decoder_context_state_->context()->IsCurrent(nullptr));
+  DCHECK(!have_context || shared_context_state_->context()->IsCurrent(nullptr));
 
   if (have_context) {
     if (copy_tex_image_blit_.get()) {
@@ -808,7 +804,7 @@
 
 // Make this decoder's GL context current.
 bool RasterDecoderImpl::MakeCurrent() {
-  if (raster_decoder_context_state_->use_vulkan_gr_context)
+  if (shared_context_state_->use_vulkan_gr_context())
     return true;
 
   if (!context_.get())
@@ -819,8 +815,8 @@
     return false;
   }
 
-  if (raster_decoder_context_state_->context_lost() ||
-      !raster_decoder_context_state_->MakeCurrent(nullptr)) {
+  if (shared_context_state_->context_lost() ||
+      !shared_context_state_->MakeCurrent(nullptr)) {
     LOG(ERROR) << "  RasterDecoderImpl: Context lost during MakeCurrent.";
     MarkContextLost(error::kMakeCurrentFailed);
     group_->LoseContexts(error::kUnknown);
@@ -847,7 +843,7 @@
 }
 
 gl::GLSurface* RasterDecoderImpl::GetGLSurface() {
-  return raster_decoder_context_state_->surface();
+  return shared_context_state_->surface();
 }
 
 Capabilities RasterDecoderImpl::GetCapabilities() {
@@ -873,7 +869,7 @@
     caps.context_supports_distance_field_text =
         gr_context()->supportsDistanceFieldText();
     caps.glyph_cache_max_texture_bytes =
-        raster_decoder_context_state_->glyph_cache_max_texture_bytes;
+        shared_context_state_->glyph_cache_max_texture_bytes();
   }
   return caps;
 }
@@ -886,52 +882,52 @@
 void RasterDecoderImpl::RestoreGlobalState() const {
   // We mark the context state is dirty instead of restoring global
   // state, and the global state will be restored by the next context.
-  raster_decoder_context_state_->need_context_state_reset = true;
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->set_need_context_state_reset(true);
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::ClearAllAttributes() const {}
 
 void RasterDecoderImpl::RestoreAllAttributes() const {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreState(const gles2::ContextState* prev_state) {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreActiveTexture() const {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreAllTextureUnitAndSamplerBindings(
     const gles2::ContextState* prev_state) const {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreActiveTextureUnitBinding(
     unsigned int target) const {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreBufferBinding(unsigned int target) {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreBufferBindings() const {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreFramebufferBindings() const {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreRenderbufferBindings() {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreProgramBindings() const {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreTextureState(unsigned service_id) {
@@ -940,15 +936,15 @@
 }
 
 void RasterDecoderImpl::RestoreTextureUnitBindings(unsigned unit) const {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreVertexAttribArray(unsigned index) {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 void RasterDecoderImpl::RestoreAllExternalTextureBindingsIfNeeded() {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 QueryManager* RasterDecoderImpl::GetQueryManager() {
@@ -1033,7 +1029,7 @@
 
 bool RasterDecoderImpl::CheckResetStatus() {
   DCHECK(!WasContextLost());
-  DCHECK(raster_decoder_context_state_->context()->IsCurrent(nullptr));
+  DCHECK(shared_context_state_->context()->IsCurrent(nullptr));
 
   if (IsRobustnessSupported()) {
     // If the reason for the call was a GL error, we can try to determine the
@@ -1337,7 +1333,7 @@
     ScopedTextureBinder binder(state(), texture->target(),
                                texture->service_id(), gr_context());
     base::Optional<ScopedPixelUnpackState> pixel_unpack_state;
-    if (raster_decoder_context_state_->need_context_state_reset) {
+    if (shared_context_state_->need_context_state_reset()) {
       pixel_unpack_state.emplace(state(), gr_context(), group_->feature_info());
     }
     // Add extra scope to destroy zero and the object it owns right
@@ -1374,7 +1370,7 @@
 }
 
 ServiceTransferCache* RasterDecoderImpl::GetTransferCacheForTest() {
-  return raster_decoder_context_state_->transfer_cache.get();
+  return shared_context_state_->transfer_cache();
 }
 
 void RasterDecoderImpl::SetUpForRasterCHROMIUMForTest() {
@@ -1522,13 +1518,13 @@
 }
 
 void RasterDecoderImpl::DoFinish() {
-  if (!raster_decoder_context_state_->use_vulkan_gr_context)
+  if (!shared_context_state_->use_vulkan_gr_context())
     api()->glFinishFn();
   ProcessPendingQueries(true);
 }
 
 void RasterDecoderImpl::DoFlush() {
-  if (!raster_decoder_context_state_->use_vulkan_gr_context)
+  if (!shared_context_state_->use_vulkan_gr_context())
     api()->glFlushFn();
   ProcessPendingQueries(false);
 }
@@ -1761,7 +1757,7 @@
     }
 
     if (image->GetType() == gl::GLImage::Type::MEMORY &&
-        raster_decoder_context_state_->need_context_state_reset) {
+        shared_context_state_->need_context_state_reset()) {
       // If the image is in shared memory, we may need upload the pixel data
       // with SubTexImage2D, so we need reset pixel unpack state if gl context
       // state has been touched by skia.
@@ -1941,7 +1937,7 @@
       api()->glTexParameteriFn(target, GL_TEXTURE_MAG_FILTER,
                                texture->mag_filter());
     }
-    raster_decoder_context_state_->PessimisticallyResetGrContext();
+    shared_context_state_->PessimisticallyResetGrContext();
   }
 }
 
@@ -2078,7 +2074,7 @@
 
   DCHECK(locked_handles_.empty());
   DCHECK(!raster_canvas_);
-  raster_decoder_context_state_->need_context_state_reset = true;
+  shared_context_state_->set_need_context_state_reset(true);
 
   // Use unknown pixel geometry to disable LCD text.
   uint32_t flags = 0;
@@ -2167,7 +2163,7 @@
     return;
   }
   DCHECK(transfer_cache());
-  raster_decoder_context_state_->need_context_state_reset = true;
+  shared_context_state_->set_need_context_state_reset(true);
 
   if (font_shm_size > 0) {
     // Deserialize fonts before raster.
@@ -2206,7 +2202,7 @@
   TransferCacheDeserializeHelperImpl impl(raster_decoder_id_, transfer_cache());
   cc::PaintOp::DeserializeOptions options(
       &impl, paint_cache_.get(), font_manager_->strike_client(),
-      &raster_decoder_context_state_->scratch_deserialization_buffer_);
+      shared_context_state_->scratch_deserialization_buffer());
   options.crash_dump_on_failure = true;
 
   size_t paint_buffer_size = raster_shm_size;
@@ -2237,7 +2233,7 @@
     return;
   }
 
-  raster_decoder_context_state_->need_context_state_reset = true;
+  shared_context_state_->set_need_context_state_reset(true);
 
   raster_canvas_.reset();
 
@@ -2323,7 +2319,7 @@
       cc::ServiceTransferCacheEntry::UsesGrContext(entry_type) ? gr_context()
                                                                : nullptr;
   if (context_for_entry)
-    raster_decoder_context_state_->need_context_state_reset = true;
+    shared_context_state_->set_need_context_state_reset(true);
 
   if (!transfer_cache()->CreateLockedEntry(
           ServiceTransferCache::EntryKey(raster_decoder_id_, entry_type,
@@ -2389,7 +2385,7 @@
 
 void RasterDecoderImpl::RestoreStateForAttrib(GLuint attrib_index,
                                               bool restore_array_binding) {
-  raster_decoder_context_state_->PessimisticallyResetGrContext();
+  shared_context_state_->PessimisticallyResetGrContext();
 }
 
 // Include the auto-generated part of this file. We split this because it means
diff --git a/gpu/command_buffer/service/raster_decoder.h b/gpu/command_buffer/service/raster_decoder.h
index 40b3e30..717b79d 100644
--- a/gpu/command_buffer/service/raster_decoder.h
+++ b/gpu/command_buffer/service/raster_decoder.h
@@ -13,6 +13,7 @@
 namespace gpu {
 
 class DecoderClient;
+class SharedContextState;
 class ServiceTransferCache;
 
 namespace gles2 {
@@ -24,7 +25,6 @@
 }  // namespace gles2
 
 namespace raster {
-struct RasterDecoderContextState;
 
 // This class implements the AsyncAPIInterface interface, decoding
 // RasterInterface commands and calling GL.
@@ -36,7 +36,7 @@
       CommandBufferServiceBase* command_buffer_service,
       gles2::Outputter* outputter,
       gles2::ContextGroup* group,
-      scoped_refptr<RasterDecoderContextState> raster_decoder_context_state);
+      scoped_refptr<SharedContextState> shared_context_state);
 
   ~RasterDecoder() override;
 
diff --git a/gpu/command_buffer/service/raster_decoder_context_state.cc b/gpu/command_buffer/service/raster_decoder_context_state.cc
index 843c978d..7018d980 100644
--- a/gpu/command_buffer/service/raster_decoder_context_state.cc
+++ b/gpu/command_buffer/service/raster_decoder_context_state.cc
@@ -28,54 +28,53 @@
 }
 
 namespace gpu {
-namespace raster {
 
-RasterDecoderContextState::RasterDecoderContextState(
+SharedContextState::SharedContextState(
     scoped_refptr<gl::GLShareGroup> share_group,
     scoped_refptr<gl::GLSurface> surface,
     scoped_refptr<gl::GLContext> context,
     bool use_virtualized_gl_contexts,
     base::OnceClosure context_lost_callback,
     viz::VulkanContextProvider* vulkan_context_provider)
-    : use_virtualized_gl_contexts(use_virtualized_gl_contexts),
-      context_lost_callback(std::move(context_lost_callback)),
-      vk_context_provider(vulkan_context_provider),
+    : use_virtualized_gl_contexts_(use_virtualized_gl_contexts),
+      context_lost_callback_(std::move(context_lost_callback)),
+      vk_context_provider_(vulkan_context_provider),
 #if BUILDFLAG(ENABLE_VULKAN)
-      gr_context(vk_context_provider ? vk_context_provider->GetGrContext()
-                                     : nullptr),
+      gr_context_(vk_context_provider_ ? vk_context_provider_->GetGrContext()
+                                       : nullptr),
 #endif
-      use_vulkan_gr_context(!!vk_context_provider),
+      use_vulkan_gr_context_(!!vk_context_provider_),
       share_group_(std::move(share_group)),
       context_(context),
       real_context_(std::move(context)),
       surface_(std::move(surface)),
       weak_ptr_factory_(this) {
-  if (use_vulkan_gr_context) {
-    DCHECK(gr_context);
-    use_virtualized_gl_contexts = false;
+  if (use_vulkan_gr_context_) {
+    DCHECK(gr_context_);
+    use_virtualized_gl_contexts_ = false;
   }
   if (base::ThreadTaskRunnerHandle::IsSet()) {
     base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
-        this, "RasterDecoderContextState", base::ThreadTaskRunnerHandle::Get());
+        this, "SharedContextState", base::ThreadTaskRunnerHandle::Get());
   }
   // Initialize the scratch buffer to some small initial size.
   scratch_deserialization_buffer_.resize(
       kInitialScratchDeserializationBufferSize);
 }
 
-RasterDecoderContextState::~RasterDecoderContextState() {
-  if (gr_context)
-    gr_context->abandonContext();
+SharedContextState::~SharedContextState() {
+  if (gr_context_)
+    gr_context_->abandonContext();
   base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
       this);
 }
 
-void RasterDecoderContextState::InitializeGrContext(
+void SharedContextState::InitializeGrContext(
     const GpuDriverBugWorkarounds& workarounds,
     GrContextOptions::PersistentCache* cache,
     GpuProcessActivityFlags* activity_flags,
     gl::ProgressReporter* progress_reporter) {
-  if (!use_vulkan_gr_context) {
+  if (!use_vulkan_gr_context_) {
     DCHECK(context_->IsCurrent(nullptr));
     sk_sp<GrGLInterface> interface(gl::init::CreateGrGLInterface(
         *context_->GetVersionInfo(), workarounds.use_es2_for_oopr,
@@ -108,25 +107,25 @@
     options.fDisableCoverageCountingPaths = true;
     size_t max_resource_cache_bytes = 0u;
     raster::DetermineGrCacheLimitsFromAvailableMemory(
-        &max_resource_cache_bytes, &glyph_cache_max_texture_bytes);
-    options.fGlyphCacheTextureMaximumBytes = glyph_cache_max_texture_bytes;
+        &max_resource_cache_bytes, &glyph_cache_max_texture_bytes_);
+    options.fGlyphCacheTextureMaximumBytes = glyph_cache_max_texture_bytes_;
     options.fPersistentCache = cache;
     options.fAvoidStencilBuffers = workarounds.avoid_stencil_buffers;
-    owned_gr_context = GrContext::MakeGL(std::move(interface), options);
-    gr_context = owned_gr_context.get();
-    if (!gr_context) {
+    owned_gr_context_ = GrContext::MakeGL(std::move(interface), options);
+    gr_context_ = owned_gr_context_.get();
+    if (!gr_context_) {
       LOG(ERROR) << "OOP raster support disabled: GrContext creation "
                     "failed.";
     } else {
       constexpr int kMaxGaneshResourceCacheCount = 16384;
-      gr_context->setResourceCacheLimits(kMaxGaneshResourceCacheCount,
-                                         max_resource_cache_bytes);
+      gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount,
+                                          max_resource_cache_bytes);
     }
   }
-  transfer_cache = std::make_unique<ServiceTransferCache>();
+  transfer_cache_ = std::make_unique<ServiceTransferCache>();
 }
 
-bool RasterDecoderContextState::InitializeGL(
+bool SharedContextState::InitializeGL(
     const GpuPreferences& gpu_preferences,
     scoped_refptr<gles2::FeatureInfo> feature_info) {
   // We still need initialize GL when Vulkan is used, because RasterDecoder
@@ -168,7 +167,7 @@
   context_state_->InitCapabilities(nullptr);
   context_state_->InitState(nullptr);
 
-  if (use_virtualized_gl_contexts) {
+  if (use_virtualized_gl_contexts_) {
     auto virtual_context = base::MakeRefCounted<GLContextVirtual>(
         share_group_.get(), real_context_.get(),
         weak_ptr_factory_.GetWeakPtr());
@@ -183,8 +182,8 @@
   return true;
 }
 
-bool RasterDecoderContextState::MakeCurrent(gl::GLSurface* surface) {
-  if (use_vulkan_gr_context)
+bool SharedContextState::MakeCurrent(gl::GLSurface* surface) {
+  if (use_vulkan_gr_context_)
     return true;
 
   if (context_lost_)
@@ -197,36 +196,36 @@
   return true;
 }
 
-void RasterDecoderContextState::MarkContextLost() {
+void SharedContextState::MarkContextLost() {
   if (!context_lost_) {
     context_lost_ = true;
     // context_state_ could be nullptr for some unittests.
     if (context_state_)
       context_state_->MarkContextLost();
-    if (gr_context)
-      gr_context->abandonContext();
-    std::move(context_lost_callback).Run();
+    if (gr_context_)
+      gr_context_->abandonContext();
+    std::move(context_lost_callback_).Run();
   }
 }
 
-bool RasterDecoderContextState::IsCurrent(gl::GLSurface* surface) {
-  if (use_vulkan_gr_context)
+bool SharedContextState::IsCurrent(gl::GLSurface* surface) {
+  if (use_vulkan_gr_context_)
     return true;
   return context_->IsCurrent(surface);
 }
 
-bool RasterDecoderContextState::OnMemoryDump(
+bool SharedContextState::OnMemoryDump(
     const base::trace_event::MemoryDumpArgs& args,
     base::trace_event::ProcessMemoryDump* pmd) {
-  if (gr_context)
-    DumpGrMemoryStatistics(gr_context, pmd, base::nullopt);
+  if (gr_context_)
+    raster::DumpGrMemoryStatistics(gr_context_, pmd, base::nullopt);
   return true;
 }
 
-void RasterDecoderContextState::PurgeMemory(
+void SharedContextState::PurgeMemory(
     base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
-  if (!gr_context) {
-    DCHECK(!transfer_cache);
+  if (!gr_context_) {
+    DCHECK(!transfer_cache_);
     return;
   }
 
@@ -240,36 +239,36 @@
       return;
     case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE:
       // With moderate pressure, clear any unlocked resources.
-      gr_context->purgeUnlockedResources(true /* scratchResourcesOnly */);
+      gr_context_->purgeUnlockedResources(true /* scratchResourcesOnly */);
       scratch_deserialization_buffer_.resize(
           kInitialScratchDeserializationBufferSize);
       scratch_deserialization_buffer_.shrink_to_fit();
       break;
     case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL:
       // With critical pressure, purge as much as possible.
-      gr_context->freeGpuResources();
+      gr_context_->freeGpuResources();
       scratch_deserialization_buffer_.resize(0u);
       scratch_deserialization_buffer_.shrink_to_fit();
       break;
   }
 
-  transfer_cache->PurgeMemory(memory_pressure_level);
+  transfer_cache_->PurgeMemory(memory_pressure_level);
 }
 
-void RasterDecoderContextState::PessimisticallyResetGrContext() const {
+void SharedContextState::PessimisticallyResetGrContext() const {
   // Calling GrContext::resetContext() is very cheap, so we do it
   // pessimistically. We could dirty less state if skia state setting
   // performance becomes an issue.
-  if (gr_context && !use_vulkan_gr_context)
-    gr_context->resetContext();
+  if (gr_context_ && !use_vulkan_gr_context_)
+    gr_context_->resetContext();
 }
 
-bool RasterDecoderContextState::initialized() const {
+bool SharedContextState::initialized() const {
   return true;
 }
 
-const gles2::ContextState* RasterDecoderContextState::GetContextState() {
-  if (need_context_state_reset) {
+const gles2::ContextState* SharedContextState::GetContextState() {
+  if (need_context_state_reset_) {
     // Returning nullptr to force full state restoration by the caller.  We do
     // this because GrContext changes to GL state are untracked in our
     // context_state_.
@@ -278,34 +277,33 @@
   return context_state_.get();
 }
 
-void RasterDecoderContextState::RestoreState(
-    const gles2::ContextState* prev_state) {
+void SharedContextState::RestoreState(const gles2::ContextState* prev_state) {
   PessimisticallyResetGrContext();
   context_state_->RestoreState(prev_state);
-  need_context_state_reset = false;
+  need_context_state_reset_ = false;
 }
 
-void RasterDecoderContextState::RestoreGlobalState() const {
+void SharedContextState::RestoreGlobalState() const {
   PessimisticallyResetGrContext();
   context_state_->RestoreGlobalState(nullptr);
 }
-void RasterDecoderContextState::ClearAllAttributes() const {}
+void SharedContextState::ClearAllAttributes() const {}
 
-void RasterDecoderContextState::RestoreActiveTexture() const {
+void SharedContextState::RestoreActiveTexture() const {
   PessimisticallyResetGrContext();
 }
 
-void RasterDecoderContextState::RestoreAllTextureUnitAndSamplerBindings(
+void SharedContextState::RestoreAllTextureUnitAndSamplerBindings(
     const gles2::ContextState* prev_state) const {
   PessimisticallyResetGrContext();
 }
 
-void RasterDecoderContextState::RestoreActiveTextureUnitBinding(
+void SharedContextState::RestoreActiveTextureUnitBinding(
     unsigned int target) const {
   PessimisticallyResetGrContext();
 }
 
-void RasterDecoderContextState::RestoreBufferBinding(unsigned int target) {
+void SharedContextState::RestoreBufferBinding(unsigned int target) {
   PessimisticallyResetGrContext();
   if (target == GL_PIXEL_PACK_BUFFER) {
     context_state_->UpdatePackParameters();
@@ -315,43 +313,41 @@
   context_state_->api()->glBindBufferFn(target, 0);
 }
 
-void RasterDecoderContextState::RestoreBufferBindings() const {
+void SharedContextState::RestoreBufferBindings() const {
   PessimisticallyResetGrContext();
   context_state_->RestoreBufferBindings();
 }
 
-void RasterDecoderContextState::RestoreFramebufferBindings() const {
+void SharedContextState::RestoreFramebufferBindings() const {
   PessimisticallyResetGrContext();
   context_state_->fbo_binding_for_scissor_workaround_dirty = true;
   context_state_->stencil_state_changed_since_validation = true;
 }
 
-void RasterDecoderContextState::RestoreRenderbufferBindings() {
+void SharedContextState::RestoreRenderbufferBindings() {
   PessimisticallyResetGrContext();
   context_state_->RestoreRenderbufferBindings();
 }
 
-void RasterDecoderContextState::RestoreProgramBindings() const {
+void SharedContextState::RestoreProgramBindings() const {
   PessimisticallyResetGrContext();
   context_state_->RestoreProgramSettings(nullptr, false);
 }
 
-void RasterDecoderContextState::RestoreTextureUnitBindings(
-    unsigned unit) const {
+void SharedContextState::RestoreTextureUnitBindings(unsigned unit) const {
   PessimisticallyResetGrContext();
 }
 
-void RasterDecoderContextState::RestoreVertexAttribArray(unsigned index) {
+void SharedContextState::RestoreVertexAttribArray(unsigned index) {
   NOTIMPLEMENTED();
 }
 
-void RasterDecoderContextState::RestoreAllExternalTextureBindingsIfNeeded() {
+void SharedContextState::RestoreAllExternalTextureBindingsIfNeeded() {
   PessimisticallyResetGrContext();
 }
 
-QueryManager* RasterDecoderContextState::GetQueryManager() {
+QueryManager* SharedContextState::GetQueryManager() {
   return nullptr;
 }
 
-}  // namespace raster
 }  // namespace gpu
diff --git a/gpu/command_buffer/service/raster_decoder_context_state.h b/gpu/command_buffer/service/raster_decoder_context_state.h
index c985f47..a9443d1 100644
--- a/gpu/command_buffer/service/raster_decoder_context_state.h
+++ b/gpu/command_buffer/service/raster_decoder_context_state.h
@@ -36,17 +36,14 @@
 struct ContextState;
 }  // namespace gles2
 
-namespace raster {
-
-// TODO(penghuang): Make RasterDecoderContextState a class.
-struct GPU_GLES2_EXPORT RasterDecoderContextState
+class GPU_GLES2_EXPORT SharedContextState
     : public base::trace_event::MemoryDumpProvider,
       public gpu::GLContextVirtualDelegate,
-      public base::RefCounted<RasterDecoderContextState> {
+      public base::RefCounted<SharedContextState> {
  public:
   // TODO: Refactor code to have seperate constructor for GL and Vulkan and not
   // initialize/use GL related info for vulkan and vice-versa.
-  RasterDecoderContextState(
+  SharedContextState(
       scoped_refptr<gl::GLShareGroup> share_group,
       scoped_refptr<gl::GLSurface> surface,
       scoped_refptr<gl::GLContext> context,
@@ -76,32 +73,37 @@
   gl::GLContext* context() { return context_.get(); }
   gl::GLContext* real_context() { return real_context_.get(); }
   gl::GLSurface* surface() { return surface_.get(); }
+  viz::VulkanContextProvider* vk_context_provider() {
+    return vk_context_provider_;
+  }
+  GrContext* gr_context() { return gr_context_; }
   gles2::FeatureInfo* feature_info() { return feature_info_.get(); }
   gles2::ContextState* context_state() const { return context_state_.get(); }
   bool context_lost() const { return context_lost_; }
-
-  sk_sp<GrContext> owned_gr_context;
-  std::unique_ptr<ServiceTransferCache> transfer_cache;
-  const bool use_virtualized_gl_contexts = false;
-  base::OnceClosure context_lost_callback;
-  viz::VulkanContextProvider* vk_context_provider = nullptr;
-  GrContext* gr_context = nullptr;
-  const bool use_vulkan_gr_context = false;
-  size_t glyph_cache_max_texture_bytes = 0u;
-  std::vector<uint8_t> scratch_deserialization_buffer_;
-
-  // |need_context_state_reset| is set whenever Skia may have altered the
-  // driver's GL state.
-  bool need_context_state_reset = false;
+  bool need_context_state_reset() const { return need_context_state_reset_; }
+  void set_need_context_state_reset(bool reset) {
+    need_context_state_reset_ = reset;
+  }
+  ServiceTransferCache* transfer_cache() { return transfer_cache_.get(); }
+  std::vector<uint8_t>* scratch_deserialization_buffer() {
+    return &scratch_deserialization_buffer_;
+  }
+  bool use_vulkan_gr_context() const { return use_vulkan_gr_context_; }
+  size_t glyph_cache_max_texture_bytes() const {
+    return glyph_cache_max_texture_bytes_;
+  }
+  bool use_virtualized_gl_contexts() const {
+    return use_virtualized_gl_contexts_;
+  }
 
   // base::trace_event::MemoryDumpProvider implementation.
   bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
                     base::trace_event::ProcessMemoryDump* pmd) override;
 
  private:
-  friend class base::RefCounted<RasterDecoderContextState>;
+  friend class base::RefCounted<SharedContextState>;
 
-  ~RasterDecoderContextState() override;
+  ~SharedContextState() override;
 
   // gpu::GLContextVirtualDelegate implementation.
   bool initialized() const override;
@@ -123,6 +125,12 @@
   void RestoreAllExternalTextureBindingsIfNeeded() override;
   QueryManager* GetQueryManager() override;
 
+  bool use_virtualized_gl_contexts_ = false;
+  base::OnceClosure context_lost_callback_;
+  viz::VulkanContextProvider* vk_context_provider_ = nullptr;
+  GrContext* gr_context_ = nullptr;
+  const bool use_vulkan_gr_context_;
+
   scoped_refptr<gl::GLShareGroup> share_group_;
   scoped_refptr<gl::GLContext> context_;
   scoped_refptr<gl::GLContext> real_context_;
@@ -132,14 +140,22 @@
   // raster decoders and display compositor share this context_state_.
   std::unique_ptr<gles2::ContextState> context_state_;
 
+  sk_sp<GrContext> owned_gr_context_;
+  std::unique_ptr<ServiceTransferCache> transfer_cache_;
+  size_t glyph_cache_max_texture_bytes_ = 0u;
+  std::vector<uint8_t> scratch_deserialization_buffer_;
+
+  // |need_context_state_reset| is set whenever Skia may have altered the
+  // driver's GL state.
+  bool need_context_state_reset_ = false;
+
   bool context_lost_ = false;
 
-  base::WeakPtrFactory<RasterDecoderContextState> weak_ptr_factory_;
+  base::WeakPtrFactory<SharedContextState> weak_ptr_factory_;
 
-  DISALLOW_COPY_AND_ASSIGN(RasterDecoderContextState);
+  DISALLOW_COPY_AND_ASSIGN(SharedContextState);
 };
 
-}  // namespace raster
 }  // namespace gpu
 
 #endif  // GPU_COMMAND_BUFFER_SERVICE_RASTER_DECODER_CONTEXT_STATE_H_
diff --git a/gpu/command_buffer/service/raster_decoder_unittest.cc b/gpu/command_buffer/service/raster_decoder_unittest.cc
index e01251e6..0a1ad35e 100644
--- a/gpu/command_buffer/service/raster_decoder_unittest.cc
+++ b/gpu/command_buffer/service/raster_decoder_unittest.cc
@@ -148,7 +148,7 @@
 }
 
 TEST_P(RasterDecoderTest, CopyTexSubImage2DTwiceClearsUnclearedTexture) {
-  raster_decoder_context_state_->need_context_state_reset = true;
+  shared_context_state_->set_need_context_state_reset(true);
   // Create uninitialized source texture.
   gpu::Mailbox source_texture_mailbox =
       CreateFakeTexture(kNewServiceId, viz::ResourceFormat::RGBA_8888,
@@ -239,7 +239,7 @@
     auto feature_info =
         base::MakeRefCounted<gles2::FeatureInfo>(workarounds, gpu_feature_info);
 
-    context_state_ = new raster::RasterDecoderContextState(
+    context_state_ = base::MakeRefCounted<SharedContextState>(
         std::move(share_group), std::move(surface), std::move(context),
         false /* use_virtualized_gl_contexts */, base::DoNothing());
     context_state_->InitializeGrContext(workarounds, nullptr);
@@ -296,7 +296,7 @@
  protected:
   gles2::TraceOutputter outputter_;
   FakeCommandBufferServiceBase command_buffer_service_;
-  scoped_refptr<RasterDecoderContextState> context_state_;
+  scoped_refptr<SharedContextState> context_state_;
 
   GpuPreferences gpu_preferences_;
   gles2::MailboxManagerImpl mailbox_manager_;
@@ -311,26 +311,26 @@
 TEST_F(RasterDecoderOOPTest, StateRestoreAcrossDecoders) {
   // First decoder receives a skia command requiring context state reset.
   auto decoder1 = CreateDecoder();
-  EXPECT_FALSE(context_state_->need_context_state_reset);
+  EXPECT_FALSE(context_state_->need_context_state_reset());
   decoder1->SetUpForRasterCHROMIUMForTest();
   cmds::EndRasterCHROMIUM end_raster_cmd;
   end_raster_cmd.Init();
   EXPECT_FALSE(error::IsError(ExecuteCmd(decoder1.get(), end_raster_cmd)));
-  EXPECT_TRUE(context_state_->need_context_state_reset);
+  EXPECT_TRUE(context_state_->need_context_state_reset());
 
   // Another decoder receives a command which does not require consistent state,
   // it should be processed without state restoration.
   auto decoder2 = CreateDecoder();
   decoder2->SetUpForRasterCHROMIUMForTest();
   EXPECT_FALSE(error::IsError(ExecuteCmd(decoder2.get(), end_raster_cmd)));
-  EXPECT_TRUE(context_state_->need_context_state_reset);
+  EXPECT_TRUE(context_state_->need_context_state_reset());
 
   decoder1->Destroy(true);
   context_state_->MakeCurrent(nullptr);
   decoder2->Destroy(true);
 
   // Make sure the context is preserved across decoders.
-  EXPECT_FALSE(context_state_->gr_context->abandoned());
+  EXPECT_FALSE(context_state_->gr_context()->abandoned());
 }
 
 }  // namespace raster
diff --git a/gpu/command_buffer/service/raster_decoder_unittest_base.cc b/gpu/command_buffer/service/raster_decoder_unittest_base.cc
index 48cab177..2de7f28a 100644
--- a/gpu/command_buffer/service/raster_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/raster_decoder_unittest_base.cc
@@ -233,23 +233,23 @@
       init.lose_context_when_out_of_memory;
   attribs.context_type = context_type;
 
-  // Setup expectations for RasterDecoderContextState::InitializeGL().
+  // Setup expectations for SharedContextState::InitializeGL().
   EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _))
       .WillOnce(SetArgPointee<1>(8u))
       .RetiresOnSaturation();
   SetupInitCapabilitiesExpectations(group_->feature_info()->IsES3Capable());
   SetupInitStateExpectations(group_->feature_info()->IsES3Capable());
 
-  raster_decoder_context_state_ = new raster::RasterDecoderContextState(
+  shared_context_state_ = base::MakeRefCounted<SharedContextState>(
       new gl::GLShareGroup(), surface_, context_,
       feature_info->workarounds().use_virtualized_gl_contexts,
       base::DoNothing());
 
-  raster_decoder_context_state_->InitializeGL(GpuPreferences(), feature_info);
+  shared_context_state_->InitializeGL(GpuPreferences(), feature_info);
 
   decoder_.reset(RasterDecoder::Create(this, command_buffer_service_.get(),
                                        &outputter_, group_.get(),
-                                       raster_decoder_context_state_));
+                                       shared_context_state_));
   decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_);
   decoder_->DisableFlushWorkaroundForTest();
   decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
@@ -257,10 +257,9 @@
   copy_texture_manager_ = new gles2::MockCopyTextureResourceManager();
   decoder_->SetCopyTextureResourceManagerForTest(copy_texture_manager_);
 
-  ASSERT_EQ(
-      decoder_->Initialize(surface_, raster_decoder_context_state_->context(),
-                           true, gles2::DisallowedFeatures(), attribs),
-      gpu::ContextResult::kSuccess);
+  ASSERT_EQ(decoder_->Initialize(surface_, shared_context_state_->context(),
+                                 true, gles2::DisallowedFeatures(), attribs),
+            gpu::ContextResult::kSuccess);
 
   EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(true));
   if (context_->WasAllocatedUsingRobustnessExtension()) {
diff --git a/gpu/command_buffer/service/raster_decoder_unittest_base.h b/gpu/command_buffer/service/raster_decoder_unittest_base.h
index bfe2a5f..6ac4cf08 100644
--- a/gpu/command_buffer/service/raster_decoder_unittest_base.h
+++ b/gpu/command_buffer/service/raster_decoder_unittest_base.h
@@ -259,8 +259,7 @@
   uint32_t immediate_buffer_[64];
 
   const bool ignore_cached_state_for_test_;
-  scoped_refptr<raster::RasterDecoderContextState>
-      raster_decoder_context_state_;
+  scoped_refptr<SharedContextState> shared_context_state_;
 
  private:
   GpuPreferences gpu_preferences_;
diff --git a/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer.cc b/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer.cc
index 469e95e..ab41c03 100644
--- a/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer.cc
+++ b/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer.cc
@@ -52,7 +52,7 @@
                         uint32_t usage,
                         base::android::ScopedHardwareBufferHandle handle,
                         size_t estimated_size,
-                        raster::RasterDecoderContextState* context_state);
+                        SharedContextState* context_state);
 
   ~SharedImageBackingAHB() override;
 
@@ -61,7 +61,7 @@
   void Update() override;
   bool ProduceLegacyMailbox(MailboxManager* mailbox_manager) override;
   void Destroy() override;
-  raster::RasterDecoderContextState* GetContextState() const;
+  SharedContextState* GetContextState() const;
   base::ScopedFD TakeGLWriteSyncFd();
   base::ScopedFD TakeVkReadSyncFd();
   base::android::ScopedHardwareBufferHandle GetAhbHandle();
@@ -92,7 +92,7 @@
   // will not know if SetCleared() arrives during begin write happening on GL
   // texture representation.
   bool is_cleared_ = false;
-  raster::RasterDecoderContextState* context_state_ = nullptr;
+  SharedContextState* context_state_ = nullptr;
   base::ScopedFD gl_write_sync_fd_;
   base::ScopedFD vk_read_sync_fd_;
 
@@ -271,17 +271,18 @@
     SharedImageBackingAHB* ahb_backing =
         static_cast<SharedImageBackingAHB*>(backing);
     DCHECK(ahb_backing);
-    raster::RasterDecoderContextState* context_state =
-        ahb_backing->GetContextState();
+    SharedContextState* context_state = ahb_backing->GetContextState();
     DCHECK(context_state);
-    DCHECK(context_state->vk_context_provider);
+    DCHECK(context_state->vk_context_provider());
 
-    vk_device_ =
-        context_state->vk_context_provider->GetDeviceQueue()->GetVulkanDevice();
-    vk_phy_device_ = context_state->vk_context_provider->GetDeviceQueue()
+    vk_device_ = context_state->vk_context_provider()
+                     ->GetDeviceQueue()
+                     ->GetVulkanDevice();
+    vk_phy_device_ = context_state->vk_context_provider()
+                         ->GetDeviceQueue()
                          ->GetVulkanPhysicalDevice();
     vk_implementation_ =
-        context_state->vk_context_provider->GetVulkanImplementation();
+        context_state->vk_context_provider()->GetVulkanImplementation();
   }
 
   ~SharedImageRepresentationSkiaVkAHB() override { DCHECK(!read_surface_); }
@@ -433,7 +434,7 @@
     uint32_t usage,
     base::android::ScopedHardwareBufferHandle handle,
     size_t estimated_size,
-    raster::RasterDecoderContextState* context_state)
+    SharedContextState* context_state)
     : SharedImageBacking(mailbox,
                          format,
                          size,
@@ -485,8 +486,7 @@
   hardware_buffer_handle_.reset();
 }
 
-raster::RasterDecoderContextState* SharedImageBackingAHB::GetContextState()
-    const {
+SharedContextState* SharedImageBackingAHB::GetContextState() const {
   return context_state_;
 }
 
@@ -531,7 +531,7 @@
 
   // Check whether we are in Vulkan mode OR GL mode and accordingly create
   // Skia representation.
-  if (context_state_->use_vulkan_gr_context) {
+  if (context_state_->use_vulkan_gr_context()) {
     return std::make_unique<SharedImageRepresentationSkiaVkAHB>(manager, this);
   }
 
@@ -621,7 +621,7 @@
 SharedImageBackingFactoryAHB::SharedImageBackingFactoryAHB(
     const GpuDriverBugWorkarounds& workarounds,
     const GpuFeatureInfo& gpu_feature_info,
-    raster::RasterDecoderContextState* context_state)
+    SharedContextState* context_state)
     : context_state_(context_state) {
   scoped_refptr<gles2::FeatureInfo> feature_info =
       new gles2::FeatureInfo(workarounds, gpu_feature_info);
diff --git a/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer.h b/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer.h
index fba257a..e733b34 100644
--- a/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer.h
+++ b/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer.h
@@ -17,24 +17,20 @@
 }  // namespace gfx
 
 namespace gpu {
+class SharedContextState;
 class SharedImageBacking;
 class GpuDriverBugWorkarounds;
 struct GpuFeatureInfo;
 struct Mailbox;
 
-namespace raster {
-struct RasterDecoderContextState;
-}  // namespace raster
-
 // Implementation of SharedImageBackingFactory that produces AHardwareBuffer
 // backed SharedImages. This is meant to be used on Android only.
 class GPU_GLES2_EXPORT SharedImageBackingFactoryAHB
     : public SharedImageBackingFactory {
  public:
-  SharedImageBackingFactoryAHB(
-      const GpuDriverBugWorkarounds& workarounds,
-      const GpuFeatureInfo& gpu_feature_info,
-      raster::RasterDecoderContextState* context_state);
+  SharedImageBackingFactoryAHB(const GpuDriverBugWorkarounds& workarounds,
+                               const GpuFeatureInfo& gpu_feature_info,
+                               SharedContextState* context_state);
   ~SharedImageBackingFactoryAHB() override;
 
   // SharedImageBackingFactory implementation.
@@ -83,7 +79,7 @@
 
   // Used to limit the max size of AHardwareBuffer.
   int32_t max_gl_texture_size_ = 0;
-  raster::RasterDecoderContextState* context_state_ = nullptr;
+  SharedContextState* context_state_ = nullptr;
 
   DISALLOW_COPY_AND_ASSIGN(SharedImageBackingFactoryAHB);
 };
diff --git a/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer_unittest.cc b/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer_unittest.cc
index fc6ec07..cc05f7f2 100644
--- a/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer_unittest.cc
+++ b/gpu/command_buffer/service/shared_image_backing_factory_ahardwarebuffer_unittest.cc
@@ -53,7 +53,7 @@
     workarounds.max_texture_size = INT_MAX - 1;
 
     scoped_refptr<gl::GLShareGroup> share_group = new gl::GLShareGroup();
-    context_state_ = new raster::RasterDecoderContextState(
+    context_state_ = base::MakeRefCounted<SharedContextState>(
         std::move(share_group), surface_, context_,
         false /* use_virtualized_gl_contexts */, base::DoNothing());
     context_state_->InitializeGrContext(workarounds, nullptr);
@@ -70,12 +70,12 @@
             &shared_image_manager_, nullptr);
   }
 
-  GrContext* gr_context() { return context_state_->gr_context; }
+  GrContext* gr_context() { return context_state_->gr_context(); }
 
  protected:
   scoped_refptr<gl::GLSurface> surface_;
   scoped_refptr<gl::GLContext> context_;
-  scoped_refptr<raster::RasterDecoderContextState> context_state_;
+  scoped_refptr<SharedContextState> context_state_;
   std::unique_ptr<SharedImageBackingFactoryAHB> backing_factory_;
   gles2::MailboxManagerImpl mailbox_manager_;
   SharedImageManager shared_image_manager_;
diff --git a/gpu/command_buffer/service/shared_image_backing_factory_gl_texture_unittest.cc b/gpu/command_buffer/service/shared_image_backing_factory_gl_texture_unittest.cc
index c0a3d3ff..d37dd7e 100644
--- a/gpu/command_buffer/service/shared_image_backing_factory_gl_texture_unittest.cc
+++ b/gpu/command_buffer/service/shared_image_backing_factory_gl_texture_unittest.cc
@@ -59,7 +59,7 @@
     scoped_refptr<gl::GLShareGroup> share_group = new gl::GLShareGroup();
     auto feature_info =
         base::MakeRefCounted<gles2::FeatureInfo>(workarounds, GpuFeatureInfo());
-    context_state_ = base::MakeRefCounted<raster::RasterDecoderContextState>(
+    context_state_ = base::MakeRefCounted<SharedContextState>(
         std::move(share_group), surface_, context_,
         false /* use_virtualized_gl_contexts */, base::DoNothing());
     context_state_->InitializeGrContext(workarounds, nullptr);
@@ -81,12 +81,12 @@
 
   bool supports_etc1() { return supports_etc1_; }
 
-  GrContext* gr_context() { return context_state_->gr_context; }
+  GrContext* gr_context() { return context_state_->gr_context(); }
 
  protected:
   scoped_refptr<gl::GLSurface> surface_;
   scoped_refptr<gl::GLContext> context_;
-  scoped_refptr<raster::RasterDecoderContextState> context_state_;
+  scoped_refptr<SharedContextState> context_state_;
   std::unique_ptr<SharedImageBackingFactoryGLTexture> backing_factory_;
   gles2::MailboxManagerImpl mailbox_manager_;
   SharedImageManager shared_image_manager_;
diff --git a/gpu/command_buffer/service/shared_image_factory.cc b/gpu/command_buffer/service/shared_image_factory.cc
index 39dde67..e23e823 100644
--- a/gpu/command_buffer/service/shared_image_factory.cc
+++ b/gpu/command_buffer/service/shared_image_factory.cc
@@ -48,7 +48,7 @@
     const GpuPreferences& gpu_preferences,
     const GpuDriverBugWorkarounds& workarounds,
     const GpuFeatureInfo& gpu_feature_info,
-    raster::RasterDecoderContextState* context_state,
+    SharedContextState* context_state,
     MailboxManager* mailbox_manager,
     SharedImageManager* shared_image_manager,
     ImageFactory* image_factory,
@@ -56,7 +56,7 @@
     : mailbox_manager_(mailbox_manager),
       shared_image_manager_(shared_image_manager),
       memory_tracker_(std::make_unique<MemoryTypeTracker>(memory_tracker)),
-      using_vulkan_(context_state && context_state->use_vulkan_gr_context),
+      using_vulkan_(context_state && context_state->use_vulkan_gr_context()),
       backing_factory_(
           std::make_unique<SharedImageBackingFactoryGLTexture>(gpu_preferences,
                                                                workarounds,
diff --git a/gpu/command_buffer/service/shared_image_factory.h b/gpu/command_buffer/service/shared_image_factory.h
index eb14870..1d50926 100644
--- a/gpu/command_buffer/service/shared_image_factory.h
+++ b/gpu/command_buffer/service/shared_image_factory.h
@@ -20,6 +20,7 @@
 #include "ui/gl/gl_bindings.h"
 
 namespace gpu {
+class SharedContextState;
 class GpuDriverBugWorkarounds;
 class ImageFactory;
 class MailboxManager;
@@ -30,7 +31,6 @@
 
 namespace raster {
 class WrappedSkImageFactory;
-struct RasterDecoderContextState;
 }  // namespace raster
 
 // TODO(ericrk): Make this a very thin wrapper around SharedImageManager like
@@ -40,7 +40,7 @@
   SharedImageFactory(const GpuPreferences& gpu_preferences,
                      const GpuDriverBugWorkarounds& workarounds,
                      const GpuFeatureInfo& gpu_feature_info,
-                     raster::RasterDecoderContextState* context_state,
+                     SharedContextState* context_state,
                      MailboxManager* mailbox_manager,
                      SharedImageManager* manager,
                      ImageFactory* image_factory,
diff --git a/gpu/command_buffer/service/wrapped_sk_image.cc b/gpu/command_buffer/service/wrapped_sk_image.cc
index cca87d4..f60e5a4b 100644
--- a/gpu/command_buffer/service/wrapped_sk_image.cc
+++ b/gpu/command_buffer/service/wrapped_sk_image.cc
@@ -34,7 +34,7 @@
     DCHECK(context_state_->context_lost() ||
            context_state_->IsCurrent(nullptr));
     if (!context_state_->context_lost())
-      context_state_->need_context_state_reset = true;
+      context_state_->set_need_context_state_reset(true);
   }
 
   // SharedImageBacking implementation.
@@ -78,7 +78,7 @@
         image_->getBackendTexture(/*flushPendingGrContextIO=*/true);
     DCHECK(gr_texture.isValid());
     return SkSurface::MakeFromBackendTextureAsRenderTarget(
-        context_state_->gr_context, gr_texture, kTopLeft_GrSurfaceOrigin,
+        context_state_->gr_context(), gr_texture, kTopLeft_GrSurfaceOrigin,
         final_msaa_count, color_type, /*colorSpace=*/nullptr, &surface_props);
   }
 
@@ -98,7 +98,7 @@
                  const gfx::ColorSpace& color_space,
                  uint32_t usage,
                  size_t estimated_size,
-                 raster::RasterDecoderContextState* context_state)
+                 SharedContextState* context_state)
       : SharedImageBacking(mailbox,
                            format,
                            size,
@@ -114,10 +114,10 @@
       return false;
     DCHECK(context_state_->IsCurrent(nullptr));
 
-    context_state_->need_context_state_reset = true;
+    context_state_->set_need_context_state_reset(true);
 
     if (data.empty()) {
-      auto surface = SkSurface::MakeRenderTarget(context_state_->gr_context,
+      auto surface = SkSurface::MakeRenderTarget(context_state_->gr_context(),
                                                  SkBudgeted::kNo, info);
       if (!surface)
         return false;
@@ -132,7 +132,7 @@
       sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
       if (!image)
         return false;
-      image_ = image->makeTextureImage(context_state_->gr_context,
+      image_ = image->makeTextureImage(context_state_->gr_context(),
                                        image->colorSpace());
     }
 
@@ -165,7 +165,7 @@
     return true;
   }
 
-  RasterDecoderContextState* const context_state_;
+  SharedContextState* const context_state_;
 
   sk_sp<SkImage> image_;
   sk_sp<SkPromiseImageTexture> promise_texture_;
@@ -223,8 +223,7 @@
 
 }  // namespace
 
-WrappedSkImageFactory::WrappedSkImageFactory(
-    RasterDecoderContextState* context_state)
+WrappedSkImageFactory::WrappedSkImageFactory(SharedContextState* context_state)
     : context_state_(context_state) {}
 
 WrappedSkImageFactory::~WrappedSkImageFactory() = default;
diff --git a/gpu/command_buffer/service/wrapped_sk_image.h b/gpu/command_buffer/service/wrapped_sk_image.h
index a733080..ca108bc 100644
--- a/gpu/command_buffer/service/wrapped_sk_image.h
+++ b/gpu/command_buffer/service/wrapped_sk_image.h
@@ -16,14 +16,15 @@
 #include "ui/gfx/geometry/size.h"
 
 namespace gpu {
-namespace raster {
 
-struct RasterDecoderContextState;
+class SharedContextState;
+
+namespace raster {
 
 class GPU_GLES2_EXPORT WrappedSkImageFactory
     : public gpu::SharedImageBackingFactory {
  public:
-  explicit WrappedSkImageFactory(RasterDecoderContextState* context_state);
+  explicit WrappedSkImageFactory(SharedContextState* context_state);
   ~WrappedSkImageFactory() override;
 
   // SharedImageBackingFactory implementation:
@@ -51,7 +52,7 @@
       uint32_t usage) override;
 
  private:
-  RasterDecoderContextState* const context_state_;
+  SharedContextState* const context_state_;
 
   DISALLOW_COPY_AND_ASSIGN(WrappedSkImageFactory);
 };
diff --git a/gpu/command_buffer/tests/fuzzer_main.cc b/gpu/command_buffer/tests/fuzzer_main.cc
index 5822843..82482ba 100644
--- a/gpu/command_buffer/tests/fuzzer_main.cc
+++ b/gpu/command_buffer/tests/fuzzer_main.cc
@@ -368,8 +368,8 @@
 
 #if defined(GPU_FUZZER_USE_RASTER_DECODER)
     CHECK(feature_info->feature_flags().chromium_raster_transport);
-    scoped_refptr<raster::RasterDecoderContextState> context_state =
-        new raster::RasterDecoderContextState(
+    scoped_refptr<SharedContextState> context_state =
+        base::MakeRefCounted<SharedContextState>(
             share_group_, surface_, context_,
             config_.workarounds.use_virtualized_gl_contexts, base::DoNothing());
     context_state->InitializeGrContext(config_.workarounds, nullptr);
diff --git a/gpu/ipc/in_process_command_buffer.cc b/gpu/ipc/in_process_command_buffer.cc
index c236cfc..3f93d10 100644
--- a/gpu/ipc/in_process_command_buffer.cc
+++ b/gpu/ipc/in_process_command_buffer.cc
@@ -581,7 +581,7 @@
 
     if (allow_raster_decoder && params.attribs.enable_raster_interface &&
         !params.attribs.enable_gles2_interface) {
-      context_state_ = base::MakeRefCounted<raster::RasterDecoderContextState>(
+      context_state_ = base::MakeRefCounted<SharedContextState>(
           gl_share_group_, surface_, real_context, use_virtualized_gl_context_,
           base::DoNothing());
       context_state_->InitializeGL(task_executor_->gpu_preferences(),
diff --git a/gpu/ipc/in_process_command_buffer.h b/gpu/ipc/in_process_command_buffer.h
index 01fa30a5..a2ac2361 100644
--- a/gpu/ipc/in_process_command_buffer.h
+++ b/gpu/ipc/in_process_command_buffer.h
@@ -56,6 +56,7 @@
 }
 
 namespace gpu {
+class SharedContextState;
 class GpuChannelManagerDelegate;
 class GpuProcessActivityFlags;
 class GpuMemoryBufferManager;
@@ -69,7 +70,6 @@
 
 namespace raster {
 class GrShaderCache;
-struct RasterDecoderContextState;
 }
 
 // This class provides a thread-safe interface to the global GPU service (for
@@ -373,7 +373,7 @@
   base::circular_deque<SwapBufferParams> pending_presented_params_;
   base::circular_deque<SwapBufferParams> pending_swap_completed_params_;
 
-  scoped_refptr<raster::RasterDecoderContextState> context_state_;
+  scoped_refptr<SharedContextState> context_state_;
 
   base::WeakPtrFactory<InProcessCommandBuffer> client_thread_weak_ptr_factory_;
   base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_;
diff --git a/gpu/ipc/service/gpu_channel_manager.cc b/gpu/ipc/service/gpu_channel_manager.cc
index 7f3fdb6..557737ff 100644
--- a/gpu/ipc/service/gpu_channel_manager.cc
+++ b/gpu/ipc/service/gpu_channel_manager.cc
@@ -312,10 +312,10 @@
   if (program_cache_)
     program_cache_->Trim(0u);
 
-  if (raster_decoder_context_state_) {
+  if (shared_context_state_) {
     gr_cache_controller_.reset();
-    raster_decoder_context_state_->MarkContextLost();
-    raster_decoder_context_state_.reset();
+    shared_context_state_->MarkContextLost();
+    shared_context_state_.reset();
   }
 
   SkGraphics::PurgeAllCaches();
@@ -323,8 +323,8 @@
 #endif
 
 void GpuChannelManager::OnApplicationBackgrounded() {
-  if (raster_decoder_context_state_) {
-    raster_decoder_context_state_->PurgeMemory(
+  if (shared_context_state_) {
+    shared_context_state_->PurgeMemory(
         base::MemoryPressureListener::MemoryPressureLevel::
             MEMORY_PRESSURE_LEVEL_CRITICAL);
   }
@@ -339,18 +339,17 @@
     program_cache_->HandleMemoryPressure(memory_pressure_level);
   discardable_manager_.HandleMemoryPressure(memory_pressure_level);
   passthrough_discardable_manager_.HandleMemoryPressure(memory_pressure_level);
-  if (raster_decoder_context_state_)
-    raster_decoder_context_state_->PurgeMemory(memory_pressure_level);
+  if (shared_context_state_)
+    shared_context_state_->PurgeMemory(memory_pressure_level);
   if (gr_shader_cache_)
     gr_shader_cache_->PurgeMemory(memory_pressure_level);
 }
 
-scoped_refptr<raster::RasterDecoderContextState>
-GpuChannelManager::GetRasterDecoderContextState(ContextResult* result) {
-  if (raster_decoder_context_state_ &&
-      !raster_decoder_context_state_->context_lost()) {
+scoped_refptr<SharedContextState> GpuChannelManager::GetSharedContextState(
+    ContextResult* result) {
+  if (shared_context_state_ && !shared_context_state_->context_lost()) {
     *result = ContextResult::kSuccess;
-    return raster_decoder_context_state_;
+    return shared_context_state_;
   }
 
   scoped_refptr<gl::GLSurface> surface = default_offscreen_surface();
@@ -418,7 +417,7 @@
   }
 
   // TODO(penghuang): https://crbug.com/899735 Handle device lost for Vulkan.
-  raster_decoder_context_state_ = new raster::RasterDecoderContextState(
+  shared_context_state_ = base::MakeRefCounted<SharedContextState>(
       std::move(share_group), std::move(surface), std::move(context),
       use_virtualized_gl_contexts,
       base::BindOnce(&GpuChannelManager::OnContextLost, base::Unretained(this),
@@ -437,22 +436,21 @@
     if (!vulkan_context_provider_) {
       auto feature_info = base::MakeRefCounted<gles2::FeatureInfo>(
           gpu_driver_bug_workarounds(), gpu_feature_info());
-      if (!raster_decoder_context_state_->InitializeGL(gpu_preferences_,
-                                                       feature_info.get())) {
-        raster_decoder_context_state_ = nullptr;
+      if (!shared_context_state_->InitializeGL(gpu_preferences_,
+                                               feature_info.get())) {
+        shared_context_state_ = nullptr;
         return nullptr;
       }
     }
-    raster_decoder_context_state_->InitializeGrContext(
-        gpu_driver_bug_workarounds_, gr_shader_cache(), &activity_flags_,
-        watchdog_);
+    shared_context_state_->InitializeGrContext(gpu_driver_bug_workarounds_,
+                                               gr_shader_cache(),
+                                               &activity_flags_, watchdog_);
   }
 
-  gr_cache_controller_.emplace(raster_decoder_context_state_.get(),
-                               task_runner_);
+  gr_cache_controller_.emplace(shared_context_state_.get(), task_runner_);
 
   *result = ContextResult::kSuccess;
-  return raster_decoder_context_state_;
+  return shared_context_state_;
 }
 
 void GpuChannelManager::OnContextLost(bool synthetic_loss) {
@@ -463,8 +461,8 @@
   // Lose all other contexts.
   if (!synthetic_loss &&
       (gl::GLContext::LosesAllContextsOnContextLost() ||
-       (raster_decoder_context_state_ &&
-        raster_decoder_context_state_->use_virtualized_gl_contexts)))
+       (shared_context_state_ &&
+        shared_context_state_->use_virtualized_gl_contexts())))
     LoseAllContexts();
 }
 
diff --git a/gpu/ipc/service/gpu_channel_manager.h b/gpu/ipc/service/gpu_channel_manager.h
index 945be948..bd829ce 100644
--- a/gpu/ipc/service/gpu_channel_manager.h
+++ b/gpu/ipc/service/gpu_channel_manager.h
@@ -158,7 +158,7 @@
   void GetVideoMemoryUsageStats(
       VideoMemoryUsageStats* video_memory_usage_stats) const;
 
-  scoped_refptr<raster::RasterDecoderContextState> GetRasterDecoderContextState(
+  scoped_refptr<SharedContextState> GetSharedContextState(
       ContextResult* result);
   void ScheduleGrContextCleanup();
   raster::GrShaderCache* gr_shader_cache() {
@@ -234,20 +234,19 @@
 
   base::MemoryPressureListener memory_pressure_listener_;
 
-  // The RasterDecoderContextState is shared across all RasterDecoders. Note
+  // The SharedContextState is shared across all RasterDecoders. Note
   // that this class needs to be ref-counted to conveniently manage the lifetime
   // of the shared context in the case of a context loss. While the
   // GpuChannelManager strictly outlives the RasterDecoders, in the event of a
   // context loss the clients need to re-create the GpuChannel and command
   // buffers once notified. In this interim state we can have multiple instances
-  // of the RasterDecoderContextState, for the lost and recovered clients. In
+  // of the SharedContextState, for the lost and recovered clients. In
   // order to avoid having the GpuChannelManager keep the lost context state
   // alive until all clients have recovered, we use a ref-counted object and
   // allow the decoders to manage its lifetime.
   base::Optional<raster::GrShaderCache> gr_shader_cache_;
   base::Optional<raster::GrCacheController> gr_cache_controller_;
-  scoped_refptr<raster::RasterDecoderContextState>
-      raster_decoder_context_state_;
+  scoped_refptr<SharedContextState> shared_context_state_;
 
   // With --enable-vulkan, the vulkan_context_provider_ will be set from
   // viz::GpuServiceImpl. The raster decoders will use it for rasterization.
diff --git a/gpu/ipc/service/gpu_channel_manager_unittest.cc b/gpu/ipc/service/gpu_channel_manager_unittest.cc
index 104d6ea..25dbb562 100644
--- a/gpu/ipc/service/gpu_channel_manager_unittest.cc
+++ b/gpu/ipc/service/gpu_channel_manager_unittest.cc
@@ -47,7 +47,7 @@
     EXPECT_EQ(result, gpu::ContextResult::kSuccess);
 
     auto raster_decoder_state =
-        channel_manager()->GetRasterDecoderContextState(&result);
+        channel_manager()->GetSharedContextState(&result);
     EXPECT_EQ(result, ContextResult::kSuccess);
     ASSERT_TRUE(raster_decoder_state);
 
@@ -64,7 +64,7 @@
     }
 
     // We should always clear the shared raster state on background cleanup.
-    ASSERT_NE(channel_manager()->GetRasterDecoderContextState(&result).get(),
+    ASSERT_NE(channel_manager()->GetSharedContextState(&result).get(),
               raster_decoder_state.get());
   }
 #endif
diff --git a/gpu/ipc/service/raster_command_buffer_stub.cc b/gpu/ipc/service/raster_command_buffer_stub.cc
index 20f57c4..f673526d 100644
--- a/gpu/ipc/service/raster_command_buffer_stub.cc
+++ b/gpu/ipc/service/raster_command_buffer_stub.cc
@@ -94,23 +94,22 @@
   }
 
   ContextResult result;
-  auto raster_decoder_context_state =
-      manager->GetRasterDecoderContextState(&result);
-  if (!raster_decoder_context_state) {
+  auto shared_context_state = manager->GetSharedContextState(&result);
+  if (!shared_context_state) {
     LOG(ERROR) << "ContextResult::kFatalFailure: "
                   "Failed to create raster decoder state.";
     DCHECK_NE(result, gpu::ContextResult::kSuccess);
     return result;
   }
 
-  if (!raster_decoder_context_state->IsGLInitialized()) {
-    if (!raster_decoder_context_state->MakeCurrent(nullptr) ||
-        !raster_decoder_context_state->InitializeGL(
+  if (!shared_context_state->IsGLInitialized()) {
+    if (!shared_context_state->MakeCurrent(nullptr) ||
+        !shared_context_state->InitializeGL(
             manager->gpu_preferences(),
             base::MakeRefCounted<gles2::FeatureInfo>(
                 manager->gpu_driver_bug_workarounds(),
                 manager->gpu_feature_info()))) {
-      LOG(ERROR) << "Failed to Initialize GL for RasterDecoderContextState";
+      LOG(ERROR) << "Failed to Initialize GL for SharedContextState";
       return ContextResult::kFatalFailure;
     }
   }
@@ -122,7 +121,7 @@
       manager->mailbox_manager(), CreateMemoryTracker(init_params),
       manager->shader_translator_cache(),
       manager->framebuffer_completeness_cache(),
-      raster_decoder_context_state->feature_info(),
+      shared_context_state->feature_info(),
       init_params.attribs.bind_generates_resource, channel_->image_manager(),
       gmb_factory ? gmb_factory->AsImageFactory() : nullptr,
       /*progress_reporter=*/manager->watchdog(), manager->gpu_feature_info(),
@@ -130,16 +129,16 @@
       manager->passthrough_discardable_manager(),
       manager->shared_image_manager());
 
-  surface_ = raster_decoder_context_state->surface();
-  share_group_ = raster_decoder_context_state->share_group();
+  surface_ = shared_context_state->surface();
+  share_group_ = shared_context_state->share_group();
   use_virtualized_gl_context_ =
-      raster_decoder_context_state->use_virtualized_gl_contexts;
+      shared_context_state->use_virtualized_gl_contexts();
 
   command_buffer_ = std::make_unique<CommandBufferService>(
       this, context_group_->transfer_buffer_manager());
   std::unique_ptr<raster::RasterDecoder> decoder(raster::RasterDecoder::Create(
       this, command_buffer_.get(), manager->outputter(), context_group_.get(),
-      raster_decoder_context_state));
+      shared_context_state));
 
   sync_point_client_state_ =
       channel_->sync_point_manager()->CreateSyncPointClientState(
@@ -149,9 +148,8 @@
   crash_keys::gpu_gl_context_is_virtual.Set(use_virtualized_gl_context_ ? "1"
                                                                         : "0");
 
-  scoped_refptr<gl::GLContext> context =
-      raster_decoder_context_state->context();
-  if (!raster_decoder_context_state->MakeCurrent(nullptr)) {
+  scoped_refptr<gl::GLContext> context = shared_context_state->context();
+  if (!shared_context_state->MakeCurrent(nullptr)) {
     LOG(ERROR) << "ContextResult::kTransientFailure: "
                   "Failed to make context current.";
     return gpu::ContextResult::kTransientFailure;
diff --git a/gpu/ipc/service/shared_image_stub.cc b/gpu/ipc/service/shared_image_stub.cc
index c2645ce..d842fe7 100644
--- a/gpu/ipc/service/shared_image_stub.cc
+++ b/gpu/ipc/service/shared_image_stub.cc
@@ -234,7 +234,7 @@
     auto* channel_manager = channel_->gpu_channel_manager();
     DCHECK(!context_state_);
     ContextResult result;
-    context_state_ = channel_manager->GetRasterDecoderContextState(&result);
+    context_state_ = channel_manager->GetSharedContextState(&result);
     if (result != ContextResult::kSuccess) {
       LOG(ERROR) << "SharedImageStub: unable to create context";
       return false;
diff --git a/gpu/ipc/service/shared_image_stub.h b/gpu/ipc/service/shared_image_stub.h
index fabddec..e1fabff4 100644
--- a/gpu/ipc/service/shared_image_stub.h
+++ b/gpu/ipc/service/shared_image_stub.h
@@ -13,14 +13,11 @@
 #include "ipc/ipc_listener.h"
 
 namespace gpu {
+class SharedContextState;
 struct Mailbox;
 class GpuChannel;
 class SharedImageFactory;
 
-namespace raster {
-struct RasterDecoderContextState;
-}
-
 class SharedImageStub : public IPC::Listener,
                         public MemoryTracker,
                         public base::trace_event::MemoryDumpProvider {
@@ -60,7 +57,7 @@
   GpuChannel* channel_;
   SequenceId sequence_;
   scoped_refptr<gpu::SyncPointClientState> sync_point_client_state_;
-  scoped_refptr<raster::RasterDecoderContextState> context_state_;
+  scoped_refptr<SharedContextState> context_state_;
   std::unique_ptr<SharedImageFactory> factory_;
   uint64_t size_ = 0;
   // Holds shared memory used in initial data uploads.