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/ppapi_plugin/plugin_process_dispatcher.h" | 5 #include "content/ppapi_plugin/plugin_process_dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "content/common/child_process.h" | 9 #include "content/common/child_process.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 // How long we wait before releasing the plugin process. | 13 // How long we wait before releasing the plugin process. |
14 const int kPluginReleaseTimeSeconds = 30; | 14 const int kPluginReleaseTimeSeconds = 30; |
15 | 15 |
16 } // namespace | 16 } // namespace |
17 | 17 |
18 PluginProcessDispatcher::PluginProcessDispatcher( | 18 PluginProcessDispatcher::PluginProcessDispatcher( |
19 PP_GetInterface_Func get_interface, | 19 PP_GetInterface_Func get_interface, |
| 20 const ppapi::PpapiPermissions& permissions, |
20 bool incognito) | 21 bool incognito) |
21 : ppapi::proxy::PluginDispatcher(get_interface, | 22 : ppapi::proxy::PluginDispatcher(get_interface, |
| 23 permissions, |
22 incognito) { | 24 incognito) { |
23 ChildProcess::current()->AddRefProcess(); | 25 ChildProcess::current()->AddRefProcess(); |
24 } | 26 } |
25 | 27 |
26 PluginProcessDispatcher::~PluginProcessDispatcher() { | 28 PluginProcessDispatcher::~PluginProcessDispatcher() { |
27 // Don't free the process right away. This timer allows the child process | 29 // Don't free the process right away. This timer allows the child process |
28 // to be re-used if the user rapidly goes to a new page that requires this | 30 // to be re-used if the user rapidly goes to a new page that requires this |
29 // plugin. This is the case for common plugins where they may be used on a | 31 // plugin. This is the case for common plugins where they may be used on a |
30 // source and destination page of a navigation. We don't want to tear down | 32 // source and destination page of a navigation. We don't want to tear down |
31 // and re-start processes each time in these cases. | 33 // and re-start processes each time in these cases. |
32 MessageLoop::current()->PostDelayedTask( | 34 MessageLoop::current()->PostDelayedTask( |
33 FROM_HERE, | 35 FROM_HERE, |
34 base::Bind(&ChildProcess::ReleaseProcess, | 36 base::Bind(&ChildProcess::ReleaseProcess, |
35 base::Unretained(ChildProcess::current())), | 37 base::Unretained(ChildProcess::current())), |
36 base::TimeDelta::FromSeconds(kPluginReleaseTimeSeconds)); | 38 base::TimeDelta::FromSeconds(kPluginReleaseTimeSeconds)); |
37 } | 39 } |
OLD | NEW |