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

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

Issue 2893873002: Convert PowerSaveBlockResourceThrottle to be client of WakeLock mojo service. (Closed)
Patch Set: Convert PowerSaveBlockResourceThrottle to be client of WakeLock mojo service. 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..1bef48cfe39b23691482ca25eae1ea956ef2bdd6
--- /dev/null
+++ b/content/browser/loader/wake_lock_resource_throttle.h
@@ -0,0 +1,46 @@
+// 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
+ // WakeLockServicImpl::OnConnectionError on the service side, so there is no
+ // need to call CancelWakeLock() in the destructor.
+ device::mojom::WakeLockServicePtr wake_lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(WakeLockResourceThrottle);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/browser/loader/wake_lock_resource_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698