Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: content/browser/loader/wake_lock_resource_throttle.h

Issue 2893873002: Convert PowerSaveBlockResourceThrottle to be client of WakeLock mojo service. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..7df7d0ab33e39f160ad2b1b18340e2421eb1fcea
--- /dev/null
+++ b/content/browser/loader/wake_lock_resource_throttle.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
Charlie Harrison 2017/05/18 13:56:42 Copyright 2017
+// 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 ActivateWakeLock();
+
+ const std::string host_;
+ base::OneShotTimer timer_;
+ device::mojom::WakeLockServicePtr wake_lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(WakeLockResourceThrottle);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_

Powered by Google App Engine
This is Rietveld 408576698