OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/device_sensors/device_inertial_sensor_service.h" | 5 #include "content/browser/device_sensors/device_inertial_sensor_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" | 10 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 DeviceInertialSensorService::DeviceInertialSensorService() | 14 DeviceInertialSensorService::DeviceInertialSensorService() |
15 : num_light_readers_(0), | 15 : num_light_readers_(0), |
16 num_motion_readers_(0), | 16 num_motion_readers_(0), |
17 num_orientation_readers_(0), | 17 num_orientation_readers_(0), |
18 is_shutdown_(false) { | 18 is_shutdown_(false) { |
19 } | 19 } |
20 | 20 |
21 DeviceInertialSensorService::~DeviceInertialSensorService() { | 21 DeviceInertialSensorService::~DeviceInertialSensorService() { |
22 } | 22 } |
23 | 23 |
24 DeviceInertialSensorService* DeviceInertialSensorService::GetInstance() { | 24 DeviceInertialSensorService* DeviceInertialSensorService::GetInstance() { |
25 return Singleton<DeviceInertialSensorService, | 25 return base::Singleton< |
26 LeakySingletonTraits<DeviceInertialSensorService> >::get(); | 26 DeviceInertialSensorService, |
| 27 base::LeakySingletonTraits<DeviceInertialSensorService>>::get(); |
27 } | 28 } |
28 | 29 |
29 void DeviceInertialSensorService::AddConsumer(ConsumerType consumer_type) { | 30 void DeviceInertialSensorService::AddConsumer(ConsumerType consumer_type) { |
30 if (!ChangeNumberConsumers(consumer_type, 1)) | 31 if (!ChangeNumberConsumers(consumer_type, 1)) |
31 return; | 32 return; |
32 | 33 |
33 DCHECK(GetNumberConsumers(consumer_type)); | 34 DCHECK(GetNumberConsumers(consumer_type)); |
34 | 35 |
35 if (!data_fetcher_) | 36 if (!data_fetcher_) |
36 data_fetcher_.reset(new DataFetcherSharedMemory); | 37 data_fetcher_.reset(new DataFetcherSharedMemory); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 102 } |
102 | 103 |
103 void DeviceInertialSensorService::SetDataFetcherForTesting( | 104 void DeviceInertialSensorService::SetDataFetcherForTesting( |
104 DataFetcherSharedMemory* test_data_fetcher) { | 105 DataFetcherSharedMemory* test_data_fetcher) { |
105 if (data_fetcher_) | 106 if (data_fetcher_) |
106 data_fetcher_->Shutdown(); | 107 data_fetcher_->Shutdown(); |
107 data_fetcher_.reset(test_data_fetcher); | 108 data_fetcher_.reset(test_data_fetcher); |
108 } | 109 } |
109 | 110 |
110 } // namespace content | 111 } // namespace content |
OLD | NEW |