Chromium Code Reviews| Index: components/mus/common/gpu_service.h |
| diff --git a/components/mus/common/gpu_service.h b/components/mus/common/gpu_service.h |
| index 91be13f3d90cce73086c0f801cda3c15834b56be..277b51f04a2afa1a68f58caa025c4e898ba2b9b4 100644 |
| --- a/components/mus/common/gpu_service.h |
| +++ b/components/mus/common/gpu_service.h |
| @@ -12,7 +12,9 @@ |
| #include "base/synchronization/lock.h" |
| #include "base/synchronization/waitable_event.h" |
| #include "base/threading/thread.h" |
| +#include "components/mus/common/mojo_gpu_memory_buffer_manager.h" |
| #include "components/mus/common/mus_common_export.h" |
| +#include "components/mus/public/interfaces/gpu_service.mojom.h" |
| #include "gpu/ipc/client/gpu_channel_host.h" |
| namespace shell { |
| @@ -21,14 +23,20 @@ class Connector; |
| namespace mus { |
| -class MojoGpuMemoryBufferManager; |
| - |
| class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory { |
| public: |
| - scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannel( |
| - shell::Connector* connector); |
| + void EstablishGpuChannel(const base::Closure& callback); |
| + scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync(); |
| + scoped_refptr<gpu::GpuChannelHost> GetGpuChannel(); |
| + gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const { |
| + return gpu_memory_buffer_manager_.get(); |
| + } |
| static bool UseChromeGpuCommandBuffer(); |
| + |
| + // The GpuService has to be initialized in the main thread before establishing |
| + // the gpu channel. |
| + static void Initialize(shell::Connector* connector); |
| static GpuService* GetInstance(); |
| private: |
| @@ -37,6 +45,16 @@ class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory { |
| GpuService(); |
| ~GpuService() override; |
| + void Init(shell::Connector* connector); |
| + |
| + scoped_refptr<gpu::GpuChannelHost> GetGpuChannelLocked(); |
| + void EstablishGpuChannelOnMainThread(); |
| + void EstablishGpuChannelOnMainThreadDone( |
| + bool locked, |
| + int client_id, |
| + mojom::ChannelHandlePtr channel_handle, |
| + mojom::GpuInfoPtr gpu_info); |
| + |
| // gpu::GpuChannelHostFactory overrides: |
| bool IsMainThread() override; |
| scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; |
| @@ -44,13 +62,18 @@ class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory { |
| size_t size) override; |
| base::MessageLoop* main_message_loop_; |
| + shell::Connector* connector_; |
| base::WaitableEvent shutdown_event_; |
| base::Thread io_thread_; |
| std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| - // Lock for |gpu_channel_|. |
| + // Lock for |gpu_channel_|, |establish_callbacks_| & |is_establishing_|. |
| base::Lock lock_; |
| + bool is_establishing_; |
| scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
| + std::vector<base::Closure> establish_callbacks_; |
| + base::ConditionVariable establishing_condition_; |
| + base::Closure quite_run_loop_closure_; |
|
piman
2016/06/22 17:58:10
nit: quite->quit
Peng
2016/06/22 19:28:30
Done.
|
| DISALLOW_COPY_AND_ASSIGN(GpuService); |
| }; |