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

Side by Side Diff: device/wake_lock/wake_lock_service_context.h

Issue 2867303003: Generalize the API of WakeLockContext mojo interface. (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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ 5 #ifndef DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_
6 #define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ 6 #define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "device/wake_lock/public/interfaces/wake_lock_context.mojom.h" 14 #include "device/wake_lock/public/interfaces/wake_lock_context.mojom.h"
15 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
16 16
17 namespace device { 17 namespace device {
18 18
19 class PowerSaveBlocker;
20
19 // Callback that maps a context ID to the NativeView associated with 21 // Callback that maps a context ID to the NativeView associated with
20 // that context. This callback is provided to the Device Service by its 22 // that context. This callback is provided to the Device Service by its
21 // embedder. 23 // embedder.
22 using WakeLockContextCallback = base::Callback<gfx::NativeView(int)>; 24 using WakeLockContextCallback = base::Callback<gfx::NativeView(int)>;
23 25
24 // Serves requests for WakeLockService connections within a given context. 26 // Serves requests for WakeLockService connections within a given context.
25 class WakeLockServiceContext : public mojom::WakeLockContext { 27 class WakeLockServiceContext : public mojom::WakeLockContext {
26 public: 28 public:
27 WakeLockServiceContext( 29 WakeLockServiceContext(
28 int context_id, 30 int context_id,
29 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, 31 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
30 const WakeLockContextCallback& native_view_getter); 32 const WakeLockContextCallback& native_view_getter);
31 ~WakeLockServiceContext() override; 33 ~WakeLockServiceContext() override;
32 34
33 // mojom::WakeLockContext: 35 // mojom::WakeLockContext:
34 void GetWakeLock(mojom::WakeLockServiceRequest request) override; 36 void GetWakeLock(device::PowerSaveBlocker::PowerSaveBlockerType type,
37 device::PowerSaveBlocker::Reason reason,
38 const std::string& description,
39 mojom::WakeLockServiceRequest request) override;
35 40
36 private: 41 private:
37 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 42 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
38 int context_id_; 43 int context_id_;
39 WakeLockContextCallback native_view_getter_; 44 WakeLockContextCallback native_view_getter_;
40 45
41 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext); 46 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext);
42 }; 47 };
43 48
44 } // namespace device 49 } // namespace device
45 50
46 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ 51 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698