OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_orientation/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_orientation/data_fetcher_shared_memory.h" | 10 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" |
11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 DeviceInertialSensorService::DeviceInertialSensorService() | 15 DeviceInertialSensorService::DeviceInertialSensorService() |
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 |
(...skipping 26 matching lines...) Expand all Loading... |
47 | 47 |
48 bool DeviceInertialSensorService::ChangeNumberConsumers( | 48 bool DeviceInertialSensorService::ChangeNumberConsumers( |
49 ConsumerType consumer_type, int delta) { | 49 ConsumerType consumer_type, int delta) { |
50 DCHECK(thread_checker_.CalledOnValidThread()); | 50 DCHECK(thread_checker_.CalledOnValidThread()); |
51 if (is_shutdown_) | 51 if (is_shutdown_) |
52 return false; | 52 return false; |
53 | 53 |
54 switch (consumer_type) { | 54 switch (consumer_type) { |
55 case CONSUMER_TYPE_MOTION: | 55 case CONSUMER_TYPE_MOTION: |
56 num_motion_readers_ += delta; | 56 num_motion_readers_ += delta; |
57 DCHECK(num_motion_readers_ >= 0); | 57 DCHECK_GE(num_motion_readers_, 0); |
58 return true; | 58 return true; |
59 case CONSUMER_TYPE_ORIENTATION: | 59 case CONSUMER_TYPE_ORIENTATION: |
60 num_orientation_readers_ += delta; | 60 num_orientation_readers_ += delta; |
61 DCHECK(num_orientation_readers_ >= 0); | 61 DCHECK_GE(num_orientation_readers_ , 0); |
62 return true; | 62 return true; |
63 default: | 63 default: |
64 NOTREACHED(); | 64 NOTREACHED(); |
65 } | 65 } |
66 return false; | 66 return false; |
67 } | 67 } |
68 | 68 |
69 int DeviceInertialSensorService::GetNumberConsumers( | 69 int DeviceInertialSensorService::GetNumberConsumers( |
70 ConsumerType consumer_type) const { | 70 ConsumerType consumer_type) const { |
71 switch (consumer_type) { | 71 switch (consumer_type) { |
(...skipping 18 matching lines...) Expand all Loading... |
90 data_fetcher_.reset(); | 90 data_fetcher_.reset(); |
91 is_shutdown_ = true; | 91 is_shutdown_ = true; |
92 } | 92 } |
93 | 93 |
94 void DeviceInertialSensorService::SetDataFetcherForTests( | 94 void DeviceInertialSensorService::SetDataFetcherForTests( |
95 DataFetcherSharedMemory* test_data_fetcher) { | 95 DataFetcherSharedMemory* test_data_fetcher) { |
96 data_fetcher_.reset(test_data_fetcher); | 96 data_fetcher_.reset(test_data_fetcher); |
97 } | 97 } |
98 | 98 |
99 } // namespace content | 99 } // namespace content |
OLD | NEW |