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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 kConnected, | 78 kConnected, |
79 // An error caused the host to become disconnected. Recreate channel to | 79 // An error caused the host to become disconnected. Recreate channel to |
80 // reestablish connection. | 80 // reestablish connection. |
81 kLost | 81 kLost |
82 }; | 82 }; |
83 | 83 |
84 // Called on the render thread | 84 // Called on the render thread |
85 GpuChannelHost(GpuChannelHostFactory* factory, | 85 GpuChannelHost(GpuChannelHostFactory* factory, |
86 int gpu_process_id, | 86 int gpu_process_id, |
87 int client_id); | 87 int client_id); |
88 virtual ~GpuChannelHost(); | |
89 | 88 |
90 // Connect to GPU process channel. | 89 // Connect to GPU process channel. |
91 void Connect(const IPC::ChannelHandle& channel_handle, | 90 void Connect(const IPC::ChannelHandle& channel_handle, |
92 base::ProcessHandle client_process_for_gpu); | 91 base::ProcessHandle client_process_for_gpu); |
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 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // cause all command buffers on this side to soon afterward start | 148 // cause all command buffers on this side to soon afterward start |
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_process_id() const { return gpu_process_id_; } | 154 int gpu_process_id() const { return gpu_process_id_; } |
156 int client_id() const { return client_id_; } | 155 int client_id() const { return client_id_; } |
157 | 156 |
158 private: | 157 private: |
| 158 friend class base::RefCountedThreadSafe<GpuChannelHost>; |
| 159 virtual ~GpuChannelHost(); |
| 160 |
159 // A filter used internally to route incoming messages from the IO thread | 161 // A filter used internally to route incoming messages from the IO thread |
160 // to the correct message loop. | 162 // to the correct message loop. |
161 class MessageFilter : public IPC::ChannelProxy::MessageFilter { | 163 class MessageFilter : public IPC::ChannelProxy::MessageFilter { |
162 public: | 164 public: |
163 explicit MessageFilter(GpuChannelHost* parent); | 165 explicit MessageFilter(GpuChannelHost* parent); |
164 virtual ~MessageFilter(); | |
165 | 166 |
166 void AddRoute(int route_id, | 167 void AddRoute(int route_id, |
167 base::WeakPtr<IPC::Channel::Listener> listener, | 168 base::WeakPtr<IPC::Channel::Listener> listener, |
168 scoped_refptr<base::MessageLoopProxy> loop); | 169 scoped_refptr<base::MessageLoopProxy> loop); |
169 void RemoveRoute(int route_id); | 170 void RemoveRoute(int route_id); |
170 | 171 |
171 // IPC::ChannelProxy::MessageFilter implementation: | 172 // IPC::ChannelProxy::MessageFilter implementation: |
172 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 173 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
173 virtual void OnChannelError() OVERRIDE; | 174 virtual void OnChannelError() OVERRIDE; |
174 | 175 |
175 private: | 176 private: |
| 177 virtual ~MessageFilter(); |
| 178 |
176 GpuChannelHost* parent_; | 179 GpuChannelHost* parent_; |
177 | 180 |
178 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; | 181 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; |
179 ListenerMap listeners_; | 182 ListenerMap listeners_; |
180 }; | 183 }; |
181 | 184 |
182 GpuChannelHostFactory* factory_; | 185 GpuChannelHostFactory* factory_; |
183 int gpu_process_id_; | 186 int gpu_process_id_; |
184 int client_id_; | 187 int client_id_; |
185 | 188 |
(...skipping 12 matching lines...) Expand all Loading... |
198 // for calls from contexts that may live on the compositor or main thread. | 201 // for calls from contexts that may live on the compositor or main thread. |
199 mutable base::Lock context_lock_; | 202 mutable base::Lock context_lock_; |
200 | 203 |
201 // A filter for sending messages from thread other than the main thread. | 204 // A filter for sending messages from thread other than the main thread. |
202 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; | 205 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; |
203 | 206 |
204 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 207 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
205 }; | 208 }; |
206 | 209 |
207 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 210 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
OLD | NEW |