| 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_id_(-1), | 164 : renderer_handle_(0), |
| 165 renderer_id_(-1), |
| 165 in_send_(0), | 166 in_send_(0), |
| 166 incognito_(false), | 167 incognito_(false), |
| 167 filter_(new MessageFilter()) { | 168 filter_(new MessageFilter()) { |
| 168 set_send_unblocking_only_during_unblock_dispatch(); | 169 set_send_unblocking_only_during_unblock_dispatch(); |
| 169 ChildProcess::current()->AddRefProcess(); | 170 ChildProcess::current()->AddRefProcess(); |
| 170 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 171 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 171 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); | 172 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); |
| 172 } | 173 } |
| 173 | 174 |
| 174 PluginChannel::~PluginChannel() { | 175 PluginChannel::~PluginChannel() { |
| 176 if (renderer_handle_) |
| 177 base::CloseProcessHandle(renderer_handle_); |
| 178 |
| 175 MessageLoop::current()->PostDelayedTask( | 179 MessageLoop::current()->PostDelayedTask( |
| 176 FROM_HERE, | 180 FROM_HERE, |
| 177 base::Bind(&PluginReleaseCallback), | 181 base::Bind(&PluginReleaseCallback), |
| 178 base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes)); | 182 base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes)); |
| 179 } | 183 } |
| 180 | 184 |
| 181 bool PluginChannel::Send(IPC::Message* msg) { | 185 bool PluginChannel::Send(IPC::Message* msg) { |
| 182 in_send_++; | 186 in_send_++; |
| 183 if (log_messages_) { | 187 if (log_messages_) { |
| 184 VLOG(1) << "sending message @" << msg << " on channel @" << this | 188 VLOG(1) << "sending message @" << msg << " on channel @" << this |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 285 } |
| 282 } | 286 } |
| 283 Send(new PluginHostMsg_ClearSiteDataResult(success)); | 287 Send(new PluginHostMsg_ClearSiteDataResult(success)); |
| 284 } | 288 } |
| 285 | 289 |
| 286 base::WaitableEvent* PluginChannel::GetModalDialogEvent( | 290 base::WaitableEvent* PluginChannel::GetModalDialogEvent( |
| 287 gfx::NativeViewId containing_window) { | 291 gfx::NativeViewId containing_window) { |
| 288 return filter_->GetModalDialogEvent(containing_window); | 292 return filter_->GetModalDialogEvent(containing_window); |
| 289 } | 293 } |
| 290 | 294 |
| 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 |
| 291 void PluginChannel::OnChannelError() { | 304 void PluginChannel::OnChannelError() { |
| 305 base::CloseProcessHandle(renderer_handle_); |
| 306 renderer_handle_ = 0; |
| 292 NPChannelBase::OnChannelError(); | 307 NPChannelBase::OnChannelError(); |
| 293 CleanUp(); | 308 CleanUp(); |
| 294 } | 309 } |
| 295 | 310 |
| 296 void PluginChannel::CleanUp() { | 311 void PluginChannel::CleanUp() { |
| 297 // We need to clean up the stubs so that they call NPPDestroy. This will | 312 // We need to clean up the stubs so that they call NPPDestroy. This will |
| 298 // also lead to them releasing their reference on this object so that it can | 313 // also lead to them releasing their reference on this object so that it can |
| 299 // be deleted. | 314 // be deleted. |
| 300 for (size_t i = 0; i < plugin_stubs_.size(); ++i) | 315 for (size_t i = 0; i < plugin_stubs_.size(); ++i) |
| 301 RemoveRoute(plugin_stubs_[i]->instance_id()); | 316 RemoveRoute(plugin_stubs_[i]->instance_id()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 312 bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop, | 327 bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop, |
| 313 bool create_pipe_now, | 328 bool create_pipe_now, |
| 314 base::WaitableEvent* shutdown_event) { | 329 base::WaitableEvent* shutdown_event) { |
| 315 if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event)) | 330 if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event)) |
| 316 return false; | 331 return false; |
| 317 | 332 |
| 318 channel_->AddFilter(filter_.get()); | 333 channel_->AddFilter(filter_.get()); |
| 319 return true; | 334 return true; |
| 320 } | 335 } |
| 321 | 336 |
| OLD | NEW |