| 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 { | 16 namespace content { |
| 17 |
| 17 class PowerSaveBlocker; | 18 class PowerSaveBlocker; |
| 18 } // namespace device | |
| 19 | |
| 20 namespace content { | |
| 21 | 19 |
| 22 // This ResourceThrottle blocks power save until large upload request finishes. | 20 // This ResourceThrottle blocks power save until large upload request finishes. |
| 23 class PowerSaveBlockResourceThrottle : public ResourceThrottle { | 21 class PowerSaveBlockResourceThrottle : public ResourceThrottle { |
| 24 public: | 22 public: |
| 25 explicit PowerSaveBlockResourceThrottle(const std::string& host); | 23 explicit PowerSaveBlockResourceThrottle(const std::string& host); |
| 26 ~PowerSaveBlockResourceThrottle() override; | 24 ~PowerSaveBlockResourceThrottle() override; |
| 27 | 25 |
| 28 // ResourceThrottle overrides: | 26 // ResourceThrottle overrides: |
| 29 void WillStartRequest(bool* defer) override; | 27 void WillStartRequest(bool* defer) override; |
| 30 void WillProcessResponse(bool* defer) override; | 28 void WillProcessResponse(bool* defer) override; |
| 31 const char* GetNameForLogging() const override; | 29 const char* GetNameForLogging() const override; |
| 32 | 30 |
| 33 private: | 31 private: |
| 34 void ActivatePowerSaveBlocker(); | 32 void ActivatePowerSaveBlocker(); |
| 35 | 33 |
| 36 const std::string host_; | 34 const std::string host_; |
| 37 base::OneShotTimer timer_; | 35 base::OneShotTimer timer_; |
| 38 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; | 36 std::unique_ptr<PowerSaveBlocker> power_save_blocker_; |
| 39 | 37 |
| 40 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockResourceThrottle); | 38 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockResourceThrottle); |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 } // namespace content | 41 } // namespace content |
| 44 | 42 |
| 45 #endif // CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ | 43 #endif // CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ |
| OLD | NEW |