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

Side by Side Diff: content/browser/wake_lock/wake_lock_service_context.h

Issue 2389743002: Content Modularization Project: Move Wake Lock to //device (Closed)
Patch Set: Eliminate frame reference Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
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_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_
6 #define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_
7
8 #include <memory>
9 #include <set>
10 #include <utility>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/sequenced_task_runner.h"
17 #include "content/browser/wake_lock/wake_lock_service_impl.h"
18 #include "content/common/content_export.h"
19 #include "mojo/public/cpp/bindings/interface_request.h"
20 #include "ui/gfx/native_widget_types.h"
21
22 namespace device {
23 class PowerSaveBlocker;
24 } // namespace device
25
26 namespace content {
27
28 class CONTENT_EXPORT WakeLockServiceContext {
29 public:
30 WakeLockServiceContext(
31 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
32 base::Callback<gfx::NativeView()> native_view_getter);
33 ~WakeLockServiceContext();
34
35 // Creates a WakeLockServiceImpl that is strongly bound to |request|.
36 void CreateService(
37 mojo::InterfaceRequest<blink::mojom::WakeLockService> request);
38
39 // Requests wake lock.
40 void RequestWakeLock();
41
42 // Cancels pending wake lock request.
43 void CancelWakeLock();
44
45 // Used by tests.
46 bool HasWakeLockForTests() const;
47
48 private:
49 void CreateWakeLock();
50 void RemoveWakeLock();
51 void UpdateWakeLock();
52
53 scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
54 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
55
56 int num_lock_requests_;
57
58 // The actual power save blocker for screen.
59 std::unique_ptr<device::PowerSaveBlocker> wake_lock_;
60 base::Callback<gfx::NativeView()> native_view_getter_;
61
62 base::WeakPtrFactory<WakeLockServiceContext> weak_factory_;
63
64 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext);
65 };
66
67 } // namespace content
68
69 #endif // CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/browser/wake_lock/wake_lock_browsertest.cc ('k') | content/browser/wake_lock/wake_lock_service_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698