OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <stdint.h> | 5 #include <stdint.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
| 8 #include "base/memory/ptr_util.h" |
8 #include "device/vibration/vibration_manager_impl.h" | 9 #include "device/vibration/vibration_manager_impl.h" |
9 #include "mojo/public/cpp/bindings/strong_binding.h" | 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
10 | 11 |
11 namespace device { | 12 namespace device { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 class VibrationManagerEmptyImpl : public VibrationManager { | 16 class VibrationManagerEmptyImpl : public VibrationManager { |
16 public: | 17 public: |
| 18 VibrationManagerEmptyImpl() {} |
| 19 ~VibrationManagerEmptyImpl() override {} |
| 20 |
17 void Vibrate(int64_t milliseconds, const VibrateCallback& callback) override { | 21 void Vibrate(int64_t milliseconds, const VibrateCallback& callback) override { |
18 callback.Run(); | 22 callback.Run(); |
19 } | 23 } |
20 | 24 |
21 void Cancel(const CancelCallback& callback) override { callback.Run(); } | 25 void Cancel(const CancelCallback& callback) override { callback.Run(); } |
22 | |
23 private: | |
24 friend VibrationManagerImpl; | |
25 | |
26 explicit VibrationManagerEmptyImpl( | |
27 mojo::InterfaceRequest<VibrationManager> request) | |
28 : binding_(this, std::move(request)) {} | |
29 ~VibrationManagerEmptyImpl() override {} | |
30 | |
31 // The binding between this object and the other end of the pipe. | |
32 mojo::StrongBinding<VibrationManager> binding_; | |
33 }; | 26 }; |
34 | 27 |
35 } // namespace | 28 } // namespace |
36 | 29 |
37 // static | 30 // static |
38 void VibrationManagerImpl::Create( | 31 void VibrationManagerImpl::Create(VibrationManagerRequest request) { |
39 mojo::InterfaceRequest<VibrationManager> request) { | 32 mojo::MakeStrongBinding(base::MakeUnique<VibrationManagerEmptyImpl>(), |
40 new VibrationManagerEmptyImpl(std::move(request)); | 33 std::move(request)); |
41 } | 34 } |
42 | 35 |
43 } // namespace device | 36 } // namespace device |
OLD | NEW |