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

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 gpu_host_id,
87 int client_id); 88 int client_id);
88 virtual ~GpuChannelHost(); 89 virtual ~GpuChannelHost();
89 90
90 // Connect to GPU process channel. 91 // Connect to GPU process channel.
91 void Connect(const IPC::ChannelHandle& channel_handle, 92 void Connect(const IPC::ChannelHandle& channel_handle);
92 base::ProcessHandle client_process_for_gpu);
93 93
94 State state() const { return state_; } 94 State state() const { return state_; }
95 95
96 // Change state to kLost. 96 // Change state to kLost.
97 void SetStateLost(); 97 void SetStateLost();
98 98
99 // The GPU stats reported by the GPU process. 99 // The GPU stats reported by the GPU process.
100 void set_gpu_info(const content::GPUInfo& gpu_info); 100 void set_gpu_info(const content::GPUInfo& gpu_info);
101 const content::GPUInfo& gpu_info() const; 101 const content::GPUInfo& gpu_info() const;
102 102
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 bool WillGpuSwitchOccur(bool is_creating_context, 145 bool WillGpuSwitchOccur(bool is_creating_context,
146 gfx::GpuPreference gpu_preference); 146 gfx::GpuPreference gpu_preference);
147 147
148 // Forcibly close the channel on the GPU process side. This will 148 // Forcibly close the channel on the GPU process side. This will
149 // cause all command buffers on this side to soon afterward start 149 // cause all command buffers on this side to soon afterward start
150 // registering lost contexts. It also has the side effect of setting 150 // registering lost contexts. It also has the side effect of setting
151 // the state on this side to lost. 151 // the state on this side to lost.
152 void ForciblyCloseChannel(); 152 void ForciblyCloseChannel();
153 153
154 GpuChannelHostFactory* factory() const { return factory_; } 154 GpuChannelHostFactory* factory() const { return factory_; }
155 int gpu_process_id() const { return gpu_process_id_; } 155 base::ProcessId gpu_process_id() const { return channel_->peer_pid(); }
apatrick_chromium 2012/04/10 20:00:35 I checked the one caller of this function and I th
jschuh 2012/04/10 23:30:59 I just corrected it and added the gpu_host_id stuf
156 int client_id() const { return client_id_; } 156 int client_id() const { return client_id_; }
157 157
158 private: 158 private:
159 // A filter used internally to route incoming messages from the IO thread 159 // A filter used internally to route incoming messages from the IO thread
160 // to the correct message loop. 160 // to the correct message loop.
161 class MessageFilter : public IPC::ChannelProxy::MessageFilter { 161 class MessageFilter : public IPC::ChannelProxy::MessageFilter {
162 public: 162 public:
163 explicit MessageFilter(GpuChannelHost* parent); 163 explicit MessageFilter(GpuChannelHost* parent);
164 virtual ~MessageFilter(); 164 virtual ~MessageFilter();
165 165
166 void AddRoute(int route_id, 166 void AddRoute(int route_id,
167 base::WeakPtr<IPC::Channel::Listener> listener, 167 base::WeakPtr<IPC::Channel::Listener> listener,
168 scoped_refptr<base::MessageLoopProxy> loop); 168 scoped_refptr<base::MessageLoopProxy> loop);
169 void RemoveRoute(int route_id); 169 void RemoveRoute(int route_id);
170 170
171 // IPC::ChannelProxy::MessageFilter implementation: 171 // IPC::ChannelProxy::MessageFilter implementation:
172 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 172 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
173 virtual void OnChannelError() OVERRIDE; 173 virtual void OnChannelError() OVERRIDE;
174 174
175 private: 175 private:
176 GpuChannelHost* parent_; 176 GpuChannelHost* parent_;
177 177
178 typedef base::hash_map<int, GpuListenerInfo> ListenerMap; 178 typedef base::hash_map<int, GpuListenerInfo> ListenerMap;
179 ListenerMap listeners_; 179 ListenerMap listeners_;
180 }; 180 };
181 181
182 GpuChannelHostFactory* factory_; 182 GpuChannelHostFactory* factory_;
183 int gpu_process_id_;
184 int client_id_; 183 int client_id_;
184 int gpu_host_id_;
185 185
186 State state_; 186 State state_;
187 187
188 content::GPUInfo gpu_info_; 188 content::GPUInfo gpu_info_;
189 189
190 scoped_ptr<IPC::SyncChannel> channel_; 190 scoped_ptr<IPC::SyncChannel> channel_;
191 scoped_refptr<MessageFilter> channel_filter_; 191 scoped_refptr<MessageFilter> channel_filter_;
192 192
193 // Used to look up a proxy from its routing id. 193 // Used to look up a proxy from its routing id.
194 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap; 194 typedef base::hash_map<int, CommandBufferProxyImpl*> ProxyMap;
195 ProxyMap proxies_; 195 ProxyMap proxies_;
196 196
197 // A lock to guard against concurrent access to members like the proxies map 197 // 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. 198 // for calls from contexts that may live on the compositor or main thread.
199 mutable base::Lock context_lock_; 199 mutable base::Lock context_lock_;
200 200
201 // A filter for sending messages from thread other than the main thread. 201 // A filter for sending messages from thread other than the main thread.
202 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; 202 scoped_refptr<IPC::SyncMessageFilter> sync_filter_;
203 203
204 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); 204 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost);
205 }; 205 };
206 206
207 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ 207 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_
OLDNEW
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.cc ('k') | content/common/gpu/client/gpu_channel_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698