| Index: services/ui/gpu/gpu_main.h | 
| diff --git a/services/ui/gpu/gpu_main.h b/services/ui/gpu/gpu_main.h | 
| index b1dde2b2bc92369c8902e4e578b6c5d4ffd759b0..6eb2eb842a020b25cbdc53c1f9b89eacf7d1b356 100644 | 
| --- a/services/ui/gpu/gpu_main.h | 
| +++ b/services/ui/gpu/gpu_main.h | 
| @@ -6,24 +6,34 @@ | 
| #define SERVICES_UI_GPU_GPU_MAIN_H_ | 
|  | 
| #include "base/threading/thread.h" | 
| +#include "gpu/ipc/in_process_command_buffer.h" | 
| #include "gpu/ipc/service/gpu_init.h" | 
| +#include "services/ui/gpu/interfaces/gpu_main.mojom.h" | 
| #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" | 
| +#include "services/ui/surfaces/display_compositor.h" | 
|  | 
| namespace gpu { | 
| class GpuMemoryBufferFactory; | 
| +class ImageFactory; | 
| } | 
|  | 
| namespace ui { | 
|  | 
| class GpuServiceInternal; | 
|  | 
| -class GpuMain : public gpu::GpuSandboxHelper { | 
| +class GpuMain : public gpu::GpuSandboxHelper, public mojom::GpuMain { | 
| public: | 
| -  GpuMain(); | 
| +  explicit GpuMain(mojom::GpuMainRequest request); | 
| ~GpuMain() override; | 
|  | 
| +  // mojom::GpuMain implementation: | 
| +  void CreateGpuService(mojom::GpuServiceInternalRequest request, | 
| +                        const CreateGpuServiceCallback& callback) override; | 
| +  void CreateDisplayCompositor( | 
| +      cc::mojom::DisplayCompositorRequest request, | 
| +      cc::mojom::DisplayCompositorClientPtr client) override; | 
| + | 
| void OnStart(); | 
| -  void Create(mojom::GpuServiceInternalRequest request); | 
|  | 
| GpuServiceInternal* gpu_service() { return gpu_service_internal_.get(); } | 
|  | 
| @@ -32,9 +42,21 @@ class GpuMain : public gpu::GpuSandboxHelper { | 
| scoped_refptr<base::SingleThreadTaskRunner> io_runner, | 
| scoped_refptr<base::SingleThreadTaskRunner> compositor_runner); | 
|  | 
| +  void CreateDisplayCompositorInternal( | 
| +      cc::mojom::DisplayCompositorRequest request, | 
| +      cc::mojom::DisplayCompositorClientPtrInfo client_info); | 
| +  void CreateDisplayCompositorOnCompositorThread( | 
| +      gpu::ImageFactory* image_factory, | 
| +      mojom::GpuServiceInternalPtrInfo gpu_service_info, | 
| +      cc::mojom::DisplayCompositorRequest request, | 
| +      cc::mojom::DisplayCompositorClientPtrInfo client_info); | 
| +  void CreateGpuServiceOnGpuThread( | 
| +      mojom::GpuServiceInternalRequest request, | 
| +      scoped_refptr<base::SingleThreadTaskRunner> origin_runner, | 
| +      const CreateGpuServiceCallback& callback); | 
| + | 
| void TearDownOnCompositorThread(); | 
| void TearDownOnGpuThread(); | 
| -  void CreateOnGpuThread(mojom::GpuServiceInternalRequest request); | 
|  | 
| // gpu::GpuSandboxHelper: | 
| void PreSandboxStartup() override; | 
| @@ -43,6 +65,22 @@ class GpuMain : public gpu::GpuSandboxHelper { | 
|  | 
| std::unique_ptr<gpu::GpuInit> gpu_init_; | 
| std::unique_ptr<GpuServiceInternal> gpu_service_internal_; | 
| + | 
| +  // The message-pipe used by the DisplayCompositor to request gpu memory | 
| +  // buffers. | 
| +  mojom::GpuServiceInternalPtr gpu_internal_; | 
| + | 
| +  // The InCommandCommandBuffer::Service used by the display compositor. | 
| +  scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_command_service_; | 
| + | 
| +  // If the gpu service is not yet ready then we stash pending MessagePipes in | 
| +  // these member variables. | 
| +  cc::mojom::DisplayCompositorRequest pending_display_compositor_request_; | 
| +  cc::mojom::DisplayCompositorClientPtrInfo | 
| +      pending_display_compositor_client_info_; | 
| + | 
| +  std::unique_ptr<DisplayCompositor> display_compositor_; | 
| + | 
| std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_; | 
|  | 
| // The main thread for GpuService. | 
| @@ -51,10 +89,14 @@ class GpuMain : public gpu::GpuSandboxHelper { | 
| // The thread that handles IO events for GpuService. | 
| base::Thread io_thread_; | 
|  | 
| -  // The thread used for the display compositor. | 
| +  // The display compositor gets its own thread in mus-gpu. The gpu service, | 
| +  // where GL commands are processed resides on its own thread. Various | 
| +  // components of the display compositor such as Display, ResourceProvider, | 
| +  // and GLRenderer block on sync tokens from other command buffers. Thus, | 
| +  // the gpu service must live on a separate thread. | 
| base::Thread compositor_thread_; | 
|  | 
| -  base::WeakPtrFactory<GpuMain> weak_factory_; | 
| +  mojo::Binding<mojom::GpuMain> binding_; | 
|  | 
| DISALLOW_COPY_AND_ASSIGN(GpuMain); | 
| }; | 
|  |