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 <utility> |
| 8 |
| 9 namespace device { |
| 10 namespace mojom { |
| 11 |
| 12 SensorImpl::SensorImpl(mojo::InterfaceRequest<Sensor> request, |
| 13 scoped_refptr<device::PlatformSensor> sensor) |
| 14 : sensor_(std::move(sensor)), binding_(this, std::move(request)) { |
| 15 sensor_->AddClient(this); |
| 16 } |
| 17 |
| 18 SensorImpl::~SensorImpl() { |
| 19 sensor_->RemoveClient(this); |
| 20 } |
| 21 |
| 22 SensorClientRequest SensorImpl::GetClient() { |
| 23 return mojo::GetProxy(&client_); |
| 24 } |
| 25 |
| 26 void SensorImpl::AddConfiguration( |
| 27 const device::PlatformSensorConfiguration& configuration, |
| 28 const AddConfigurationCallback& callback) { |
| 29 callback.Run(sensor_->StartListening(this, configuration)); |
| 30 } |
| 31 |
| 32 void SensorImpl::RemoveConfiguration( |
| 33 const device::PlatformSensorConfiguration& configuration, |
| 34 const RemoveConfigurationCallback& callback) { |
| 35 callback.Run(sensor_->StopListening(this, configuration)); |
| 36 } |
| 37 |
| 38 void SensorImpl::OnSensorReadingChanged() { |
| 39 if (client_) |
| 40 client_->SensorReadingChanged(); |
| 41 } |
| 42 |
| 43 void SensorImpl::OnSensorError() { |
| 44 if (client_) |
| 45 client_->RaiseError(); |
| 46 } |
| 47 |
| 48 } // namespace mojom |
| 49 } // namespace device |
OLD | NEW |