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

Side by Side Diff: content/browser/device_orientation/data_fetcher_shared_memory_mac.cc

Issue 23441047: Fix race condition in DataFetcherSharedMemoryBase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 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 "data_fetcher_shared_memory.h" 5 #include "data_fetcher_shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/sudden_motion_sensor/sudden_motion_sensor_mac.h" 8 #include "third_party/sudden_motion_sensor/sudden_motion_sensor_mac.h"
9 9
10 namespace { 10 namespace {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (consumer_bitmask & CONSUMER_TYPE_ORIENTATION) 108 if (consumer_bitmask & CONSUMER_TYPE_ORIENTATION)
109 FetchOrientation(sudden_motion_sensor_.get(), orientation_buffer_); 109 FetchOrientation(sudden_motion_sensor_.get(), orientation_buffer_);
110 if (consumer_bitmask & CONSUMER_TYPE_MOTION) 110 if (consumer_bitmask & CONSUMER_TYPE_MOTION)
111 FetchMotion(sudden_motion_sensor_.get(), motion_buffer_); 111 FetchMotion(sudden_motion_sensor_.get(), motion_buffer_);
112 } 112 }
113 113
114 bool DataFetcherSharedMemory::IsPolling() const { 114 bool DataFetcherSharedMemory::IsPolling() const {
115 return true; 115 return true;
116 } 116 }
117 117
118 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type) { 118 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
119 DCHECK(base::MessageLoop::current() == GetPollingMessageLoop()); 119 DCHECK(base::MessageLoop::current() == GetPollingMessageLoop());
120
121 void* buffer = GetSharedMemoryBuffer(consumer_type);
122 DCHECK(buffer); 120 DCHECK(buffer);
123 121
124 switch (consumer_type) { 122 switch (consumer_type) {
125 case CONSUMER_TYPE_MOTION: 123 case CONSUMER_TYPE_MOTION:
126 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); 124 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer);
127 if (!sudden_motion_sensor_) 125 if (!sudden_motion_sensor_)
128 sudden_motion_sensor_.reset(SuddenMotionSensor::Create()); 126 sudden_motion_sensor_.reset(SuddenMotionSensor::Create());
129 return true; 127 return true;
130 case CONSUMER_TYPE_ORIENTATION: 128 case CONSUMER_TYPE_ORIENTATION:
131 orientation_buffer_ = 129 orientation_buffer_ =
(...skipping 27 matching lines...) Expand all
159 orientation_buffer_ = NULL; 157 orientation_buffer_ = NULL;
160 } 158 }
161 return true; 159 return true;
162 default: 160 default:
163 NOTREACHED(); 161 NOTREACHED();
164 } 162 }
165 return false; 163 return false;
166 } 164 }
167 165
168 } // namespace content 166 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/device_orientation/data_fetcher_shared_memory_default.cc ('k') | tools/valgrind/tsan/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698