summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-24 18:11:39 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-24 18:11:39 +0000
commit770dd8b8b1ee5adc67ed257e53d3f34c7e67b02e (patch)
treee0894895aa1152dd152459657f4e0de497195d51 /chrome
parentd5fa6fd614049dcacb22ab9034eaf2b892a17e85 (diff)
downloadchromium_src-770dd8b8b1ee5adc67ed257e53d3f34c7e67b02e.zip
chromium_src-770dd8b8b1ee5adc67ed257e53d3f34c7e67b02e.tar.gz
chromium_src-770dd8b8b1ee5adc67ed257e53d3f34c7e67b02e.tar.bz2
Mac: Fix renderer idle cpu usage regression.
Since polling is required only for the preferred height and mac only needs preferred width, add a flag that specifies if the client is interested in width and/or height. This is a band-aid, the Real Fix is tracked in 44850. BUG=44494 TEST=Open chrome's task manager. Idle renderer processes should take close to 0 %cpu instead of ~1.5 before. Review URL: http://codereview.chromium.org/2145002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_host.cc3
-rw-r--r--chrome/browser/notifications/balloon_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_view_host.h6
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc6
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_mac.mm8
-rw-r--r--chrome/common/render_messages.h9
-rw-r--r--chrome/common/render_messages_internal.h2
-rw-r--r--chrome/renderer/render_view.cc16
-rw-r--r--chrome/renderer/render_view.h2
10 files changed, 42 insertions, 18 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 1ae5aca..1a98b0d 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -712,7 +712,8 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
extension_host_type_ == ViewType::EXTENSION_MOLE ||
extension_host_type_ == ViewType::EXTENSION_POPUP ||
extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
- render_view_host->EnablePreferredSizeChangedMode();
+ render_view_host->EnablePreferredSizeChangedMode(
+ kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
}
}
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index 3dbefdc..56c6b93 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -15,6 +15,7 @@
#include "chrome/common/bindings_policy.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
+#include "chrome/common/render_messages.h"
#include "chrome/common/renderer_preferences.h"
#include "chrome/common/url_constants.h"
@@ -57,7 +58,8 @@ void BalloonHost::Close(RenderViewHost* render_view_host) {
}
void BalloonHost::RenderViewCreated(RenderViewHost* render_view_host) {
- render_view_host->EnablePreferredSizeChangedMode();
+ render_view_host->EnablePreferredSizeChangedMode(
+ kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
}
void BalloonHost::RenderViewReady(RenderViewHost* render_view_host) {
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index c807f73..7d5a58a 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1816,8 +1816,8 @@ void RenderViewHost::SendContentSettings(const GURL& url,
Send(new ViewMsg_SetContentSettingsForCurrentURL(url, settings));
}
-void RenderViewHost::EnablePreferredSizeChangedMode() {
- Send(new ViewMsg_EnablePreferredSizeChangedMode(routing_id()));
+void RenderViewHost::EnablePreferredSizeChangedMode(int flags) {
+ Send(new ViewMsg_EnablePreferredSizeChangedMode(routing_id(), flags));
}
void RenderViewHost::OnExtensionPostMessage(
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 97467f4..cd97788 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -462,8 +462,10 @@ class RenderViewHost : public RenderWidgetHost {
const ContentSettings& settings);
// Tells the renderer to notify us when the page contents preferred size
- // changed.
- void EnablePreferredSizeChangedMode();
+ // changed. |flags| is a combination of
+ // |ViewHostMsg_EnablePreferredSizeChangedMode_Flags| values, which is defined
+ // in render_messages.h.
+ void EnablePreferredSizeChangedMode(int flags);
protected:
// RenderWidgetHost protected overrides.
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 3e38fe0..f3160cc 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -789,8 +789,10 @@ bool TabContents::NavigateToPendingEntry(
if (!dest_render_view_host)
return false; // Unable to create the desired render view host.
- if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications())
- dest_render_view_host->EnablePreferredSizeChangedMode();
+ if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) {
+ dest_render_view_host->EnablePreferredSizeChangedMode(
+ kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
+ }
// For security, we should never send non-DOM-UI URLs (other than about:blank)
// to a DOM UI renderer. Double check that here.
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm
index 92cbe2d..9de79b9 100644
--- a/chrome/browser/tab_contents/tab_contents_view_mac.mm
+++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm
@@ -154,10 +154,10 @@ void TabContentsViewMac::StartDragging(
}
void TabContentsViewMac::RenderViewCreated(RenderViewHost* host) {
- // We want updates whenever the intrinsic width of the webpage
- // changes. Put the RenderView into that mode.
- int routing_id = host->routing_id();
- host->Send(new ViewMsg_EnablePreferredSizeChangedMode(routing_id));
+ // We want updates whenever the intrinsic width of the webpage changes.
+ // Put the RenderView into that mode. The preferred width is used for example
+ // when the "zoom" button in the browser window is clicked.
+ host->EnablePreferredSizeChangedMode(kPreferredSizeWidth);
}
void TabContentsViewMac::SetPageTitle(const std::wstring& title) {
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 065fde0..ce94e22 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -657,6 +657,15 @@ struct ViewMsg_ExtensionExtentsUpdated_Params {
std::vector< std::pair<std::string, ExtensionExtent> > extension_apps;
};
+// Values that may be OR'd together to form the 'flags' parameter of the
+// ViewMsg_EnablePreferredSizeChangedMode message.
+enum ViewHostMsg_EnablePreferredSizeChangedMode_Flags {
+ kPreferredSizeNothing,
+ kPreferredSizeWidth = 1 << 0,
+ // Requesting the height currently requires a polling loop in render_view.cc.
+ kPreferredSizeHeightThisIsSlow = 1 << 1,
+};
+
namespace IPC {
template <>
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 2f71dc6..828c0e9 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -763,7 +763,7 @@ IPC_BEGIN_MESSAGES(View)
IPC_MESSAGE_ROUTED0(ViewMsg_Move_ACK)
// Used to instruct the RenderView to send back updates to the preferred size.
- IPC_MESSAGE_ROUTED0(ViewMsg_EnablePreferredSizeChangedMode)
+ IPC_MESSAGE_ROUTED1(ViewMsg_EnablePreferredSizeChangedMode, int /*flags*/)
// Used to tell the renderer not to add scrollbars with height and
// width below a threshold.
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index e1a0dc3..832914a 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -3875,13 +3875,21 @@ void RenderView::OnEnableViewSourceMode() {
main_frame->enableViewSourceMode(true);
}
-void RenderView::OnEnablePreferredSizeChangedMode() {
+void RenderView::OnEnablePreferredSizeChangedMode(int flags) {
+ DCHECK(flags != kPreferredSizeNothing);
if (send_preferred_size_changes_)
return;
-
send_preferred_size_changes_ = true;
- preferred_size_change_timer_.Start(TimeDelta::FromMilliseconds(10), this,
- &RenderView::CheckPreferredSize);
+
+ // WebKit doesn't send a notification of the effective height of the page
+ // changes, so poll for it.
+ // TODO: Add a notification for this to WebKit, remove polling. After that's
+ // done, rename kPreferredSizeHeightThisIsSlow to kPreferredSizeHeight.
+ // http://crbug.com/44850
+ if (flags & kPreferredSizeHeightThisIsSlow) {
+ preferred_size_change_timer_.Start(TimeDelta::FromMilliseconds(10), this,
+ &RenderView::CheckPreferredSize);
+ }
}
void RenderView::OnDisableScrollbarsForSmallWindows(
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 972e2a7..283f203 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -722,7 +722,7 @@ class RenderView : public RenderWidget,
void OnInstallMissingPlugin();
void OnFileChooserResponse(const std::vector<FilePath>& paths);
void OnEnableViewSourceMode();
- void OnEnablePreferredSizeChangedMode();
+ void OnEnablePreferredSizeChangedMode(int flags);
void OnDisableScrollbarsForSmallWindows(
const gfx::Size& disable_scrollbars_size_limit);
void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);