Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3349)

Unified Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 61063003: Keep NaCl plugins used in app background pages alive when active. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: working prototype Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/nacl_host/nacl_process_host.cc
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index 530ebbb50318b7ab873e46560581e670801946ad..9b533625c36a2ea062a6f23301abe102c8957826 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -25,7 +25,10 @@
#include "base/strings/utf_string_conversions.h"
#include "base/win/windows_version.h"
#include "build/build_config.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/nacl_host/nacl_host_message_filter.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/nacl_cmd_line.h"
@@ -36,6 +39,8 @@
#include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/child_process_data.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/site_instance.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/process_type.h"
@@ -769,6 +774,54 @@ bool NaClProcessHost::SendStart() {
return StartNaClExecution();
}
+class BrowserPpapiHostDelegate : public content::BrowserPpapiHost::Delegate {
+ virtual void OnIdleState(bool idle,
dmichael (off chromium) 2013/11/06 22:39:21 OnIdleStateChange? OnIdleStateTransition?
scheib 2013/11/15 01:22:17 Done: IdleStateChange
+ const base::FilePath& profile_data_directory,
+ const content::RenderViewHost* render_view_host,
+ const GURL& document_url) OVERRIDE {
+ DCHECK(render_view_host);
+ if (!render_view_host)
+ return;
+
+ content::SiteInstance* site_instance = render_view_host->GetSiteInstance();
+ DCHECK(site_instance);
+ if (!site_instance)
+ return;
+
+ extensions::ExtensionSystem* extension_system =
+ extensions::ExtensionSystem::GetForBrowserContext(
+ site_instance->GetBrowserContext());
+ DCHECK(extension_system);
+ if (!extension_system)
+ return;
+
+ const ExtensionService* extension_service =
+ extension_system->extension_service();
+ DCHECK(extension_service);
+ if (!extension_service)
+ return;
+
+ const extensions::Extension* extension =
+ extension_service->GetExtensionById(document_url.host(), false);
+ DCHECK(extension);
+ if (!extension)
+ return;
+
+ ExtensionProcessManager* pm = extension_system->process_manager();
+ DCHECK(pm);
+ if (!pm)
+ return;
+
+ if (idle) {
+ fprintf(stderr, "%s:%s:%d DecrementLazyKeepaliveCount\n", __FILE__, __FUNCTION__, __LINE__);
+ pm->DecrementLazyKeepaliveCount(extension);
+ } else {
+ fprintf(stderr, "%s:%s:%d IncrementLazyKeepaliveCount\n", __FILE__, __FUNCTION__, __LINE__);
+ pm->IncrementLazyKeepaliveCount(extension);
+ }
+ }
+};
dmichael (off chromium) 2013/11/06 22:39:21 This should probably go up in the unnamed namespac
scheib 2013/11/15 01:22:17 Done.
+
// This method is called when NaClProcessHostMsg_PpapiChannelCreated is
// received or PpapiHostMsg_ChannelCreated is forwarded by our plugin
// listener.
@@ -788,14 +841,15 @@ void NaClProcessHost::OnPpapiChannelCreated(
base::MessageLoopProxy::current().get()));
// Create the browser ppapi host and enable PPAPI message dispatching to the
// browser process.
- ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess(
+ ppapi_host_ = content::BrowserPpapiHost::CreateExternalPluginProcess(
+ new BrowserPpapiHostDelegate(),
ipc_proxy_channel_.get(), // sender
permissions_,
process_->GetData().handle,
ipc_proxy_channel_.get(),
nacl_host_message_filter_->render_process_id(),
render_view_id_,
- profile_directory_));
+ profile_directory_);
ppapi::PpapiNaClChannelArgs args;
args.off_the_record = nacl_host_message_filter_->off_the_record();

Powered by Google App Engine
This is Rietveld 408576698