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

Unified Diff: ppapi/proxy/plugin_main_nacl.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: fix ref counted compile warning 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: ppapi/proxy/plugin_main_nacl.cc
diff --git a/ppapi/proxy/plugin_main_nacl.cc b/ppapi/proxy/plugin_main_nacl.cc
index f050778227cad4eef35c4f1c26f59fe1a6ccbcbe..3e1eb1691da4c293459a3e381646ec6056b24926 100644
--- a/ppapi/proxy/plugin_main_nacl.cc
+++ b/ppapi/proxy/plugin_main_nacl.cc
@@ -12,6 +12,7 @@
// ViewMsgLog et al. functions.
#include "base/command_line.h"
+#include "base/debug/trace_event.h"
#include "base/message_loop/message_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
@@ -266,6 +267,23 @@ void PpapiPluginRegisterThreadCreator(
ppapi::PPB_Audio_Shared::SetThreadFunctions(thread_functions);
}
+const int checkIntervalInSeconds = 1;
yzshen1 2013/11/06 22:43:15 Please use kCheck.... Shall we put these two vari
scheib 2013/11/15 01:22:17 Done.
+bool last_was_active = false;
+
+void CheckActivity(base::MessageLoop* loop, PpapiDispatcher* dispatcher) {
yzshen1 2013/11/06 22:43:15 |dispatcher| is not needed, right?
scheib 2013/11/15 01:22:17 Done.
+ bool was_active = PluginGlobals::Get()->plugin_has_been_active();
yzshen1 2013/11/06 22:43:15 You need to lock the pepper proxy lock before you
scheib 2013/11/15 01:22:17 Done.
+ PluginGlobals::Get()->set_plugin_has_been_active(false);
+
+ if (last_was_active != was_active) {
+ PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PpapiHostMsg_IdleState(!was_active));
+ }
+ last_was_active = was_active;
+
+ loop->PostDelayedTask(FROM_HERE, base::Bind(&CheckActivity, loop, dispatcher),
yzshen1 2013/11/06 22:43:15 nit: you could use MessageLoop::current() instead
scheib 2013/11/15 01:22:17 Done.
+ base::TimeDelta::FromSeconds(checkIntervalInSeconds));
+}
+
int PpapiPluginMain() {
// Though it isn't referenced here, we must instantiate an AtExitManager.
base::AtExitManager exit_manager;
@@ -289,6 +307,11 @@ int PpapiPluginMain() {
PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy());
plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher);
+ io_thread.message_loop()->PostDelayedTask(FROM_HERE,
+ base::Bind(&CheckActivity,
+ io_thread.message_loop(),
+ &ppapi_dispatcher),
+ base::TimeDelta::FromSeconds(checkIntervalInSeconds));
yzshen1 2013/11/06 22:43:15 wrong indent.
scheib 2013/11/15 01:22:17 Done.
loop.Run();
return 0;

Powered by Google App Engine
This is Rietveld 408576698