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" |
| 10 |
9 namespace device { | 11 namespace device { |
10 | 12 |
11 SensorImpl::SensorImpl(mojo::InterfaceRequest<Sensor> request, | 13 SensorImpl::SensorImpl(scoped_refptr<PlatformSensor> sensor) |
12 scoped_refptr<PlatformSensor> sensor) | 14 : sensor_(std::move(sensor)), suspended_(false) { |
13 : sensor_(std::move(sensor)), | |
14 binding_(this, std::move(request)), | |
15 suspended_(false) { | |
16 sensor_->AddClient(this); | 15 sensor_->AddClient(this); |
17 } | 16 } |
18 | 17 |
19 SensorImpl::~SensorImpl() { | 18 SensorImpl::~SensorImpl() { |
20 sensor_->RemoveClient(this); | 19 sensor_->RemoveClient(this); |
21 } | 20 } |
22 | 21 |
23 mojom::SensorClientRequest SensorImpl::GetClient() { | 22 mojom::SensorClientRequest SensorImpl::GetClient() { |
24 return mojo::GetProxy(&client_); | 23 return mojo::GetProxy(&client_); |
25 } | 24 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DCHECK(!suspended_); | 62 DCHECK(!suspended_); |
64 if (client_) | 63 if (client_) |
65 client_->RaiseError(); | 64 client_->RaiseError(); |
66 } | 65 } |
67 | 66 |
68 bool SensorImpl::IsNotificationSuspended() { | 67 bool SensorImpl::IsNotificationSuspended() { |
69 return suspended_; | 68 return suspended_; |
70 } | 69 } |
71 | 70 |
72 } // namespace device | 71 } // namespace device |
OLD | NEW |