| 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 #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 Loading... |
| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 281 } |
| 286 } | 282 } |
| 287 Send(new PluginHostMsg_ClearSiteDataResult(success)); | 283 Send(new PluginHostMsg_ClearSiteDataResult(success)); |
| 288 } | 284 } |
| 289 | 285 |
| 290 base::WaitableEvent* PluginChannel::GetModalDialogEvent( | 286 base::WaitableEvent* PluginChannel::GetModalDialogEvent( |
| 291 gfx::NativeViewId containing_window) { | 287 gfx::NativeViewId containing_window) { |
| 292 return filter_->GetModalDialogEvent(containing_window); | 288 return filter_->GetModalDialogEvent(containing_window); |
| 293 } | 289 } |
| 294 | 290 |
| 295 void PluginChannel::OnChannelConnected(int32 peer_pid) { | |
| 296 base::ProcessHandle handle; | |
| 297 if (!base::OpenProcessHandle(peer_pid, &handle)) { | |
| 298 NOTREACHED(); | |
| 299 } | |
| 300 renderer_handle_ = handle; | |
| 301 NPChannelBase::OnChannelConnected(peer_pid); | |
| 302 } | |
| 303 | |
| 304 void PluginChannel::OnChannelError() { | 291 void PluginChannel::OnChannelError() { |
| 305 base::CloseProcessHandle(renderer_handle_); | |
| 306 renderer_handle_ = 0; | |
| 307 NPChannelBase::OnChannelError(); | 292 NPChannelBase::OnChannelError(); |
| 308 CleanUp(); | 293 CleanUp(); |
| 309 } | 294 } |
| 310 | 295 |
| 311 void PluginChannel::CleanUp() { | 296 void PluginChannel::CleanUp() { |
| 312 // We need to clean up the stubs so that they call NPPDestroy. This will | 297 // We need to clean up the stubs so that they call NPPDestroy. This will |
| 313 // also lead to them releasing their reference on this object so that it can | 298 // also lead to them releasing their reference on this object so that it can |
| 314 // be deleted. | 299 // be deleted. |
| 315 for (size_t i = 0; i < plugin_stubs_.size(); ++i) | 300 for (size_t i = 0; i < plugin_stubs_.size(); ++i) |
| 316 RemoveRoute(plugin_stubs_[i]->instance_id()); | 301 RemoveRoute(plugin_stubs_[i]->instance_id()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 327 bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop, | 312 bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop, |
| 328 bool create_pipe_now, | 313 bool create_pipe_now, |
| 329 base::WaitableEvent* shutdown_event) { | 314 base::WaitableEvent* shutdown_event) { |
| 330 if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event)) | 315 if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event)) |
| 331 return false; | 316 return false; |
| 332 | 317 |
| 333 channel_->AddFilter(filter_.get()); | 318 channel_->AddFilter(filter_.get()); |
| 334 return true; | 319 return true; |
| 335 } | 320 } |
| 336 | 321 |
| OLD | NEW |