Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: device/sensors/sensor_impl.cc

Issue 2078433002: [sensors] Introduce Generic Sensor API interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cap frequency to 60Hz. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698