Hook up V8 idle notifications for extension prcoesses.
We reset the idle timer after any activity, which includes an extension event
or message, or a new extension view being created. The timer runs after 10
seconds of idleness.
BUG=29329
Review URL: http://codereview.chromium.org/460062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34002 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index f5e0d80..8a376aad 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -12,6 +12,8 @@
#include "base/shared_memory.h"
#include "base/string16.h"
#include "base/task.h"
+#include "base/time.h"
+#include "base/timer.h"
#include "build/build_config.h"
#include "chrome/common/child_thread.h"
#include "chrome/common/css_colors.h"
@@ -125,6 +127,8 @@
bool plugin_refresh_allowed() const { return plugin_refresh_allowed_; }
+ bool is_extension_process() const { return is_extension_process_; }
+
// Do DNS prefetch resolution of a hostname.
void Resolve(const char* name, size_t length);
@@ -206,6 +210,9 @@
// A task we invoke periodically to assist with idle cleanup.
void IdleHandler();
+ // Schedule a call to IdleHandler with the given initial delay.
+ void ScheduleIdleHandler(double initial_delay_s);
+
// These objects live solely on the render thread.
scoped_ptr<ScopedRunnableMethodFactory<RenderThread> > task_factory_;
scoped_ptr<VisitedLinkSlave> visited_link_slave_;
@@ -242,6 +249,16 @@
// The current value of the idle notification timer delay.
double idle_notification_delay_in_s_;
+ // True if this renderer is running extensions.
+ bool is_extension_process_;
+
+ // Timer that periodically calls IdleHandler.
+ base::RepeatingTimer<RenderThread> idle_timer_;
+
+ // Same as above, but on a longer timer and will run even if the process is
+ // not idle, to ensure that IdleHandle gets called eventually.
+ base::RepeatingTimer<RenderThread> forced_idle_timer_;
+
DISALLOW_COPY_AND_ASSIGN(RenderThread);
};