1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/loader/power_save_block_resource_throttle.h"
7 #include "content/public/browser/power_save_blocker.h"
13 const int kPowerSaveBlockDelaySeconds
= 30;
17 PowerSaveBlockResourceThrottle::PowerSaveBlockResourceThrottle() {
20 PowerSaveBlockResourceThrottle::~PowerSaveBlockResourceThrottle() {
23 void PowerSaveBlockResourceThrottle::WillStartRequest(bool* defer
) {
24 // Delay PowerSaveBlocker activation to dismiss small requests.
25 timer_
.Start(FROM_HERE
,
26 base::TimeDelta::FromSeconds(kPowerSaveBlockDelaySeconds
),
28 &PowerSaveBlockResourceThrottle::ActivatePowerSaveBlocker
);
31 void PowerSaveBlockResourceThrottle::WillProcessResponse(bool* defer
) {
32 // Stop blocking power save after request finishes.
33 power_save_blocker_
.reset();
37 const char* PowerSaveBlockResourceThrottle::GetNameForLogging() const {
38 return "PowerSaveBlockResourceThrottle";
41 void PowerSaveBlockResourceThrottle::ActivatePowerSaveBlocker() {
42 power_save_blocker_
= PowerSaveBlocker::Create(
43 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension
,
47 } // namespace content