summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-18 17:58:07 +0000
committerkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-18 17:58:07 +0000
commita6939ca46f65f58425ef5966028013ed65535e8f (patch)
treeeced484a857552f2510c119c1d203ee69732f21e /webkit
parent92c699d5a6b73316cb9fd7f44ef9753038b02846 (diff)
downloadchromium_src-a6939ca46f65f58425ef5966028013ed65535e8f.zip
chromium_src-a6939ca46f65f58425ef5966028013ed65535e8f.tar.gz
chromium_src-a6939ca46f65f58425ef5966028013ed65535e8f.tar.bz2
Set the minimum timer interval on a per-page basis, and adjust it when
tabs are brought to the foreground and sent to the background. This CL does not actually increase the background timer interval. That will be done separately, so that it can easily be reverted without removing all of the associated code. BUG=66078 TEST=none (tested manually with minimal test case) Review URL: http://codereview.chromium.org/6532012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75404 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webkit_constants.h22
-rw-r--r--webkit/glue/webkit_glue.gypi1
-rw-r--r--webkit/glue/webpreferences.cc4
-rw-r--r--webkit/support/webkit_support.cc6
-rw-r--r--webkit/support/webkit_support.h4
5 files changed, 37 insertions, 0 deletions
diff --git a/webkit/glue/webkit_constants.h b/webkit/glue/webkit_constants.h
new file mode 100644
index 0000000..54e7e00
--- /dev/null
+++ b/webkit/glue/webkit_constants.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
+#define WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
+
+namespace webkit_glue {
+
+// Chromium sets the minimum interval timeout to 4ms, overriding the
+// default of 10ms. We'd like to go lower, however there are poorly
+// coded websites out there which do create CPU-spinning loops. Using
+// 4ms prevents the CPU from spinning too busily and provides a balance
+// between CPU spinning and the smallest possible interval timer.
+const double kForegroundTabTimerInterval = 0.004;
+
+// Provides control over the minimum timer interval for background tabs.
+const double kBackgroundTabTimerInterval = 0.004;
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 7060ed2..c3bb964 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -422,6 +422,7 @@
'webdropdata.h',
'webfileutilities_impl.cc',
'webfileutilities_impl.h',
+ 'webkit_constants.h',
'webkit_glue.cc',
'webkit_glue.h',
'webkitclient_impl.cc',
diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc
index 03c87bf..86c40f6 100644
--- a/webkit/glue/webpreferences.cc
+++ b/webkit/glue/webpreferences.cc
@@ -12,6 +12,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "webkit/glue/webkit_constants.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebRuntimeFeatures;
@@ -197,4 +198,7 @@ void WebPreferences::Apply(WebView* web_view) const {
settings->setInteractiveFormValidationEnabled(
interactive_form_validation_enabled);
+
+ // Tabs start out hidden and are made visible.
+ settings->setMinimumTimerInterval(webkit_glue::kBackgroundTabTimerInterval);
}
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index 2e893f9..9e850f4 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -37,6 +37,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
#include "webkit/appcache/web_application_cache_host_impl.h"
#include "webkit/glue/media/video_renderer_impl.h"
+#include "webkit/glue/webkit_constants.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webkitclient_impl.h"
#include "webkit/glue/webmediaplayer_impl.h"
@@ -548,4 +549,9 @@ void OpenFileSystem(WebFrame* frame, WebFileSystem::Type type,
fileSystem->OpenFileSystem(frame, type, size, create, callbacks);
}
+// Timers
+double GetForegroundTabTimerInterval() {
+ return webkit_glue::kForegroundTabTimerInterval;
+}
+
} // namespace webkit_support
diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h
index 30cb885..d145955 100644
--- a/webkit/support/webkit_support.h
+++ b/webkit/support/webkit_support.h
@@ -182,6 +182,10 @@ enum {
VKEY_F1 = ui::VKEY_F1,
};
+// - Timers
+
+double GetForegroundTabTimerInterval();
+
} // namespace webkit_support
#endif // WEBKIT_SUPPORT_WEBIT_CLIENT_IMPL_H_