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

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

Issue 1114623002: Plugin Power Saver: Make PPS work well with prerendered pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 7 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 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void PluginInstanceThrottlerImpl::MarkPluginEssential( 95 void PluginInstanceThrottlerImpl::MarkPluginEssential(
96 PowerSaverUnthrottleMethod method) { 96 PowerSaverUnthrottleMethod method) {
97 if (state_ == THROTTLER_STATE_MARKED_ESSENTIAL) 97 if (state_ == THROTTLER_STATE_MARKED_ESSENTIAL)
98 return; 98 return;
99 99
100 bool was_throttled = IsThrottled(); 100 bool was_throttled = IsThrottled();
101 state_ = THROTTLER_STATE_MARKED_ESSENTIAL; 101 state_ = THROTTLER_STATE_MARKED_ESSENTIAL;
102 RecordUnthrottleMethodMetric(method); 102 RecordUnthrottleMethodMetric(method);
103 103
104 if (was_throttled) 104 if (was_throttled)
105 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange()); 105 BroadcastThrottleStateChange();
106 106
107 // Notify the Power Saver test plugin of a peripheral status change. 107 // Notify the Power Saver test plugin of a peripheral status change.
108 if (web_plugin_ && web_plugin_->instance() && 108 if (web_plugin_ && web_plugin_->instance() &&
109 plugin_module_name_ == ppapi::kPowerSaverTestPluginName) { 109 plugin_module_name_ == ppapi::kPowerSaverTestPluginName) {
110 web_plugin_->instance()->HandleMessage(ppapi::ScopedPPVar( 110 web_plugin_->instance()->HandleMessage(ppapi::ScopedPPVar(
111 ppapi::ScopedPPVar::PassRef(), 111 ppapi::ScopedPPVar::PassRef(),
112 ppapi::StringVar::StringToPPVar("peripheralStatusChange"))); 112 ppapi::StringVar::StringToPPVar("peripheralStatusChange")));
113 } 113 }
114 } 114 }
115 115
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 if (!last_received_frame_.empty()) { 223 if (!last_received_frame_.empty()) {
224 FOR_EACH_OBSERVER(Observer, observer_list_, 224 FOR_EACH_OBSERVER(Observer, observer_list_,
225 OnKeyframeExtracted(&last_received_frame_)); 225 OnKeyframeExtracted(&last_received_frame_));
226 226
227 // Release our reference to the underlying pixel data. 227 // Release our reference to the underlying pixel data.
228 last_received_frame_.reset(); 228 last_received_frame_.reset();
229 } 229 }
230 230
231 state_ = THROTTLER_STATE_PLUGIN_THROTTLED; 231 state_ = THROTTLER_STATE_PLUGIN_THROTTLED;
232 BroadcastThrottleStateChange();
233 }
234
235 void PluginInstanceThrottlerImpl::BroadcastThrottleStateChange() {
232 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange()); 236 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange());
237
238 // Notify the Power Saver test plugin of a throttle status change.
239 if (web_plugin_ && web_plugin_->instance() &&
240 plugin_module_name_ == ppapi::kPowerSaverTestPluginName) {
241 web_plugin_->instance()->HandleMessage(ppapi::ScopedPPVar(
242 ppapi::ScopedPPVar::PassRef(),
243 ppapi::StringVar::StringToPPVar("throttleStatusChange")));
244 }
raymes 2015/04/29 00:12:34 It feels a little weird to have this test code in
tommycli 2015/04/29 20:25:47 Done.
233 } 245 }
234 246
235 } // namespace content 247 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698