Index: content/browser/loader/wake_lock_resource_throttle.h |
diff --git a/content/browser/loader/wake_lock_resource_throttle.h b/content/browser/loader/wake_lock_resource_throttle.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4b2ec58e90f67dbed732989b76e49006e962dd7b |
--- /dev/null |
+++ b/content/browser/loader/wake_lock_resource_throttle.h |
@@ -0,0 +1,47 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_ |
+#define CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_ |
+ |
+#include <memory> |
+#include <string> |
+ |
+#include "base/compiler_specific.h" |
+#include "base/macros.h" |
+#include "base/timer/timer.h" |
+#include "content/public/browser/resource_throttle.h" |
+#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" |
+ |
+namespace content { |
+ |
+// This ResourceThrottle holds wake lock until large upload request finishes. |
+class WakeLockResourceThrottle : public ResourceThrottle { |
+ public: |
+ WakeLockResourceThrottle(const std::string& host); |
+ ~WakeLockResourceThrottle() override; |
+ |
+ // ResourceThrottle overrides: |
+ void WillStartRequest(bool* defer) override; |
+ void WillProcessResponse(bool* defer) override; |
+ const char* GetNameForLogging() const override; |
+ |
+ private: |
+ void RequestWakeLock(); |
+ |
+ const std::string host_; |
+ base::OneShotTimer timer_; |
+ |
+ // Destruction of wake_lock_ will trigger |
Charlie Harrison
2017/05/18 16:43:49
Suggested rephrasing:
Destruction of wake_lock_ wi
ke.he
2017/05/19 03:35:52
Done.
|
+ // WakeLockServicImpl::OnConnectionError in remote Device Service side, in |
+ // which the wake lock is well updated. So no need to call CancelWakeLock() in |
+ // destructor of this class. |
+ device::mojom::WakeLockServicePtr wake_lock_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WakeLockResourceThrottle); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_ |