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

Side by Side Diff: content/browser/device_sensors/data_fetcher_shared_memory_base.cc

Issue 292693004: [DeviceLight] Browser+java part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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
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/data_fetcher_shared_memory_base.h" 5 #include "content/browser/device_sensors/data_fetcher_shared_memory_base.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/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "content/common/device_sensors/device_light_hardware_buffer.h"
12 #include "content/common/device_sensors/device_motion_hardware_buffer.h" 13 #include "content/common/device_sensors/device_motion_hardware_buffer.h"
13 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" 14 #include "content/common/device_sensors/device_orientation_hardware_buffer.h"
14 15
15 namespace content { 16 namespace content {
16 17
17 namespace { 18 namespace {
18 19
19 static size_t GetConsumerSharedMemoryBufferSize(ConsumerType consumer_type) { 20 static size_t GetConsumerSharedMemoryBufferSize(ConsumerType consumer_type) {
20 switch (consumer_type) { 21 switch (consumer_type) {
21 case CONSUMER_TYPE_MOTION: 22 case CONSUMER_TYPE_MOTION:
22 return sizeof(DeviceMotionHardwareBuffer); 23 return sizeof(DeviceMotionHardwareBuffer);
23 case CONSUMER_TYPE_ORIENTATION: 24 case CONSUMER_TYPE_ORIENTATION:
24 return sizeof(DeviceOrientationHardwareBuffer); 25 return sizeof(DeviceOrientationHardwareBuffer);
26 case CONSUMER_TYPE_LIGHT:
27 return sizeof(DeviceLightHardwareBuffer);
25 default: 28 default:
26 NOTREACHED(); 29 NOTREACHED();
27 } 30 }
28 return 0; 31 return 0;
29 } 32 }
30 33
31 } // namespace 34 } // namespace
32 35
33 class DataFetcherSharedMemoryBase::PollingThread : public base::Thread { 36 class DataFetcherSharedMemoryBase::PollingThread : public base::Thread {
34 public: 37 public:
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 161 }
159 162
160 started_consumers_ ^= consumer_type; 163 started_consumers_ ^= consumer_type;
161 164
162 return true; 165 return true;
163 } 166 }
164 167
165 void DataFetcherSharedMemoryBase::StopFetchingAllDeviceData() { 168 void DataFetcherSharedMemoryBase::StopFetchingAllDeviceData() {
166 StopFetchingDeviceData(CONSUMER_TYPE_MOTION); 169 StopFetchingDeviceData(CONSUMER_TYPE_MOTION);
167 StopFetchingDeviceData(CONSUMER_TYPE_ORIENTATION); 170 StopFetchingDeviceData(CONSUMER_TYPE_ORIENTATION);
171 StopFetchingDeviceData(CONSUMER_TYPE_LIGHT);
168 } 172 }
169 173
170 base::SharedMemoryHandle 174 base::SharedMemoryHandle
171 DataFetcherSharedMemoryBase::GetSharedMemoryHandleForProcess( 175 DataFetcherSharedMemoryBase::GetSharedMemoryHandleForProcess(
172 ConsumerType consumer_type, base::ProcessHandle process) { 176 ConsumerType consumer_type, base::ProcessHandle process) {
173 SharedMemoryMap::const_iterator it = shared_memory_map_.find(consumer_type); 177 SharedMemoryMap::const_iterator it = shared_memory_map_.find(consumer_type);
174 if (it == shared_memory_map_.end()) 178 if (it == shared_memory_map_.end())
175 return base::SharedMemory::NULLHandle(); 179 return base::SharedMemory::NULLHandle();
176 180
177 base::SharedMemoryHandle renderer_handle; 181 base::SharedMemoryHandle renderer_handle;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 242
239 base::MessageLoop* DataFetcherSharedMemoryBase::GetPollingMessageLoop() const { 243 base::MessageLoop* DataFetcherSharedMemoryBase::GetPollingMessageLoop() const {
240 return polling_thread_ ? polling_thread_->message_loop() : NULL; 244 return polling_thread_ ? polling_thread_->message_loop() : NULL;
241 } 245 }
242 246
243 bool DataFetcherSharedMemoryBase::IsPollingTimerRunningForTesting() const { 247 bool DataFetcherSharedMemoryBase::IsPollingTimerRunningForTesting() const {
244 return polling_thread_ ? polling_thread_->IsTimerRunning() : false; 248 return polling_thread_ ? polling_thread_->IsTimerRunning() : false;
245 } 249 }
246 250
247 } // namespace content 251 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698