| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 bool IsLost() const { | 95 bool IsLost() const { |
| 96 DCHECK(channel_filter_.get()); | 96 DCHECK(channel_filter_.get()); |
| 97 return channel_filter_->IsLost(); | 97 return channel_filter_->IsLost(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 // The GPU stats reported by the GPU process. | 100 // The GPU stats reported by the GPU process. |
| 101 const gpu::GPUInfo& gpu_info() const { return gpu_info_; } | 101 const gpu::GPUInfo& gpu_info() const { return gpu_info_; } |
| 102 | 102 |
| 103 // IPC::Sender implementation: | 103 // IPC::Sender implementation: |
| 104 virtual bool Send(IPC::Message* msg) override; | 104 bool Send(IPC::Message* msg) override; |
| 105 | 105 |
| 106 // Create and connect to a command buffer in the GPU process. | 106 // Create and connect to a command buffer in the GPU process. |
| 107 CommandBufferProxyImpl* CreateViewCommandBuffer( | 107 CommandBufferProxyImpl* CreateViewCommandBuffer( |
| 108 int32 surface_id, | 108 int32 surface_id, |
| 109 CommandBufferProxyImpl* share_group, | 109 CommandBufferProxyImpl* share_group, |
| 110 const std::vector<int32>& attribs, | 110 const std::vector<int32>& attribs, |
| 111 const GURL& active_url, | 111 const GURL& active_url, |
| 112 gfx::GpuPreference gpu_preference); | 112 gfx::GpuPreference gpu_preference); |
| 113 | 113 |
| 114 // Create and connect to a command buffer in the GPU process. | 114 // Create and connect to a command buffer in the GPU process. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 int32 ReserveImageId(); | 159 int32 ReserveImageId(); |
| 160 | 160 |
| 161 // Generate a route ID guaranteed to be unique for this channel. | 161 // Generate a route ID guaranteed to be unique for this channel. |
| 162 int32 GenerateRouteID(); | 162 int32 GenerateRouteID(); |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 friend class base::RefCountedThreadSafe<GpuChannelHost>; | 165 friend class base::RefCountedThreadSafe<GpuChannelHost>; |
| 166 GpuChannelHost(GpuChannelHostFactory* factory, | 166 GpuChannelHost(GpuChannelHostFactory* factory, |
| 167 const gpu::GPUInfo& gpu_info, | 167 const gpu::GPUInfo& gpu_info, |
| 168 cc::GpuMemoryBufferManager* gpu_memory_buffer_manager); | 168 cc::GpuMemoryBufferManager* gpu_memory_buffer_manager); |
| 169 virtual ~GpuChannelHost(); | 169 ~GpuChannelHost() override; |
| 170 void Connect(const IPC::ChannelHandle& channel_handle, | 170 void Connect(const IPC::ChannelHandle& channel_handle, |
| 171 base::WaitableEvent* shutdown_event); | 171 base::WaitableEvent* shutdown_event); |
| 172 | 172 |
| 173 // A filter used internally to route incoming messages from the IO thread | 173 // A filter used internally to route incoming messages from the IO thread |
| 174 // to the correct message loop. It also maintains some shared state between | 174 // to the correct message loop. It also maintains some shared state between |
| 175 // all the contexts. | 175 // all the contexts. |
| 176 class MessageFilter : public IPC::MessageFilter { | 176 class MessageFilter : public IPC::MessageFilter { |
| 177 public: | 177 public: |
| 178 MessageFilter(); | 178 MessageFilter(); |
| 179 | 179 |
| 180 // Called on the IO thread. | 180 // Called on the IO thread. |
| 181 void AddRoute(int route_id, | 181 void AddRoute(int route_id, |
| 182 base::WeakPtr<IPC::Listener> listener, | 182 base::WeakPtr<IPC::Listener> listener, |
| 183 scoped_refptr<base::MessageLoopProxy> loop); | 183 scoped_refptr<base::MessageLoopProxy> loop); |
| 184 // Called on the IO thread. | 184 // Called on the IO thread. |
| 185 void RemoveRoute(int route_id); | 185 void RemoveRoute(int route_id); |
| 186 | 186 |
| 187 // IPC::MessageFilter implementation | 187 // IPC::MessageFilter implementation |
| 188 // (called on the IO thread): | 188 // (called on the IO thread): |
| 189 virtual bool OnMessageReceived(const IPC::Message& msg) override; | 189 bool OnMessageReceived(const IPC::Message& msg) override; |
| 190 virtual void OnChannelError() override; | 190 void OnChannelError() override; |
| 191 | 191 |
| 192 // The following methods can be called on any thread. | 192 // The following methods can be called on any thread. |
| 193 | 193 |
| 194 // Whether the channel is lost. | 194 // Whether the channel is lost. |
| 195 bool IsLost() const; | 195 bool IsLost() const; |
| 196 | 196 |
| 197 private: | 197 private: |
| 198 virtual ~MessageFilter(); | 198 ~MessageFilter() override; |
| 199 | 199 |
| 200 // Threading notes: |listeners_| is only accessed on the IO thread. Every | 200 // Threading notes: |listeners_| is only accessed on the IO thread. Every |
| 201 // other field is protected by |lock_|. | 201 // other field is protected by |lock_|. |
| 202 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; | 202 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; |
| 203 ListenerMap listeners_; | 203 ListenerMap listeners_; |
| 204 | 204 |
| 205 // Protects all fields below this one. | 205 // Protects all fields below this one. |
| 206 mutable base::Lock lock_; | 206 mutable base::Lock lock_; |
| 207 | 207 |
| 208 // Whether the channel has been lost. | 208 // Whether the channel has been lost. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // Used to look up a proxy from its routing id. | 241 // Used to look up a proxy from its routing id. |
| 242 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap; | 242 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap; |
| 243 ProxyMap proxies_; | 243 ProxyMap proxies_; |
| 244 | 244 |
| 245 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 245 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 } // namespace content | 248 } // namespace content |
| 249 | 249 |
| 250 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 250 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
| OLD | NEW |