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

Side by Side Diff: content/renderer/pepper/plugin_instance_throttler_impl.cc

Issue 1528653002: Revert of Plugin Power Saver: Improve Poster behavior for essential plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer/pepper/plugin_instance_throttler_impl.h" 5 #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "content/public/common/content_constants.h" 9 #include "content/public/common/content_constants.h"
10 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void PluginInstanceThrottlerImpl::Initialize( 132 void PluginInstanceThrottlerImpl::Initialize(
133 RenderFrameImpl* frame, 133 RenderFrameImpl* frame,
134 const url::Origin& content_origin, 134 const url::Origin& content_origin,
135 const std::string& plugin_module_name, 135 const std::string& plugin_module_name,
136 const gfx::Size& unobscured_size) { 136 const gfx::Size& unobscured_size) {
137 DCHECK(unobscured_size_.IsEmpty()); 137 DCHECK(unobscured_size_.IsEmpty());
138 unobscured_size_ = unobscured_size; 138 unobscured_size_ = unobscured_size;
139 139
140 // |frame| may be nullptr in tests. 140 // |frame| may be nullptr in tests.
141 if (frame) { 141 if (frame) {
142 bool cross_origin_main_content = false;
142 float zoom_factor = GetWebPlugin()->container()->pageZoomFactor(); 143 float zoom_factor = GetWebPlugin()->container()->pageZoomFactor();
143 auto status = frame->GetPeripheralContentStatus( 144 if (!frame->ShouldThrottleContent(
144 frame->GetWebFrame()->top()->securityOrigin(), content_origin, 145 frame->GetWebFrame()->top()->securityOrigin(), content_origin,
145 gfx::Size(roundf(unobscured_size.width() / zoom_factor), 146 roundf(unobscured_size.width() / zoom_factor),
146 roundf(unobscured_size.height() / zoom_factor))); 147 roundf(unobscured_size.height() / zoom_factor),
147 if (status != RenderFrame::CONTENT_STATUS_PERIPHERAL) { 148 &cross_origin_main_content)) {
148 DCHECK_NE(THROTTLER_STATE_MARKED_ESSENTIAL, state_); 149 DCHECK_NE(THROTTLER_STATE_MARKED_ESSENTIAL, state_);
149 state_ = THROTTLER_STATE_MARKED_ESSENTIAL; 150 state_ = THROTTLER_STATE_MARKED_ESSENTIAL;
150 FOR_EACH_OBSERVER(Observer, observer_list_, OnPeripheralStateChange()); 151 FOR_EACH_OBSERVER(Observer, observer_list_, OnPeripheralStateChange());
151 152
152 if (status == RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_BIG) 153 if (cross_origin_main_content)
153 frame->WhitelistContentOrigin(content_origin); 154 frame->WhitelistContentOrigin(content_origin);
154 155
155 return; 156 return;
156 } 157 }
157 158
158 // To collect UMAs, register peripheral content even if power saver mode 159 // To collect UMAs, register peripheral content even if power saver mode
159 // is disabled. 160 // is disabled.
160 frame->RegisterPeripheralPlugin( 161 frame->RegisterPeripheralPlugin(
161 content_origin, 162 content_origin,
162 base::Bind(&PluginInstanceThrottlerImpl::MarkPluginEssential, 163 base::Bind(&PluginInstanceThrottlerImpl::MarkPluginEssential,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 215
215 // Release our reference to the underlying pixel data. 216 // Release our reference to the underlying pixel data.
216 last_received_frame_.reset(); 217 last_received_frame_.reset();
217 } 218 }
218 219
219 state_ = THROTTLER_STATE_PLUGIN_THROTTLED; 220 state_ = THROTTLER_STATE_PLUGIN_THROTTLED;
220 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange()); 221 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange());
221 } 222 }
222 223
223 } // namespace content 224 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/render_frame.h ('k') | content/renderer/pepper/plugin_power_saver_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698