OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "device/generic_sensor/sensor_impl.h" | 5 #include "device/generic_sensor/sensor_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
10 | 10 |
11 namespace device { | 11 namespace device { |
12 | 12 |
13 SensorImpl::SensorImpl(scoped_refptr<PlatformSensor> sensor) | 13 SensorImpl::SensorImpl(scoped_refptr<PlatformSensor> sensor) |
14 : sensor_(std::move(sensor)), suspended_(false) { | 14 : sensor_(std::move(sensor)), suspended_(false) { |
15 sensor_->AddClient(this); | 15 sensor_->AddClient(this); |
16 } | 16 } |
17 | 17 |
18 SensorImpl::~SensorImpl() { | 18 SensorImpl::~SensorImpl() { |
19 sensor_->RemoveClient(this); | 19 sensor_->RemoveClient(this); |
20 } | 20 } |
21 | 21 |
22 mojom::SensorClientRequest SensorImpl::GetClient() { | 22 mojom::SensorClientRequest SensorImpl::GetClient() { |
23 return mojo::GetProxy(&client_); | 23 return mojo::MakeRequest(&client_); |
24 } | 24 } |
25 | 25 |
26 void SensorImpl::AddConfiguration( | 26 void SensorImpl::AddConfiguration( |
27 const PlatformSensorConfiguration& configuration, | 27 const PlatformSensorConfiguration& configuration, |
28 const AddConfigurationCallback& callback) { | 28 const AddConfigurationCallback& callback) { |
29 // TODO(Mikhail): To avoid overflowing browser by repeated AddConfigs | 29 // TODO(Mikhail): To avoid overflowing browser by repeated AddConfigs |
30 // (maybe limit the number of configs per client). | 30 // (maybe limit the number of configs per client). |
31 callback.Run(sensor_->StartListening(this, configuration)); | 31 callback.Run(sensor_->StartListening(this, configuration)); |
32 } | 32 } |
33 | 33 |
(...skipping 28 matching lines...) Expand all Loading... |
62 DCHECK(!suspended_); | 62 DCHECK(!suspended_); |
63 if (client_) | 63 if (client_) |
64 client_->RaiseError(); | 64 client_->RaiseError(); |
65 } | 65 } |
66 | 66 |
67 bool SensorImpl::IsNotificationSuspended() { | 67 bool SensorImpl::IsNotificationSuspended() { |
68 return suspended_; | 68 return suspended_; |
69 } | 69 } |
70 | 70 |
71 } // namespace device | 71 } // namespace device |
OLD | NEW |