OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_GPU_GPU_CHANNEL_H_ | 5 #ifndef CHROME_GPU_GPU_CHANNEL_H_ |
6 #define CHROME_GPU_GPU_CHANNEL_H_ | 6 #define CHROME_GPU_GPU_CHANNEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
14 #include "base/scoped_open_process.h" | 14 #include "base/scoped_open_process.h" |
15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "chrome/common/gpu_create_command_buffer_config.h" | 17 #include "chrome/common/gpu_create_command_buffer_config.h" |
18 #include "chrome/common/gpu_video_common.h" | 18 #include "chrome/common/gpu_video_common.h" |
19 #include "chrome/common/message_router.h" | 19 #include "chrome/common/message_router.h" |
20 #include "chrome/gpu/gpu_command_buffer_stub.h" | 20 #include "chrome/gpu/gpu_command_buffer_stub.h" |
21 #include "gfx/native_widget_types.h" | 21 #include "gfx/native_widget_types.h" |
22 #include "gfx/size.h" | 22 #include "gfx/size.h" |
23 #include "ipc/ipc_channel.h" | 23 #include "ipc/ipc_channel.h" |
24 #include "ipc/ipc_message.h" | 24 #include "ipc/ipc_message.h" |
25 #include "ipc/ipc_sync_channel.h" | 25 #include "ipc/ipc_sync_channel.h" |
26 | 26 |
27 class GpuThread; | |
28 | |
27 // Encapsulates an IPC channel between the GPU process and one renderer | 29 // Encapsulates an IPC channel between the GPU process and one renderer |
28 // process. On the renderer side there's a corresponding GpuChannelHost. | 30 // process. On the renderer side there's a corresponding GpuChannelHost. |
29 class GpuChannel : public IPC::Channel::Listener, | 31 class GpuChannel : public IPC::Channel::Listener, |
30 public IPC::Message::Sender, | 32 public IPC::Message::Sender, |
31 public base::RefCountedThreadSafe<GpuChannel> { | 33 public base::RefCountedThreadSafe<GpuChannel> { |
32 public: | 34 public: |
33 explicit GpuChannel(int renderer_id); | 35 GpuChannel(GpuThread* gpu_thread, int renderer_id); |
34 virtual ~GpuChannel(); | 36 virtual ~GpuChannel(); |
35 | 37 |
36 bool Init(); | 38 bool Init(); |
37 | 39 |
40 // Get the GpuThread that owns this channel. | |
41 GpuThread* gpu_thread() const { return gpu_thread_; } | |
42 | |
43 // Returns the name of the associated IPC channel. | |
38 std::string GetChannelName(); | 44 std::string GetChannelName(); |
39 | 45 |
40 #if defined(OS_POSIX) | 46 #if defined(OS_POSIX) |
41 int GetRendererFileDescriptor(); | 47 int GetRendererFileDescriptor(); |
42 #endif // defined(OS_POSIX) | 48 #endif // defined(OS_POSIX) |
43 | 49 |
44 base::ProcessHandle renderer_handle() const { | 50 base::ProcessHandle renderer_handle() const { |
45 return renderer_process_.handle(); | 51 return renderer_process_.handle(); |
46 } | 52 } |
47 | 53 |
(...skipping 29 matching lines...) Expand all Loading... | |
77 const gfx::Size& size, | 83 const gfx::Size& size, |
78 const GPUCreateCommandBufferConfig& init_params, | 84 const GPUCreateCommandBufferConfig& init_params, |
79 uint32 parent_texture_id, | 85 uint32 parent_texture_id, |
80 int32* route_id); | 86 int32* route_id); |
81 void OnDestroyCommandBuffer(int32 route_id); | 87 void OnDestroyCommandBuffer(int32 route_id); |
82 | 88 |
83 void OnCreateVideoDecoder(int32 context_route_id, | 89 void OnCreateVideoDecoder(int32 context_route_id, |
84 int32 decoder_host_id); | 90 int32 decoder_host_id); |
85 void OnDestroyVideoDecoder(int32 decoder_id); | 91 void OnDestroyVideoDecoder(int32 decoder_id); |
86 | 92 |
93 // The lifetime of objects of this class is managed by a GpuThread. The | |
94 // GpuThreadss destroy all the GpuChannels that they own when they | |
Ken Russell (switch to Gerrit)
2011/01/12 23:13:56
GpuThreadss -> GpuThreads
| |
95 // are destroyed. So a raw pointer is safe. | |
96 GpuThread* gpu_thread_; | |
97 | |
87 scoped_ptr<IPC::SyncChannel> channel_; | 98 scoped_ptr<IPC::SyncChannel> channel_; |
88 | 99 |
89 // Handle to the renderer process who is on the other side of the channel. | 100 // Handle to the renderer process who is on the other side of the channel. |
90 base::ScopedOpenProcess renderer_process_; | 101 base::ScopedOpenProcess renderer_process_; |
91 | 102 |
92 // The id of the renderer who is on the other side of the channel. | 103 // The id of the renderer who is on the other side of the channel. |
93 int renderer_id_; | 104 int renderer_id_; |
94 | 105 |
95 // Used to implement message routing functionality to CommandBuffer objects | 106 // Used to implement message routing functionality to CommandBuffer objects |
96 MessageRouter router_; | 107 MessageRouter router_; |
97 | 108 |
98 #if defined(ENABLE_GPU) | 109 #if defined(ENABLE_GPU) |
99 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; | 110 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; |
100 StubMap stubs_; | 111 StubMap stubs_; |
101 | 112 |
102 #if defined(OS_MACOSX) | 113 #if defined(OS_MACOSX) |
103 std::set<int32> destroyed_renderer_routes_; | 114 std::set<int32> destroyed_renderer_routes_; |
104 #endif // defined (OS_MACOSX) | 115 #endif // defined (OS_MACOSX) |
105 #endif // defined (ENABLE_GPU) | 116 #endif // defined (ENABLE_GPU) |
106 | 117 |
107 bool log_messages_; // True if we should log sent and received messages. | 118 bool log_messages_; // True if we should log sent and received messages. |
108 | 119 |
109 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 120 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
110 }; | 121 }; |
111 | 122 |
112 #endif // CHROME_GPU_GPU_CHANNEL_H_ | 123 #endif // CHROME_GPU_GPU_CHANNEL_H_ |
OLD | NEW |