Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1091)

Side by Side Diff: content/common/gpu/client/gpu_channel_host.h

Issue 9958034: Convert plugin and GPU process to brokered handle duplication. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
11 11
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/process.h"
16 #include "base/process_util.h" 17 #include "base/process_util.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
19 #include "content/common/gpu/gpu_process_launch_causes.h" 20 #include "content/common/gpu/gpu_process_launch_causes.h"
20 #include "content/common/message_router.h" 21 #include "content/common/message_router.h"
21 #include "content/public/common/gpu_info.h" 22 #include "content/public/common/gpu_info.h"
22 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" 23 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h"
23 #include "ipc/ipc_channel_handle.h" 24 #include "ipc/ipc_channel_handle.h"
24 #include "ipc/ipc_channel_proxy.h" 25 #include "ipc/ipc_channel_proxy.h"
25 #include "ipc/ipc_sync_channel.h" 26 #include "ipc/ipc_sync_channel.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 kUnconnected, 77 kUnconnected,
77 // Ready to use. 78 // Ready to use.
78 kConnected, 79 kConnected,
79 // An error caused the host to become disconnected. Recreate channel to 80 // An error caused the host to become disconnected. Recreate channel to
80 // reestablish connection. 81 // reestablish connection.
81 kLost 82 kLost
82 }; 83 };
83 84
84 // Called on the render thread 85 // Called on the render thread
85 GpuChannelHost(GpuChannelHostFactory* factory, 86 GpuChannelHost(GpuChannelHostFactory* factory,
86 int gpu_process_id,
87 int client_id); 87 int client_id);
88 virtual ~GpuChannelHost(); 88 virtual ~GpuChannelHost();
89 89
90 // Connect to GPU process channel. 90 // Connect to GPU process channel.
91 void Connect(const IPC::ChannelHandle& channel_handle, 91 void Connect(const IPC::ChannelHandle& channel_handle);
92 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
99 // The GPU stats reported by the GPU process. 98 // The GPU stats reported by the GPU process.
100 void set_gpu_info(const content::GPUInfo& gpu_info); 99 void set_gpu_info(const content::GPUInfo& gpu_info);
101 const content::GPUInfo& gpu_info() const; 100 const content::GPUInfo& gpu_info() const;
102 101
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 bool WillGpuSwitchOccur(bool is_creating_context, 144 bool WillGpuSwitchOccur(bool is_creating_context,
146 gfx::GpuPreference gpu_preference); 145 gfx::GpuPreference gpu_preference);
147 146
148 // Forcibly close the channel on the GPU process side. This will 147 // Forcibly close the channel on the GPU process side. This will
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 base::ProcessId gpu_process_id() const { return channel_->peer_pid(); }
156 int client_id() const { return client_id_; } 155 int client_id() const { return client_id_; }
157 156
158 private: 157 private:
159 // A filter used internally to route incoming messages from the IO thread 158 // A filter used internally to route incoming messages from the IO thread
160 // to the correct message loop. 159 // to the correct message loop.
161 class MessageFilter : public IPC::ChannelProxy::MessageFilter { 160 class MessageFilter : public IPC::ChannelProxy::MessageFilter {
162 public: 161 public:
163 explicit MessageFilter(GpuChannelHost* parent); 162 explicit MessageFilter(GpuChannelHost* parent);
164 virtual ~MessageFilter(); 163 virtual ~MessageFilter();
165 164
166 void AddRoute(int route_id, 165 void AddRoute(int route_id,
167 base::WeakPtr<IPC::Channel::Listener> listener, 166 base::WeakPtr<IPC::Channel::Listener> listener,
168 scoped_refptr<base::MessageLoopProxy> loop); 167 scoped_refptr<base::MessageLoopProxy> loop);
169 void RemoveRoute(int route_id); 168 void RemoveRoute(int route_id);
170 169
171 // IPC::ChannelProxy::MessageFilter implementation: 170 // IPC::ChannelProxy::MessageFilter implementation:
172 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 171 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
173 virtual void OnChannelError() OVERRIDE; 172 virtual void OnChannelError() OVERRIDE;
174 173
175 private: 174 private:
176 GpuChannelHost* parent_; 175 GpuChannelHost* parent_;
177 176
178 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; 177 typedef base::hash_map<int, GpuListenerInfo> ListenerMap;
179 ListenerMap listeners_; 178 ListenerMap listeners_;
180 }; 179 };
181 180
182 GpuChannelHostFactory* factory_; 181 GpuChannelHostFactory* factory_;
183 int gpu_process_id_;
184 int client_id_; 182 int client_id_;
185 183
186 State state_; 184 State state_;
187 185
188 content::GPUInfo gpu_info_; 186 content::GPUInfo gpu_info_;
189 187
190 scoped_ptr<IPC::SyncChannel> channel_; 188 scoped_ptr<IPC::SyncChannel> channel_;
191 scoped_refptr<MessageFilter> channel_filter_; 189 scoped_refptr<MessageFilter> channel_filter_;
192 190
193 // Used to look up a proxy from its routing id. 191 // Used to look up a proxy from its routing id.
194 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap; 192 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap;
195 ProxyMap proxies_; 193 ProxyMap proxies_;
196 194
197 // A lock to guard against concurrent access to members like the proxies map 195 // A lock to guard against concurrent access to members like the proxies map
198 // for calls from contexts that may live on the compositor or main thread. 196 // for calls from contexts that may live on the compositor or main thread.
199 mutable base::Lock context_lock_; 197 mutable base::Lock context_lock_;
200 198
201 // A filter for sending messages from thread other than the main thread. 199 // A filter for sending messages from thread other than the main thread.
202 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; 200 scoped_refptr<IPC::SyncMessageFilter> sync_filter_;
203 201
204 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); 202 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost);
205 }; 203 };
206 204
207 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ 205 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698