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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // stored in render_(view|frame)_message_source_. 486 // stored in render_(view|frame)_message_source_.
487 if (render_frame_host) 487 if (render_frame_host)
488 render_frame_message_source_ = render_frame_host; 488 render_frame_message_source_ = render_frame_host;
489 else 489 else
490 render_view_message_source_ = render_view_host; 490 render_view_message_source_ = render_view_host;
491 491
492 bool handled = true; 492 bool handled = true;
493 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) 493 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message)
494 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) 494 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung)
495 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) 495 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed)
496 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginContentOriginAllowed,
497 OnPluginContentOriginAllowed)
498 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginContentMarkedPeripheral,
499 OnPluginContentMarkedPeripheral)
496 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, 500 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse,
497 OnDomOperationResponse) 501 OnDomOperationResponse)
498 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, 502 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor,
499 OnThemeColorChanged) 503 OnThemeColorChanged)
500 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, 504 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad,
501 OnDocumentLoadedInFrame) 505 OnDocumentLoadedInFrame)
502 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) 506 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad)
503 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) 507 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading)
504 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) 508 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading)
505 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, 509 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress,
(...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2892 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2896 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2893 PluginHungStatusChanged(plugin_child_id, path, is_hung)); 2897 PluginHungStatusChanged(plugin_child_id, path, is_hung));
2894 } 2898 }
2895 2899
2896 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, 2900 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path,
2897 base::ProcessId plugin_pid) { 2901 base::ProcessId plugin_pid) {
2898 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2902 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2899 PluginCrashed(plugin_path, plugin_pid)); 2903 PluginCrashed(plugin_path, plugin_pid));
2900 } 2904 }
2901 2905
2906 void WebContentsImpl::OnPluginContentOriginAllowed(const GURL& content_origin) {
2907 DCHECK(render_frame_message_source_);
2908 DCHECK(!render_view_message_source_);
2909
2910 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
2911 content_origin);
2912
2913 // Broadcast whitelisting to all render frames with plugin content from this
2914 // origin thas has already been marked peripheral.
2915 for (auto peripheral_plugin_origins : plugin_content_marked_peripheral_) {
2916 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
2917 Send(new FrameMsg_PluginContentOriginWhitelisted(
2918 peripheral_plugin_origins.first->GetRoutingID(),
2919 content_origin));
2920 }
2921 }
2922 }
2923
2924 void WebContentsImpl::OnPluginContentMarkedPeripheral(
2925 const GURL& content_origin) {
2926 DCHECK(render_frame_message_source_);
2927 DCHECK(!render_view_message_source_);
2928
2929 bool origin_already_whitelisted = false;
2930 for (auto whitelisted_plugin_origins : plugin_content_origin_whitelist_) {
2931 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.
2932 whitelisted_plugin_origins.second.end()) {
2933 origin_already_whitelisted = true;
2934 break;
2935 }
2936 }
2937
2938 if (origin_already_whitelisted) {
2939 Send(new FrameMsg_PluginContentOriginWhitelisted(
2940 render_frame_message_source_->GetRoutingID(),
2941 content_origin));
2942 } else {
2943 plugin_content_marked_peripheral_[render_frame_message_source_].insert(
2944 content_origin);
2945 }
2946 }
2947
2902 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string, 2948 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string,
2903 int automation_id) { 2949 int automation_id) {
2904 DomOperationNotificationDetails details(json_string, automation_id); 2950 DomOperationNotificationDetails details(json_string, automation_id);
2905 NotificationService::current()->Notify( 2951 NotificationService::current()->Notify(
2906 NOTIFICATION_DOM_OPERATION_RESPONSE, 2952 NOTIFICATION_DOM_OPERATION_RESPONSE,
2907 Source<WebContents>(this), 2953 Source<WebContents>(this),
2908 Details<DomOperationNotificationDetails>(&details)); 2954 Details<DomOperationNotificationDetails>(&details));
2909 } 2955 }
2910 2956
2911 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, 2957 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url,
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3329 // Note this is only for subframes, the notification for the main frame 3375 // Note this is only for subframes, the notification for the main frame
3330 // happens in RenderViewCreated. 3376 // happens in RenderViewCreated.
3331 FOR_EACH_OBSERVER(WebContentsObserver, 3377 FOR_EACH_OBSERVER(WebContentsObserver,
3332 observers_, 3378 observers_,
3333 RenderFrameCreated(render_frame_host)); 3379 RenderFrameCreated(render_frame_host));
3334 SetAccessibilityModeOnFrame(accessibility_mode_, render_frame_host); 3380 SetAccessibilityModeOnFrame(accessibility_mode_, render_frame_host);
3335 } 3381 }
3336 3382
3337 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) { 3383 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) {
3338 ClearPowerSaveBlockers(render_frame_host); 3384 ClearPowerSaveBlockers(render_frame_host);
3385 plugin_content_origin_whitelist_.erase(render_frame_host);
3386 plugin_content_marked_peripheral_.erase(render_frame_host);
3339 FOR_EACH_OBSERVER(WebContentsObserver, 3387 FOR_EACH_OBSERVER(WebContentsObserver,
3340 observers_, 3388 observers_,
3341 RenderFrameDeleted(render_frame_host)); 3389 RenderFrameDeleted(render_frame_host));
3342 } 3390 }
3343 3391
3344 void WebContentsImpl::WorkerCrashed(RenderFrameHost* render_frame_host) { 3392 void WebContentsImpl::WorkerCrashed(RenderFrameHost* render_frame_host) {
3345 if (delegate_) 3393 if (delegate_)
3346 delegate_->WorkerCrashed(this); 3394 delegate_->WorkerCrashed(this);
3347 } 3395 }
3348 3396
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
4325 node->render_manager()->ResumeResponseDeferredAtStart(); 4373 node->render_manager()->ResumeResponseDeferredAtStart();
4326 } 4374 }
4327 4375
4328 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4376 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4329 force_disable_overscroll_content_ = force_disable; 4377 force_disable_overscroll_content_ = force_disable;
4330 if (view_) 4378 if (view_)
4331 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4379 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4332 } 4380 }
4333 4381
4334 } // namespace content 4382 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698