OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "device/sensors/sensor_impl.h" | |
6 | |
7 #include "device/sensors/platform_sensor_configuration.h" | |
8 #include "device/sensors/sensor_type_converters.h" | |
9 | |
10 namespace device { | |
11 namespace mojom { | |
12 | |
13 SensorImpl::SensorImpl(mojo::InterfaceRequest<Sensor> request, | |
14 scoped_refptr<device::PlatformSensor> sensor) | |
15 : sensor_(sensor), binding_(this, std::move(request)) { | |
dcheng
2016/07/01 09:17:24
Nit: std::move(sensor)
shalamov
2016/07/01 14:22:47
Done.
| |
16 sensor_->AddClient(this); | |
17 } | |
18 | |
19 SensorImpl::~SensorImpl() { | |
20 sensor_->RemoveClient(this); | |
21 } | |
22 | |
23 SensorClientRequest SensorImpl::GetClient() { | |
24 return mojo::GetProxy(&client_); | |
25 } | |
26 | |
27 void SensorImpl::AddConfiguration(SensorConfigurationPtr configuration, | |
28 const AddConfigurationCallback& callback) { | |
29 callback.Run(sensor_->StartListening( | |
30 this, configuration.To<device::PlatformSensorConfiguration>())); | |
31 } | |
32 | |
33 void SensorImpl::RemoveConfiguration( | |
34 SensorConfigurationPtr configuration, | |
35 const RemoveConfigurationCallback& callback) { | |
36 callback.Run(sensor_->StopListening( | |
37 this, configuration.To<device::PlatformSensorConfiguration>())); | |
38 } | |
39 | |
40 void SensorImpl::OnSensorReadingChanged() { | |
41 if (client_) | |
42 client_->SensorReadingChanged(); | |
43 } | |
44 | |
45 void SensorImpl::OnSensorError() { | |
46 if (client_) | |
47 client_->RaiseError(); | |
48 } | |
49 | |
50 } // namespace mojom | |
51 } // namespace device | |
OLD | NEW |