Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / loader / power_save_block_resource_throttle.cc
blob42e0b0e46d87603906bff6a31d558da87fc4278a
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"
9 namespace content {
11 namespace {
13 const int kPowerSaveBlockDelaySeconds = 30;
15 } // namespace
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),
27 this,
28 &PowerSaveBlockResourceThrottle::ActivatePowerSaveBlocker);
31 void PowerSaveBlockResourceThrottle::WillProcessResponse(bool* defer) {
32 // Stop blocking power save after request finishes.
33 power_save_blocker_.reset();
34 timer_.Stop();
37 const char* PowerSaveBlockResourceThrottle::GetNameForLogging() const {
38 return "PowerSaveBlockResourceThrottle";
41 void PowerSaveBlockResourceThrottle::ActivatePowerSaveBlocker() {
42 power_save_blocker_ = PowerSaveBlocker::Create(
43 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
44 PowerSaveBlocker::kReasonOther, "Uploading data");
47 } // namespace content