Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
|
Charlie Harrison
2017/05/18 13:56:42
Copyright 2017
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_ | |
| 6 #define CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/timer/timer.h" | |
| 14 #include "content/public/browser/resource_throttle.h" | |
| 15 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 // This ResourceThrottle holds wake lock until large upload request finishes. | |
| 20 class WakeLockResourceThrottle : public ResourceThrottle { | |
| 21 public: | |
| 22 WakeLockResourceThrottle(const std::string& host); | |
| 23 ~WakeLockResourceThrottle() override; | |
| 24 | |
| 25 // ResourceThrottle overrides: | |
| 26 void WillStartRequest(bool* defer) override; | |
| 27 void WillProcessResponse(bool* defer) override; | |
| 28 const char* GetNameForLogging() const override; | |
| 29 | |
| 30 private: | |
| 31 void ActivateWakeLock(); | |
| 32 | |
| 33 const std::string host_; | |
| 34 base::OneShotTimer timer_; | |
| 35 device::mojom::WakeLockServicePtr wake_lock_; | |
| 36 | |
| 37 DISALLOW_COPY_AND_ASSIGN(WakeLockResourceThrottle); | |
| 38 }; | |
| 39 | |
| 40 } // namespace content | |
| 41 | |
| 42 #endif // CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_ | |
| OLD | NEW |