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 <string> | |
9 | |
10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/timer.h" |
13 #include "content/public/browser/resource_throttle.h" | 12 #include "content/public/browser/resource_throttle.h" |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 | 15 |
17 class PowerSaveBlocker; | 16 class PowerSaveBlocker; |
18 | 17 |
19 // This ResourceThrottle blocks power save until request finishes. | 18 // This ResourceThrottle blocks power save until large upload request finishes. |
20 class PowerSaveBlockResourceThrottle : public ResourceThrottle { | 19 class PowerSaveBlockResourceThrottle : public ResourceThrottle { |
21 public: | 20 public: |
22 explicit PowerSaveBlockResourceThrottle(const std::string& reason); | 21 PowerSaveBlockResourceThrottle(); |
23 virtual ~PowerSaveBlockResourceThrottle(); | 22 virtual ~PowerSaveBlockResourceThrottle(); |
24 | 23 |
25 // ResourceThrottle override. | 24 // ResourceThrottle overrides: |
| 25 virtual void WillStartRequest(bool* defer) OVERRIDE; |
26 virtual void WillProcessResponse(bool* defer) OVERRIDE; | 26 virtual void WillProcessResponse(bool* defer) OVERRIDE; |
27 | 27 |
28 private: | 28 private: |
| 29 void ActivatePowerSaveBlocker(); |
| 30 |
| 31 base::OneShotTimer<PowerSaveBlockResourceThrottle> timer_; |
29 scoped_ptr<PowerSaveBlocker> power_save_blocker_; | 32 scoped_ptr<PowerSaveBlocker> power_save_blocker_; |
30 | 33 |
31 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockResourceThrottle); | 34 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockResourceThrottle); |
32 }; | 35 }; |
33 | 36 |
34 } // namespace content | 37 } // namespace content |
35 | 38 |
36 #endif // CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ | 39 #endif // CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ |
OLD | NEW |