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" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: | 86 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: |
87 return num_orientation_absolute_readers_; | 87 return num_orientation_absolute_readers_; |
88 case CONSUMER_TYPE_LIGHT: | 88 case CONSUMER_TYPE_LIGHT: |
89 return num_light_readers_; | 89 return num_light_readers_; |
90 default: | 90 default: |
91 NOTREACHED(); | 91 NOTREACHED(); |
92 } | 92 } |
93 return 0; | 93 return 0; |
94 } | 94 } |
95 | 95 |
96 base::SharedMemoryHandle | 96 mojo::ScopedSharedBufferHandle |
97 DeviceInertialSensorService::GetSharedMemoryHandleForProcess( | 97 DeviceInertialSensorService::GetSharedMemoryHandle(ConsumerType consumer_type) { |
98 ConsumerType consumer_type, base::ProcessHandle handle) { | |
99 DCHECK(thread_checker_.CalledOnValidThread()); | 98 DCHECK(thread_checker_.CalledOnValidThread()); |
100 return data_fetcher_->GetSharedMemoryHandleForProcess(consumer_type, handle); | 99 return data_fetcher_->GetSharedMemoryHandle(consumer_type); |
101 } | 100 } |
102 | 101 |
103 void DeviceInertialSensorService::Shutdown() { | 102 void DeviceInertialSensorService::Shutdown() { |
104 if (data_fetcher_) { | 103 if (data_fetcher_) { |
105 data_fetcher_->Shutdown(); | 104 data_fetcher_->Shutdown(); |
106 data_fetcher_.reset(); | 105 data_fetcher_.reset(); |
107 } | 106 } |
108 is_shutdown_ = true; | 107 is_shutdown_ = true; |
109 } | 108 } |
110 | 109 |
111 void DeviceInertialSensorService::SetDataFetcherForTesting( | 110 void DeviceInertialSensorService::SetDataFetcherForTesting( |
112 DataFetcherSharedMemory* test_data_fetcher) { | 111 DataFetcherSharedMemory* test_data_fetcher) { |
113 if (data_fetcher_) | 112 if (data_fetcher_) |
114 data_fetcher_->Shutdown(); | 113 data_fetcher_->Shutdown(); |
115 data_fetcher_.reset(test_data_fetcher); | 114 data_fetcher_.reset(test_data_fetcher); |
116 } | 115 } |
117 | 116 |
118 } // namespace content | 117 } // namespace content |
OLD | NEW |