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/ppapi_plugin/broker_process_dispatcher.h" | 5 #include "content/ppapi_plugin/broker_process_dispatcher.h" |
6 | 6 |
7 #include "content/common/child_process.h" | 7 #include "content/common/child_process.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
11 class PluginReleaseTask : public Task { | 11 class PluginReleaseTask : public Task { |
12 public: | 12 public: |
13 void Run() { | 13 void Run() { |
14 ChildProcess::current()->ReleaseProcess(); | 14 ChildProcess::current()->ReleaseProcess(); |
15 } | 15 } |
16 }; | 16 }; |
17 | 17 |
18 // How long we wait before releasing the plugin process. | 18 // How long we wait before releasing the plugin process. |
19 const int kPluginReleaseTimeMs = 30 * 1000; // 30 seconds. | 19 const int kPluginReleaseTimeMs = 30 * 1000; // 30 seconds. |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 BrokerProcessDispatcher::BrokerProcessDispatcher( | 23 BrokerProcessDispatcher::BrokerProcessDispatcher( |
24 base::ProcessHandle remote_process_handle, | 24 base::ProcessHandle remote_process_handle, |
25 PP_ConnectInstance_Func connect_instance) | 25 PP_ConnectInstance_Func connect_instance) |
26 : pp::proxy::BrokerSideDispatcher(remote_process_handle, connect_instance) { | 26 : ppapi::proxy::BrokerSideDispatcher(remote_process_handle, |
| 27 connect_instance) { |
27 ChildProcess::current()->AddRefProcess(); | 28 ChildProcess::current()->AddRefProcess(); |
28 } | 29 } |
29 | 30 |
30 BrokerProcessDispatcher::~BrokerProcessDispatcher() { | 31 BrokerProcessDispatcher::~BrokerProcessDispatcher() { |
31 // Don't free the process right away. This timer allows the child process | 32 // Don't free the process right away. This timer allows the child process |
32 // to be re-used if the user rapidly goes to a new page that requires this | 33 // to be re-used if the user rapidly goes to a new page that requires this |
33 // plugin. This is the case for common plugins where they may be used on a | 34 // plugin. This is the case for common plugins where they may be used on a |
34 // source and destination page of a navigation. We don't want to tear down | 35 // source and destination page of a navigation. We don't want to tear down |
35 // and re-start processes each time in these cases. | 36 // and re-start processes each time in these cases. |
36 MessageLoop::current()->PostDelayedTask(FROM_HERE, new PluginReleaseTask(), | 37 MessageLoop::current()->PostDelayedTask(FROM_HERE, new PluginReleaseTask(), |
37 kPluginReleaseTimeMs); | 38 kPluginReleaseTimeMs); |
38 } | 39 } |
OLD | NEW |