OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_H_ | 5 #ifndef COMPONENTS_MUS_COMMON_GPU_SERVICE_H_ |
6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_H_ | 6 #define COMPONENTS_MUS_COMMON_GPU_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/synchronization/lock.h" | |
12 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "components/mus/common/mus_common_export.h" | |
14 #include "gpu/ipc/client/gpu_channel_host.h" | 16 #include "gpu/ipc/client/gpu_channel_host.h" |
15 | 17 |
16 namespace shell { | 18 namespace shell { |
17 class Connector; | 19 class Connector; |
18 } | 20 } |
19 | 21 |
20 namespace mus { | 22 namespace mus { |
21 | 23 |
22 class GpuMemoryBufferManagerMus; | 24 class MojoGpuMemoryBufferManager; |
23 | 25 |
24 class GpuService : public gpu::GpuChannelHostFactory { | 26 class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory { |
25 public: | 27 public: |
26 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannel( | 28 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannel( |
27 shell::Connector* connector); | 29 shell::Connector* connector); |
28 | 30 |
29 static bool UseChromeGpuCommandBuffer(); | 31 static bool UseChromeGpuCommandBuffer(); |
30 static GpuService* GetInstance(); | 32 static GpuService* GetInstance(); |
31 | 33 |
32 private: | 34 private: |
33 friend struct base::DefaultSingletonTraits<GpuService>; | 35 friend struct base::DefaultSingletonTraits<GpuService>; |
34 | 36 |
35 GpuService(); | 37 GpuService(); |
36 ~GpuService() override; | 38 ~GpuService() override; |
37 | 39 |
38 // gpu::GpuChannelHostFactory overrides: | 40 // gpu::GpuChannelHostFactory overrides: |
39 bool IsMainThread() override; | 41 bool IsMainThread() override; |
40 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; | 42 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; |
41 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( | 43 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( |
42 size_t size) override; | 44 size_t size) override; |
43 | 45 |
44 base::MessageLoop* main_message_loop_; | 46 base::MessageLoop* main_message_loop_; |
45 base::WaitableEvent shutdown_event_; | 47 base::WaitableEvent shutdown_event_; |
46 base::Thread io_thread_; | 48 base::Thread io_thread_; |
47 std::unique_ptr<GpuMemoryBufferManagerMus> gpu_memory_buffer_manager_; | 49 std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
50 | |
51 base::Lock lock_; | |
sky
2016/06/06 17:06:25
Please add a comment as to why you need the lock.
Peng
2016/06/06 17:16:41
Done.
| |
48 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | 52 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
49 | 53 |
50 DISALLOW_COPY_AND_ASSIGN(GpuService); | 54 DISALLOW_COPY_AND_ASSIGN(GpuService); |
51 }; | 55 }; |
52 | 56 |
53 } // namespace mus | 57 } // namespace mus |
54 | 58 |
55 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_CONNECTION_H_ | 59 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_CONNECTION_H_ |
OLD | NEW |