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

Side by Side Diff: device/sensors/data_fetcher_shared_memory_win.cc

Issue 2870263002: Rename ScopedComPtr::Receive to ScopedComPtr::GetAddressOf (Closed)
Patch Set: Rebase to 2a6f440 Created 3 years, 7 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 "device/sensors/data_fetcher_shared_memory.h" 5 #include "device/sensors/data_fetcher_shared_memory.h"
6 6
7 #include <GuidDef.h> 7 #include <GuidDef.h>
8 #include <InitGuid.h> 8 #include <InitGuid.h>
9 #include <PortableDeviceTypes.h> 9 #include <PortableDeviceTypes.h>
10 #include <Sensors.h> 10 #include <Sensors.h>
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { 228 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
229 DCHECK(buffer); 229 DCHECK(buffer);
230 230
231 switch (consumer_type) { 231 switch (consumer_type) {
232 case CONSUMER_TYPE_ORIENTATION: { 232 case CONSUMER_TYPE_ORIENTATION: {
233 orientation_buffer_ = 233 orientation_buffer_ =
234 static_cast<DeviceOrientationHardwareBuffer*>(buffer); 234 static_cast<DeviceOrientationHardwareBuffer*>(buffer);
235 scoped_refptr<SensorEventSink> sink( 235 scoped_refptr<SensorEventSink> sink(
236 new SensorEventSinkOrientation(orientation_buffer_)); 236 new SensorEventSinkOrientation(orientation_buffer_));
237 bool inclinometer_available = RegisterForSensor( 237 bool inclinometer_available =
238 SENSOR_TYPE_INCLINOMETER_3D, sensor_inclinometer_.Receive(), sink); 238 RegisterForSensor(SENSOR_TYPE_INCLINOMETER_3D,
239 sensor_inclinometer_.GetAddressOf(), sink);
239 UMA_HISTOGRAM_BOOLEAN("InertialSensor.InclinometerWindowsAvailable", 240 UMA_HISTOGRAM_BOOLEAN("InertialSensor.InclinometerWindowsAvailable",
240 inclinometer_available); 241 inclinometer_available);
241 if (inclinometer_available) 242 if (inclinometer_available)
242 return true; 243 return true;
243 // if no sensors are available set buffer to ready, to fire null-events. 244 // if no sensors are available set buffer to ready, to fire null-events.
244 SetBufferAvailableState(consumer_type, true); 245 SetBufferAvailableState(consumer_type, true);
245 } break; 246 } break;
246 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: { 247 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: {
247 orientation_absolute_buffer_ = 248 orientation_absolute_buffer_ =
248 static_cast<DeviceOrientationHardwareBuffer*>(buffer); 249 static_cast<DeviceOrientationHardwareBuffer*>(buffer);
249 scoped_refptr<SensorEventSink> sink( 250 scoped_refptr<SensorEventSink> sink(
250 new SensorEventSinkOrientation(orientation_absolute_buffer_)); 251 new SensorEventSinkOrientation(orientation_absolute_buffer_));
251 // Currently we use the same sensor as for orientation which provides 252 // Currently we use the same sensor as for orientation which provides
252 // absolute angles. 253 // absolute angles.
253 bool inclinometer_available = 254 bool inclinometer_available =
254 RegisterForSensor(SENSOR_TYPE_INCLINOMETER_3D, 255 RegisterForSensor(SENSOR_TYPE_INCLINOMETER_3D,
255 sensor_inclinometer_absolute_.Receive(), sink); 256 sensor_inclinometer_absolute_.GetAddressOf(), sink);
256 // TODO(timvolodine): consider adding UMA. 257 // TODO(timvolodine): consider adding UMA.
257 if (inclinometer_available) 258 if (inclinometer_available)
258 return true; 259 return true;
259 // if no sensors are available set buffer to ready, to fire null-events. 260 // if no sensors are available set buffer to ready, to fire null-events.
260 SetBufferAvailableState(consumer_type, true); 261 SetBufferAvailableState(consumer_type, true);
261 } break; 262 } break;
262 case CONSUMER_TYPE_MOTION: { 263 case CONSUMER_TYPE_MOTION: {
263 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); 264 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer);
264 scoped_refptr<SensorEventSink> sink( 265 scoped_refptr<SensorEventSink> sink(
265 new SensorEventSinkMotion(motion_buffer_)); 266 new SensorEventSinkMotion(motion_buffer_));
266 bool accelerometer_available = RegisterForSensor( 267 bool accelerometer_available =
267 SENSOR_TYPE_ACCELEROMETER_3D, sensor_accelerometer_.Receive(), sink); 268 RegisterForSensor(SENSOR_TYPE_ACCELEROMETER_3D,
269 sensor_accelerometer_.GetAddressOf(), sink);
268 bool gyrometer_available = RegisterForSensor( 270 bool gyrometer_available = RegisterForSensor(
269 SENSOR_TYPE_GYROMETER_3D, sensor_gyrometer_.Receive(), sink); 271 SENSOR_TYPE_GYROMETER_3D, sensor_gyrometer_.GetAddressOf(), sink);
270 UMA_HISTOGRAM_BOOLEAN("InertialSensor.AccelerometerWindowsAvailable", 272 UMA_HISTOGRAM_BOOLEAN("InertialSensor.AccelerometerWindowsAvailable",
271 accelerometer_available); 273 accelerometer_available);
272 UMA_HISTOGRAM_BOOLEAN("InertialSensor.GyrometerWindowsAvailable", 274 UMA_HISTOGRAM_BOOLEAN("InertialSensor.GyrometerWindowsAvailable",
273 gyrometer_available); 275 gyrometer_available);
274 if (accelerometer_available || gyrometer_available) { 276 if (accelerometer_available || gyrometer_available) {
275 motion_buffer_->seqlock.WriteBegin(); 277 motion_buffer_->seqlock.WriteBegin();
276 motion_buffer_->data.interval = GetInterval().InMilliseconds(); 278 motion_buffer_->data.interval = GetInterval().InMilliseconds();
277 motion_buffer_->seqlock.WriteEnd(); 279 motion_buffer_->seqlock.WriteEnd();
278 return true; 280 return true;
279 } 281 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 if (base::win::GetVersion() < base::win::VERSION_WIN7) 316 if (base::win::GetVersion() < base::win::VERSION_WIN7)
315 return false; 317 return false;
316 318
317 base::win::ScopedComPtr<ISensorManager> sensor_manager; 319 base::win::ScopedComPtr<ISensorManager> sensor_manager;
318 HRESULT hr = sensor_manager.CreateInstance(CLSID_SensorManager); 320 HRESULT hr = sensor_manager.CreateInstance(CLSID_SensorManager);
319 if (FAILED(hr) || !sensor_manager.Get()) 321 if (FAILED(hr) || !sensor_manager.Get())
320 return false; 322 return false;
321 323
322 base::win::ScopedComPtr<ISensorCollection> sensor_collection; 324 base::win::ScopedComPtr<ISensorCollection> sensor_collection;
323 hr = sensor_manager->GetSensorsByType(sensor_type, 325 hr = sensor_manager->GetSensorsByType(sensor_type,
324 sensor_collection.Receive()); 326 sensor_collection.GetAddressOf());
325 327
326 if (FAILED(hr) || !sensor_collection.Get()) 328 if (FAILED(hr) || !sensor_collection.Get())
327 return false; 329 return false;
328 330
329 ULONG count = 0; 331 ULONG count = 0;
330 hr = sensor_collection->GetCount(&count); 332 hr = sensor_collection->GetCount(&count);
331 if (FAILED(hr) || !count) 333 if (FAILED(hr) || !count)
332 return false; 334 return false;
333 335
334 hr = sensor_collection->GetAt(0, sensor); 336 hr = sensor_collection->GetAt(0, sensor);
335 if (FAILED(hr) || !(*sensor)) 337 if (FAILED(hr) || !(*sensor))
336 return false; 338 return false;
337 339
338 base::win::ScopedComPtr<IPortableDeviceValues> device_values; 340 base::win::ScopedComPtr<IPortableDeviceValues> device_values;
339 if (SUCCEEDED(device_values.CreateInstance(CLSID_PortableDeviceValues))) { 341 if (SUCCEEDED(device_values.CreateInstance(CLSID_PortableDeviceValues))) {
340 if (SUCCEEDED(device_values->SetUnsignedIntegerValue( 342 if (SUCCEEDED(device_values->SetUnsignedIntegerValue(
341 SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, 343 SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL,
342 GetInterval().InMilliseconds()))) { 344 GetInterval().InMilliseconds()))) {
343 base::win::ScopedComPtr<IPortableDeviceValues> return_values; 345 base::win::ScopedComPtr<IPortableDeviceValues> return_values;
344 (*sensor)->SetProperties(device_values.Get(), return_values.Receive()); 346 (*sensor)->SetProperties(device_values.Get(),
347 return_values.GetAddressOf());
345 } 348 }
346 } 349 }
347 350
348 base::win::ScopedComPtr<ISensorEvents> sensor_events; 351 base::win::ScopedComPtr<ISensorEvents> sensor_events;
349 hr = event_sink->QueryInterface(IID_PPV_ARGS(&sensor_events)); 352 hr = event_sink->QueryInterface(IID_PPV_ARGS(&sensor_events));
350 if (FAILED(hr) || !sensor_events.Get()) 353 if (FAILED(hr) || !sensor_events.Get())
351 return false; 354 return false;
352 355
353 hr = (*sensor)->SetEventSink(sensor_events.Get()); 356 hr = (*sensor)->SetEventSink(sensor_events.Get());
354 if (FAILED(hr)) 357 if (FAILED(hr))
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 motion_buffer_->data.all_available_sensors_are_active = enabled; 414 motion_buffer_->data.all_available_sensors_are_active = enabled;
412 motion_buffer_->seqlock.WriteEnd(); 415 motion_buffer_->seqlock.WriteEnd();
413 } 416 }
414 break; 417 break;
415 default: 418 default:
416 NOTREACHED(); 419 NOTREACHED();
417 } 420 }
418 } 421 }
419 422
420 } // namespace device 423 } // namespace device
OLDNEW
« no previous file with comments | « device/generic_sensor/platform_sensor_reader_win.cc ('k') | gpu/ipc/service/direct_composition_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698