| OLD | NEW |
| 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_CONTEXT_H_ |
| 6 #define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | 6 #define DEVICE_WAKE_LOCK_WAKE_LOCK_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 // Callback that maps a context ID to the NativeView associated with | 19 // Callback that maps a context ID to the NativeView associated with |
| 20 // that context. This callback is provided to the Device Service by its | 20 // that context. This callback is provided to the Device Service by its |
| 21 // embedder. | 21 // embedder. |
| 22 using WakeLockContextCallback = base::Callback<gfx::NativeView(int)>; | 22 using WakeLockContextCallback = base::Callback<gfx::NativeView(int)>; |
| 23 | 23 |
| 24 // Serves requests for WakeLockService connections within a given context. | 24 // Serves requests for WakeLock connections within a given context. |
| 25 class WakeLockServiceContext : public mojom::WakeLockContext { | 25 class WakeLockContext : public mojom::WakeLockContext { |
| 26 public: | 26 public: |
| 27 WakeLockServiceContext( | 27 WakeLockContext(int context_id, |
| 28 int context_id, | 28 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
| 29 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, | 29 const WakeLockContextCallback& native_view_getter); |
| 30 const WakeLockContextCallback& native_view_getter); | 30 ~WakeLockContext() override; |
| 31 ~WakeLockServiceContext() override; | |
| 32 | 31 |
| 33 // mojom::WakeLockContext: | 32 // mojom::WakeLockContext: |
| 34 void GetWakeLock(mojom::WakeLockType type, | 33 void GetWakeLock(mojom::WakeLockType type, |
| 35 mojom::WakeLockReason reason, | 34 mojom::WakeLockReason reason, |
| 36 const std::string& description, | 35 const std::string& description, |
| 37 mojom::WakeLockServiceRequest request) override; | 36 mojom::WakeLockRequest request) override; |
| 38 | 37 |
| 39 static const int WakeLockInvalidContextId; | 38 static const int WakeLockInvalidContextId; |
| 40 | 39 |
| 41 private: | 40 private: |
| 42 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | 41 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
| 43 int context_id_; | 42 int context_id_; |
| 44 WakeLockContextCallback native_view_getter_; | 43 WakeLockContextCallback native_view_getter_; |
| 45 | 44 |
| 46 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext); | 45 DISALLOW_COPY_AND_ASSIGN(WakeLockContext); |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 } // namespace device | 48 } // namespace device |
| 50 | 49 |
| 51 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | 50 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_CONTEXT_H_ |
| OLD | NEW |