OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 13 matching lines...) Expand all Loading... |
24 #include "ipc/ipc_channel_posix.h" | 24 #include "ipc/ipc_channel_posix.h" |
25 #endif | 25 #endif |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 void PluginReleaseCallback() { | 29 void PluginReleaseCallback() { |
30 ChildProcess::current()->ReleaseProcess(); | 30 ChildProcess::current()->ReleaseProcess(); |
31 } | 31 } |
32 | 32 |
33 // How long we wait before releasing the plugin process. | 33 // How long we wait before releasing the plugin process. |
34 const int kPluginReleaseTimeMs = 5 * 60 * 1000; // 5 minutes | 34 const int kPluginReleaseTimeMinutes = 5; |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 // If a sync call to the renderer results in a modal dialog, we need to have a | 38 // If a sync call to the renderer results in a modal dialog, we need to have a |
39 // way to know so that we can run a nested message loop to simulate what would | 39 // way to know so that we can run a nested message loop to simulate what would |
40 // happen in a single process browser and avoid deadlock. | 40 // happen in a single process browser and avoid deadlock. |
41 class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter { | 41 class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter { |
42 public: | 42 public: |
43 MessageFilter() : channel_(NULL) { } | 43 MessageFilter() : channel_(NULL) { } |
44 ~MessageFilter() { | 44 ~MessageFilter() { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 ChildProcess::current()->AddRefProcess(); | 170 ChildProcess::current()->AddRefProcess(); |
171 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 171 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
172 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); | 172 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); |
173 } | 173 } |
174 | 174 |
175 PluginChannel::~PluginChannel() { | 175 PluginChannel::~PluginChannel() { |
176 if (renderer_handle_) | 176 if (renderer_handle_) |
177 base::CloseProcessHandle(renderer_handle_); | 177 base::CloseProcessHandle(renderer_handle_); |
178 | 178 |
179 MessageLoop::current()->PostDelayedTask( | 179 MessageLoop::current()->PostDelayedTask( |
180 FROM_HERE, base::Bind(&PluginReleaseCallback), kPluginReleaseTimeMs); | 180 FROM_HERE, |
| 181 base::Bind(&PluginReleaseCallback), |
| 182 base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes)); |
181 } | 183 } |
182 | 184 |
183 bool PluginChannel::Send(IPC::Message* msg) { | 185 bool PluginChannel::Send(IPC::Message* msg) { |
184 in_send_++; | 186 in_send_++; |
185 if (log_messages_) { | 187 if (log_messages_) { |
186 VLOG(1) << "sending message @" << msg << " on channel @" << this | 188 VLOG(1) << "sending message @" << msg << " on channel @" << this |
187 << " with type " << msg->type(); | 189 << " with type " << msg->type(); |
188 } | 190 } |
189 bool result = NPChannelBase::Send(msg); | 191 bool result = NPChannelBase::Send(msg); |
190 in_send_--; | 192 in_send_--; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop, | 327 bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop, |
326 bool create_pipe_now, | 328 bool create_pipe_now, |
327 base::WaitableEvent* shutdown_event) { | 329 base::WaitableEvent* shutdown_event) { |
328 if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event)) | 330 if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event)) |
329 return false; | 331 return false; |
330 | 332 |
331 channel_->AddFilter(filter_.get()); | 333 channel_->AddFilter(filter_.get()); |
332 return true; | 334 return true; |
333 } | 335 } |
334 | 336 |
OLD | NEW |