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

Side by Side Diff: content/plugin/plugin_channel.cc

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
« no previous file with comments | « content/plugin/plugin_channel.h ('k') | content/plugin/webplugin_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/plugin/plugin_channel.h" 5 #include "content/plugin/plugin_channel.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 return channel; 155 return channel;
156 } 156 }
157 157
158 // static 158 // static
159 void PluginChannel::NotifyRenderersOfPendingShutdown() { 159 void PluginChannel::NotifyRenderersOfPendingShutdown() {
160 Broadcast(new PluginHostMsg_PluginShuttingDown()); 160 Broadcast(new PluginHostMsg_PluginShuttingDown());
161 } 161 }
162 162
163 PluginChannel::PluginChannel() 163 PluginChannel::PluginChannel()
164 : renderer_handle_(0), 164 : renderer_id_(-1),
165 renderer_id_(-1),
166 in_send_(0), 165 in_send_(0),
167 incognito_(false), 166 incognito_(false),
168 filter_(new MessageFilter()) { 167 filter_(new MessageFilter()) {
169 set_send_unblocking_only_during_unblock_dispatch(); 168 set_send_unblocking_only_during_unblock_dispatch();
170 ChildProcess::current()->AddRefProcess(); 169 ChildProcess::current()->AddRefProcess();
171 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 170 const CommandLine* command_line = CommandLine::ForCurrentProcess();
172 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); 171 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
173 } 172 }
174 173
175 PluginChannel::~PluginChannel() { 174 PluginChannel::~PluginChannel() {
176 if (renderer_handle_)
177 base::CloseProcessHandle(renderer_handle_);
178
179 MessageLoop::current()->PostDelayedTask( 175 MessageLoop::current()->PostDelayedTask(
180 FROM_HERE, 176 FROM_HERE,
181 base::Bind(&PluginReleaseCallback), 177 base::Bind(&PluginReleaseCallback),
182 base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes)); 178 base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes));
183 } 179 }
184 180
185 bool PluginChannel::Send(IPC::Message* msg) { 181 bool PluginChannel::Send(IPC::Message* msg) {
186 in_send_++; 182 in_send_++;
187 if (log_messages_) { 183 if (log_messages_) {
188 VLOG(1) << "sending message @" << msg << " on channel @" << this 184 VLOG(1) << "sending message @" << msg << " on channel @" << this
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 274 }
279 } 275 }
280 Send(new PluginHostMsg_ClearSiteDataResult(success)); 276 Send(new PluginHostMsg_ClearSiteDataResult(success));
281 } 277 }
282 278
283 base::WaitableEvent* PluginChannel::GetModalDialogEvent( 279 base::WaitableEvent* PluginChannel::GetModalDialogEvent(
284 gfx::NativeViewId containing_window) { 280 gfx::NativeViewId containing_window) {
285 return filter_->GetModalDialogEvent(containing_window); 281 return filter_->GetModalDialogEvent(containing_window);
286 } 282 }
287 283
288 void PluginChannel::OnChannelConnected(int32 peer_pid) {
289 base::ProcessHandle handle;
290 if (!base::OpenProcessHandle(peer_pid, &handle)) {
291 NOTREACHED();
292 }
293 renderer_handle_ = handle;
294 NPChannelBase::OnChannelConnected(peer_pid);
295 }
296
297 void PluginChannel::OnChannelError() { 284 void PluginChannel::OnChannelError() {
298 base::CloseProcessHandle(renderer_handle_);
299 renderer_handle_ = 0;
300 NPChannelBase::OnChannelError(); 285 NPChannelBase::OnChannelError();
301 CleanUp(); 286 CleanUp();
302 } 287 }
303 288
304 void PluginChannel::CleanUp() { 289 void PluginChannel::CleanUp() {
305 // We need to clean up the stubs so that they call NPPDestroy. This will 290 // We need to clean up the stubs so that they call NPPDestroy. This will
306 // also lead to them releasing their reference on this object so that it can 291 // also lead to them releasing their reference on this object so that it can
307 // be deleted. 292 // be deleted.
308 for (size_t i = 0; i < plugin_stubs_.size(); ++i) 293 for (size_t i = 0; i < plugin_stubs_.size(); ++i)
309 RemoveRoute(plugin_stubs_[i]->instance_id()); 294 RemoveRoute(plugin_stubs_[i]->instance_id());
(...skipping 10 matching lines...) Expand all
320 bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop, 305 bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop,
321 bool create_pipe_now, 306 bool create_pipe_now,
322 base::WaitableEvent* shutdown_event) { 307 base::WaitableEvent* shutdown_event) {
323 if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event)) 308 if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event))
324 return false; 309 return false;
325 310
326 channel_->AddFilter(filter_.get()); 311 channel_->AddFilter(filter_.get());
327 return true; 312 return true;
328 } 313 }
329 314
OLDNEW
« no previous file with comments | « content/plugin/plugin_channel.h ('k') | content/plugin/webplugin_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698