| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 virtual void CreateImage( | 71 virtual void CreateImage( |
| 72 gfx::PluginWindowHandle window, | 72 gfx::PluginWindowHandle window, |
| 73 int32 image_id, | 73 int32 image_id, |
| 74 const CreateImageCallback& callback) = 0; | 74 const CreateImageCallback& callback) = 0; |
| 75 virtual void DeleteImage(int32 image_id, int32 sync_point) = 0; | 75 virtual void DeleteImage(int32 image_id, int32 sync_point) = 0; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 // Encapsulates an IPC channel between the client and one GPU process. | 78 // Encapsulates an IPC channel between the client and one GPU process. |
| 79 // On the GPU process side there's a corresponding GpuChannel. | 79 // On the GPU process side there's a corresponding GpuChannel. |
| 80 class GpuChannelHost : public IPC::Sender, | 80 class GpuChannelHost : public IPC::Sender, |
| 81 public base::RefCountedThreadSafe<GpuChannelHost> { | 81 public base::RefCountedThreadSafe<GpuChannelHost>, |
| 82 public base::SupportsWeakPtr<GpuChannelHost> { |
| 82 public: | 83 public: |
| 83 enum State { | 84 enum State { |
| 84 // Not yet connected. | 85 // Not yet connected. |
| 85 kUnconnected, | 86 kUnconnected, |
| 86 // Ready to use. | 87 // Ready to use. |
| 87 kConnected, | 88 kConnected, |
| 88 // An error caused the host to become disconnected. Recreate channel to | 89 // An error caused the host to become disconnected. Recreate channel to |
| 89 // reestablish connection. | 90 // reestablish connection. |
| 90 kLost | 91 kLost |
| 91 }; | 92 }; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 friend class base::RefCountedThreadSafe<GpuChannelHost>; | 179 friend class base::RefCountedThreadSafe<GpuChannelHost>; |
| 179 virtual ~GpuChannelHost(); | 180 virtual ~GpuChannelHost(); |
| 180 | 181 |
| 181 // Message handlers. | 182 // Message handlers. |
| 182 void OnGenerateMailboxNamesReply(const std::vector<std::string>& names); | 183 void OnGenerateMailboxNamesReply(const std::vector<std::string>& names); |
| 183 | 184 |
| 184 // A filter used internally to route incoming messages from the IO thread | 185 // A filter used internally to route incoming messages from the IO thread |
| 185 // to the correct message loop. | 186 // to the correct message loop. |
| 186 class MessageFilter : public IPC::ChannelProxy::MessageFilter { | 187 class MessageFilter : public IPC::ChannelProxy::MessageFilter { |
| 187 public: | 188 public: |
| 188 explicit MessageFilter(GpuChannelHost* parent); | 189 MessageFilter(base::WeakPtr<GpuChannelHost> parent, |
| 190 GpuChannelHostFactory* factory); |
| 189 | 191 |
| 190 void AddRoute(int route_id, | 192 void AddRoute(int route_id, |
| 191 base::WeakPtr<IPC::Listener> listener, | 193 base::WeakPtr<IPC::Listener> listener, |
| 192 scoped_refptr<base::MessageLoopProxy> loop); | 194 scoped_refptr<base::MessageLoopProxy> loop); |
| 193 void RemoveRoute(int route_id); | 195 void RemoveRoute(int route_id); |
| 194 | 196 |
| 195 // IPC::ChannelProxy::MessageFilter implementation: | 197 // IPC::ChannelProxy::MessageFilter implementation: |
| 196 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 198 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 197 virtual void OnChannelError() OVERRIDE; | 199 virtual void OnChannelError() OVERRIDE; |
| 198 | 200 |
| 199 private: | 201 private: |
| 200 virtual ~MessageFilter(); | 202 virtual ~MessageFilter(); |
| 201 | 203 |
| 202 GpuChannelHost* parent_; | 204 // Note: this reference can only be used to post tasks back to the |
| 205 // GpuChannelHost, it is illegal to dereference on the IO thread where the |
| 206 // MessageFilter lives. |
| 207 base::WeakPtr<GpuChannelHost> parent_; |
| 208 |
| 209 GpuChannelHostFactory* factory_; |
| 203 | 210 |
| 204 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; | 211 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; |
| 205 ListenerMap listeners_; | 212 ListenerMap listeners_; |
| 206 }; | 213 }; |
| 207 | 214 |
| 208 GpuChannelHostFactory* factory_; | 215 GpuChannelHostFactory* factory_; |
| 209 int client_id_; | 216 int client_id_; |
| 210 int gpu_host_id_; | 217 int gpu_host_id_; |
| 211 | 218 |
| 212 State state_; | 219 State state_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 232 | 239 |
| 233 // Transfer buffer IDs are allocated in sequence. | 240 // Transfer buffer IDs are allocated in sequence. |
| 234 base::AtomicSequenceNumber next_transfer_buffer_id_; | 241 base::AtomicSequenceNumber next_transfer_buffer_id_; |
| 235 | 242 |
| 236 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 243 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
| 237 }; | 244 }; |
| 238 | 245 |
| 239 } // namespace content | 246 } // namespace content |
| 240 | 247 |
| 241 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 248 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
| OLD | NEW |