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

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: Forgot some light bits removal from device_inertial_sensor_diagnostics.html 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 102
100 // --- end of PollingThread methods 103 // --- end of PollingThread methods
101 104
102 DataFetcherSharedMemoryBase::DataFetcherSharedMemoryBase() 105 DataFetcherSharedMemoryBase::DataFetcherSharedMemoryBase()
103 : started_consumers_(0) { 106 : started_consumers_(0) {
104 } 107 }
105 108
106 DataFetcherSharedMemoryBase::~DataFetcherSharedMemoryBase() { 109 DataFetcherSharedMemoryBase::~DataFetcherSharedMemoryBase() {
107 StopFetchingDeviceData(CONSUMER_TYPE_MOTION); 110 StopFetchingDeviceData(CONSUMER_TYPE_MOTION);
108 StopFetchingDeviceData(CONSUMER_TYPE_ORIENTATION); 111 StopFetchingDeviceData(CONSUMER_TYPE_ORIENTATION);
112 StopFetchingDeviceData(CONSUMER_TYPE_LIGHT);
109 113
110 // make sure polling thread stops asap. 114 // make sure polling thread stops asap.
111 if (polling_thread_) 115 if (polling_thread_)
112 polling_thread_->Stop(); 116 polling_thread_->Stop();
113 117
114 STLDeleteContainerPairSecondPointers(shared_memory_map_.begin(), 118 STLDeleteContainerPairSecondPointers(shared_memory_map_.begin(),
115 shared_memory_map_.end()); 119 shared_memory_map_.end());
116 } 120 }
117 121
118 bool DataFetcherSharedMemoryBase::StartFetchingDeviceData( 122 bool DataFetcherSharedMemoryBase::StartFetchingDeviceData(
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 base::MessageLoop* DataFetcherSharedMemoryBase::GetPollingMessageLoop() const { 239 base::MessageLoop* DataFetcherSharedMemoryBase::GetPollingMessageLoop() const {
236 return polling_thread_ ? polling_thread_->message_loop() : NULL; 240 return polling_thread_ ? polling_thread_->message_loop() : NULL;
237 } 241 }
238 242
239 bool DataFetcherSharedMemoryBase::IsPollingTimerRunningForTesting() const { 243 bool DataFetcherSharedMemoryBase::IsPollingTimerRunningForTesting() const {
240 return polling_thread_ ? polling_thread_->IsTimerRunning() : false; 244 return polling_thread_ ? polling_thread_->IsTimerRunning() : false;
241 } 245 }
242 246
243 247
244 } // namespace content 248 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698