| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/process.h" | 11 #include "base/process.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "content/common/gpu/client/gpu_channel_host.h" | 13 #include "content/common/gpu/client/gpu_channel_host.h" |
| 14 #include "ipc/ipc_channel_handle.h" | 14 #include "ipc/ipc_channel_handle.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class BrowserGpuChannelHostFactory : public GpuChannelHostFactory { | 18 class BrowserGpuChannelHostFactory : public GpuChannelHostFactory { |
| 19 public: | 19 public: |
| 20 static void Initialize(); | 20 static void Initialize(); |
| 21 static void Terminate(); | 21 static void Terminate(); |
| 22 static BrowserGpuChannelHostFactory* Get(); | 22 static BrowserGpuChannelHostFactory* instance() { return instance_; } |
| 23 | 23 |
| 24 // GpuChannelHostFactory implementation. | 24 // GpuChannelHostFactory implementation. |
| 25 virtual bool IsMainThread() OVERRIDE; | 25 virtual bool IsMainThread() OVERRIDE; |
| 26 virtual bool IsIOThread() OVERRIDE; | 26 virtual bool IsIOThread() OVERRIDE; |
| 27 virtual MessageLoop* GetMainLoop() OVERRIDE; | 27 virtual MessageLoop* GetMainLoop() OVERRIDE; |
| 28 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() OVERRIDE; | 28 virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() OVERRIDE; |
| 29 virtual base::WaitableEvent* GetShutDownEvent() OVERRIDE; | 29 virtual base::WaitableEvent* GetShutDownEvent() OVERRIDE; |
| 30 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory( | 30 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory( |
| 31 uint32 size) OVERRIDE; | 31 uint32 size) OVERRIDE; |
| 32 virtual int32 CreateViewCommandBuffer( | 32 virtual int32 CreateViewCommandBuffer( |
| 33 int32 surface_id, | 33 int32 surface_id, |
| 34 const GPUCreateCommandBufferConfig& init_params) OVERRIDE; | 34 const GPUCreateCommandBufferConfig& init_params) OVERRIDE; |
| 35 virtual GpuChannelHost* EstablishGpuChannelSync( | 35 virtual GpuChannelHost* EstablishGpuChannelSync( |
| 36 CauseForGpuLaunch cause_for_gpu_launch) OVERRIDE; | 36 CauseForGpuLaunch cause_for_gpu_launch) OVERRIDE; |
| 37 | 37 |
| 38 int gpu_client_id() { return gpu_client_id_; } | |
| 39 | |
| 40 private: | 38 private: |
| 41 struct CreateRequest { | 39 struct CreateRequest { |
| 42 CreateRequest(); | 40 CreateRequest(); |
| 43 ~CreateRequest(); | 41 ~CreateRequest(); |
| 44 base::WaitableEvent event; | 42 base::WaitableEvent event; |
| 45 int32 route_id; | 43 int32 route_id; |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 struct EstablishRequest { | 46 struct EstablishRequest { |
| 49 EstablishRequest(); | 47 EstablishRequest(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 EstablishRequest* request, | 66 EstablishRequest* request, |
| 69 const IPC::ChannelHandle& channel_handle, | 67 const IPC::ChannelHandle& channel_handle, |
| 70 base::ProcessHandle gpu_process_handle, | 68 base::ProcessHandle gpu_process_handle, |
| 71 const GPUInfo& gpu_info); | 69 const GPUInfo& gpu_info); |
| 72 | 70 |
| 73 int gpu_client_id_; | 71 int gpu_client_id_; |
| 74 scoped_ptr<base::WaitableEvent> shutdown_event_; | 72 scoped_ptr<base::WaitableEvent> shutdown_event_; |
| 75 scoped_refptr<GpuChannelHost> gpu_channel_; | 73 scoped_refptr<GpuChannelHost> gpu_channel_; |
| 76 int gpu_host_id_; | 74 int gpu_host_id_; |
| 77 | 75 |
| 76 static BrowserGpuChannelHostFactory* instance_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); | 78 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace content | 81 } // namespace content |
| 82 | 82 |
| 83 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ | 83 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ |
| OLD | NEW |