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_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 kConnected, | 79 kConnected, |
80 // An error caused the host to become disconnected. Recreate channel to | 80 // An error caused the host to become disconnected. Recreate channel to |
81 // reestablish connection. | 81 // reestablish connection. |
82 kLost | 82 kLost |
83 }; | 83 }; |
84 | 84 |
85 // Called on the render thread | 85 // Called on the render thread |
86 GpuChannelHost(GpuChannelHostFactory* factory, | 86 GpuChannelHost(GpuChannelHostFactory* factory, |
87 int gpu_host_id, | 87 int gpu_host_id, |
88 int client_id); | 88 int client_id); |
89 virtual ~GpuChannelHost(); | |
90 | 89 |
91 // Connect to GPU process channel. | 90 // Connect to GPU process channel. |
92 void Connect(const IPC::ChannelHandle& channel_handle); | 91 void Connect(const IPC::ChannelHandle& channel_handle); |
93 | 92 |
94 State state() const { return state_; } | 93 State state() const { return state_; } |
95 | 94 |
96 // Change state to kLost. | 95 // Change state to kLost. |
97 void SetStateLost(); | 96 void SetStateLost(); |
98 | 97 |
99 // The GPU stats reported by the GPU process. | 98 // The GPU stats reported by the GPU process. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // registering lost contexts. It also has the side effect of setting | 149 // registering lost contexts. It also has the side effect of setting |
151 // the state on this side to lost. | 150 // the state on this side to lost. |
152 void ForciblyCloseChannel(); | 151 void ForciblyCloseChannel(); |
153 | 152 |
154 GpuChannelHostFactory* factory() const { return factory_; } | 153 GpuChannelHostFactory* factory() const { return factory_; } |
155 int gpu_host_id() const { return gpu_host_id_; } | 154 int gpu_host_id() const { return gpu_host_id_; } |
156 base::ProcessId gpu_pid() const { return channel_->peer_pid(); } | 155 base::ProcessId gpu_pid() const { return channel_->peer_pid(); } |
157 int client_id() const { return client_id_; } | 156 int client_id() const { return client_id_; } |
158 | 157 |
159 private: | 158 private: |
| 159 friend class base::RefCountedThreadSafe<GpuChannelHost>; |
| 160 virtual ~GpuChannelHost(); |
| 161 |
160 // A filter used internally to route incoming messages from the IO thread | 162 // A filter used internally to route incoming messages from the IO thread |
161 // to the correct message loop. | 163 // to the correct message loop. |
162 class MessageFilter : public IPC::ChannelProxy::MessageFilter { | 164 class MessageFilter : public IPC::ChannelProxy::MessageFilter { |
163 public: | 165 public: |
164 explicit MessageFilter(GpuChannelHost* parent); | 166 explicit MessageFilter(GpuChannelHost* parent); |
165 virtual ~MessageFilter(); | |
166 | 167 |
167 void AddRoute(int route_id, | 168 void AddRoute(int route_id, |
168 base::WeakPtr<IPC::Channel::Listener> listener, | 169 base::WeakPtr<IPC::Channel::Listener> listener, |
169 scoped_refptr<base::MessageLoopProxy> loop); | 170 scoped_refptr<base::MessageLoopProxy> loop); |
170 void RemoveRoute(int route_id); | 171 void RemoveRoute(int route_id); |
171 | 172 |
172 // IPC::ChannelProxy::MessageFilter implementation: | 173 // IPC::ChannelProxy::MessageFilter implementation: |
173 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 174 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
174 virtual void OnChannelError() OVERRIDE; | 175 virtual void OnChannelError() OVERRIDE; |
175 | 176 |
176 private: | 177 private: |
| 178 virtual ~MessageFilter(); |
| 179 |
177 GpuChannelHost* parent_; | 180 GpuChannelHost* parent_; |
178 | 181 |
179 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; | 182 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; |
180 ListenerMap listeners_; | 183 ListenerMap listeners_; |
181 }; | 184 }; |
182 | 185 |
183 GpuChannelHostFactory* factory_; | 186 GpuChannelHostFactory* factory_; |
184 int client_id_; | 187 int client_id_; |
185 int gpu_host_id_; | 188 int gpu_host_id_; |
186 | 189 |
(...skipping 12 matching lines...) Expand all Loading... |
199 // for calls from contexts that may live on the compositor or main thread. | 202 // for calls from contexts that may live on the compositor or main thread. |
200 mutable base::Lock context_lock_; | 203 mutable base::Lock context_lock_; |
201 | 204 |
202 // A filter for sending messages from thread other than the main thread. | 205 // A filter for sending messages from thread other than the main thread. |
203 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; | 206 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; |
204 | 207 |
205 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 208 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
206 }; | 209 }; |
207 | 210 |
208 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 211 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
OLD | NEW |