OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ |
6 #define CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ | 6 #define CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "content/public/browser/resource_throttle.h" | 14 #include "content/public/browser/resource_throttle.h" |
15 | 15 |
| 16 namespace device { |
| 17 class PowerSaveBlocker; |
| 18 } // namespace device |
| 19 |
16 namespace content { | 20 namespace content { |
17 | 21 |
18 class PowerSaveBlocker; | |
19 | |
20 // This ResourceThrottle blocks power save until large upload request finishes. | 22 // This ResourceThrottle blocks power save until large upload request finishes. |
21 class PowerSaveBlockResourceThrottle : public ResourceThrottle { | 23 class PowerSaveBlockResourceThrottle : public ResourceThrottle { |
22 public: | 24 public: |
23 explicit PowerSaveBlockResourceThrottle(const std::string& host); | 25 explicit PowerSaveBlockResourceThrottle(const std::string& host); |
24 ~PowerSaveBlockResourceThrottle() override; | 26 ~PowerSaveBlockResourceThrottle() override; |
25 | 27 |
26 // ResourceThrottle overrides: | 28 // ResourceThrottle overrides: |
27 void WillStartRequest(bool* defer) override; | 29 void WillStartRequest(bool* defer) override; |
28 void WillProcessResponse(bool* defer) override; | 30 void WillProcessResponse(bool* defer) override; |
29 const char* GetNameForLogging() const override; | 31 const char* GetNameForLogging() const override; |
30 | 32 |
31 private: | 33 private: |
32 void ActivatePowerSaveBlocker(); | 34 void ActivatePowerSaveBlocker(); |
33 | 35 |
34 const std::string host_; | 36 const std::string host_; |
35 base::OneShotTimer timer_; | 37 base::OneShotTimer timer_; |
36 std::unique_ptr<PowerSaveBlocker> power_save_blocker_; | 38 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; |
37 | 39 |
38 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockResourceThrottle); | 40 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockResourceThrottle); |
39 }; | 41 }; |
40 | 42 |
41 } // namespace content | 43 } // namespace content |
42 | 44 |
43 #endif // CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ | 45 #endif // CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ |
OLD | NEW |