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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 680193002: Plugin Power Saver: Implement size-based heuristic for peripheral content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 4ce4f972db0f278193541181710e527129cdb364..106e94195df3027d10828f1199e353b8587a71d7 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -493,6 +493,10 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message)
IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung)
IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed)
+ IPC_MESSAGE_HANDLER(FrameHostMsg_PluginContentOriginAllowed,
+ OnPluginContentOriginAllowed)
+ IPC_MESSAGE_HANDLER(FrameHostMsg_PluginContentMarkedPeripheral,
+ OnPluginContentMarkedPeripheral)
IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse,
OnDomOperationResponse)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor,
@@ -2899,6 +2903,48 @@ void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path,
PluginCrashed(plugin_path, plugin_pid));
}
+void WebContentsImpl::OnPluginContentOriginAllowed(const GURL& content_origin) {
+ DCHECK(render_frame_message_source_);
+ DCHECK(!render_view_message_source_);
+
+ plugin_content_origin_whitelist_[render_frame_message_source_].insert(
groby-ooo-7-16 2014/10/28 00:39:12 Why is this a map keyed by renderframe? AFAICT, we
Lei Zhang 2014/10/28 02:16:23 I think it's just being used to limit the number o
+ content_origin);
+
+ // Broadcast whitelisting to all render frames with plugin content from this
+ // origin thas has already been marked peripheral.
+ for (auto peripheral_plugin_origins : plugin_content_marked_peripheral_) {
+ if (peripheral_plugin_origins.second.erase(content_origin) > 0) {
groby-ooo-7-16 2014/10/28 00:39:11 Hm. Is that necessary? The message is broadcast an
tommycli 2014/10/28 22:18:07 The WebContents needs to aggregate all the per-fra
+ Send(new FrameMsg_PluginContentOriginWhitelisted(
+ peripheral_plugin_origins.first->GetRoutingID(),
+ content_origin));
+ }
+ }
+}
+
+void WebContentsImpl::OnPluginContentMarkedPeripheral(
+ const GURL& content_origin) {
+ DCHECK(render_frame_message_source_);
+ DCHECK(!render_view_message_source_);
+
+ bool origin_already_whitelisted = false;
+ for (auto whitelisted_plugin_origins : plugin_content_origin_whitelist_) {
+ if (whitelisted_plugin_origins.second.find(content_origin) !=
groby-ooo-7-16 2014/10/28 00:39:11 Since you're just checking for set membership: i
tommycli 2014/10/28 22:18:07 Done.
+ whitelisted_plugin_origins.second.end()) {
+ origin_already_whitelisted = true;
+ break;
+ }
+ }
+
+ if (origin_already_whitelisted) {
+ Send(new FrameMsg_PluginContentOriginWhitelisted(
+ render_frame_message_source_->GetRoutingID(),
+ content_origin));
+ } else {
+ plugin_content_marked_peripheral_[render_frame_message_source_].insert(
+ content_origin);
+ }
+}
+
void WebContentsImpl::OnDomOperationResponse(const std::string& json_string,
int automation_id) {
DomOperationNotificationDetails details(json_string, automation_id);
@@ -3336,6 +3382,8 @@ void WebContentsImpl::RenderFrameCreated(RenderFrameHost* render_frame_host) {
void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) {
ClearPowerSaveBlockers(render_frame_host);
+ plugin_content_origin_whitelist_.erase(render_frame_host);
+ plugin_content_marked_peripheral_.erase(render_frame_host);
FOR_EACH_OBSERVER(WebContentsObserver,
observers_,
RenderFrameDeleted(render_frame_host));

Powered by Google App Engine
This is Rietveld 408576698