OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ | 5 #ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ |
6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ | 6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
19 #include "content/common/gpu_process_launch_causes.h" | 19 #include "content/common/gpu_process_launch_causes.h" |
20 #include "gpu/ipc/client/gpu_channel_host.h" | 20 #include "gpu/ipc/client/gpu_channel_host.h" |
21 #include "ipc/message_filter.h" | 21 #include "ipc/message_filter.h" |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 class BrowserGpuMemoryBufferManager; | 24 class BrowserGpuMemoryBufferManager; |
25 | 25 |
26 class CONTENT_EXPORT BrowserGpuChannelHostFactory | 26 class CONTENT_EXPORT BrowserGpuChannelHostFactory |
27 : public gpu::GpuChannelHostFactory { | 27 : public gpu::GpuChannelHostFactory { |
28 public: | 28 public: |
29 static void Initialize(bool establish_gpu_channel); | 29 static void Initialize(bool establish_gpu_channel); |
30 static void Terminate(); | 30 static void Terminate(); |
31 static BrowserGpuChannelHostFactory* instance() { return instance_; } | 31 static BrowserGpuChannelHostFactory* instance() { return instance_; } |
32 | 32 |
33 // Overridden from gpu::GpuChannelHostFactory: | 33 // Overridden from gpu::GpuChannelHostFactory: |
34 bool IsMainThread() override; | 34 bool IsMainThread() override; |
35 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; | 35 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; |
36 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override; | 36 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( |
| 37 size_t size) override; |
37 | 38 |
38 int GpuProcessHostId() { return gpu_host_id_; } | 39 int GpuProcessHostId() { return gpu_host_id_; } |
39 #if !defined(OS_ANDROID) | 40 #if !defined(OS_ANDROID) |
40 gpu::GpuChannelHost* EstablishGpuChannelSync( | 41 gpu::GpuChannelHost* EstablishGpuChannelSync( |
41 CauseForGpuLaunch cause_for_gpu_launch); | 42 CauseForGpuLaunch cause_for_gpu_launch); |
42 #endif | 43 #endif |
43 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch, | 44 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch, |
44 const base::Closure& callback); | 45 const base::Closure& callback); |
45 gpu::GpuChannelHost* GetGpuChannel(); | 46 gpu::GpuChannelHost* GetGpuChannel(); |
46 int GetGpuChannelId() { return gpu_client_id_; } | 47 int GetGpuChannelId() { return gpu_client_id_; } |
(...skipping 10 matching lines...) Expand all Loading... |
57 | 58 |
58 void GpuChannelEstablished(); | 59 void GpuChannelEstablished(); |
59 | 60 |
60 static void AddFilterOnIO(int gpu_host_id, | 61 static void AddFilterOnIO(int gpu_host_id, |
61 scoped_refptr<IPC::MessageFilter> filter); | 62 scoped_refptr<IPC::MessageFilter> filter); |
62 static void InitializeShaderDiskCacheOnIO(int gpu_client_id, | 63 static void InitializeShaderDiskCacheOnIO(int gpu_client_id, |
63 const base::FilePath& cache_dir); | 64 const base::FilePath& cache_dir); |
64 | 65 |
65 const int gpu_client_id_; | 66 const int gpu_client_id_; |
66 const uint64_t gpu_client_tracing_id_; | 67 const uint64_t gpu_client_tracing_id_; |
67 scoped_ptr<base::WaitableEvent> shutdown_event_; | 68 std::unique_ptr<base::WaitableEvent> shutdown_event_; |
68 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | 69 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
69 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 70 std::unique_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
70 int gpu_host_id_; | 71 int gpu_host_id_; |
71 scoped_refptr<EstablishRequest> pending_request_; | 72 scoped_refptr<EstablishRequest> pending_request_; |
72 std::vector<base::Closure> established_callbacks_; | 73 std::vector<base::Closure> established_callbacks_; |
73 | 74 |
74 static BrowserGpuChannelHostFactory* instance_; | 75 static BrowserGpuChannelHostFactory* instance_; |
75 | 76 |
76 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); | 77 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); |
77 }; | 78 }; |
78 | 79 |
79 } // namespace content | 80 } // namespace content |
80 | 81 |
81 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ | 82 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ |
OLD | NEW |