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

Side by Side Diff: device/generic_sensor/platform_sensor_reader_win.cc

Issue 2887243002: Remove ScopedComPtr::CreateInstance() (Closed)
Patch Set: 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/generic_sensor/platform_sensor_reader_win.h" 5 #include "device/generic_sensor/platform_sensor_reader_win.h"
6 6
7 #include <Sensors.h> 7 #include <Sensors.h>
8 #include <objbase.h>
8 9
9 #include "base/callback.h" 10 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
11 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "base/win/iunknown_impl.h" 14 #include "base/win/iunknown_impl.h"
14 #include "base/win/scoped_propvariant.h" 15 #include "base/win/scoped_propvariant.h"
15 #include "device/generic_sensor/generic_sensor_consts.h" 16 #include "device/generic_sensor/generic_sensor_consts.h"
16 #include "device/generic_sensor/public/cpp/platform_sensor_configuration.h" 17 #include "device/generic_sensor/public/cpp/platform_sensor_configuration.h"
17 #include "device/generic_sensor/public/cpp/sensor_reading.h" 18 #include "device/generic_sensor/public/cpp/sensor_reading.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // Set event listener. 424 // Set event listener.
424 if (FAILED(sensor_->SetEventSink(event_listener_.get()))) { 425 if (FAILED(sensor_->SetEventSink(event_listener_.get()))) {
425 SensorError(); 426 SensorError();
426 StopSensor(); 427 StopSensor();
427 } 428 }
428 } 429 }
429 430
430 bool PlatformSensorReaderWin::SetReportingInterval( 431 bool PlatformSensorReaderWin::SetReportingInterval(
431 const PlatformSensorConfiguration& configuration) { 432 const PlatformSensorConfiguration& configuration) {
432 base::win::ScopedComPtr<IPortableDeviceValues> props; 433 base::win::ScopedComPtr<IPortableDeviceValues> props;
433 if (SUCCEEDED(props.CreateInstance(CLSID_PortableDeviceValues))) { 434 if (SUCCEEDED(::CoCreateInstance(CLSID_PortableDeviceValues, nullptr,
435 CLSCTX_ALL, IID_PPV_ARGS(&props)))) {
434 unsigned interval = 436 unsigned interval =
435 (1 / configuration.frequency()) * base::Time::kMillisecondsPerSecond; 437 (1 / configuration.frequency()) * base::Time::kMillisecondsPerSecond;
436 438
437 HRESULT hr = props->SetUnsignedIntegerValue( 439 HRESULT hr = props->SetUnsignedIntegerValue(
438 SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, interval); 440 SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, interval);
439 441
440 if (SUCCEEDED(hr)) { 442 if (SUCCEEDED(hr)) {
441 base::win::ScopedComPtr<IPortableDeviceValues> return_props; 443 base::win::ScopedComPtr<IPortableDeviceValues> return_props;
442 hr = sensor_->SetProperties(props.Get(), return_props.GetAddressOf()); 444 hr = sensor_->SetProperties(props.Get(), return_props.GetAddressOf());
443 return SUCCEEDED(hr); 445 return SUCCEEDED(hr);
(...skipping 17 matching lines...) Expand all
461 void PlatformSensorReaderWin::SensorError() { 463 void PlatformSensorReaderWin::SensorError() {
462 if (client_) 464 if (client_)
463 client_->OnSensorError(); 465 client_->OnSensorError();
464 } 466 }
465 467
466 unsigned long PlatformSensorReaderWin::GetMinimalReportingIntervalMs() const { 468 unsigned long PlatformSensorReaderWin::GetMinimalReportingIntervalMs() const {
467 return init_params_->min_reporting_interval_ms; 469 return init_params_->min_reporting_interval_ms;
468 } 470 }
469 471
470 } // namespace device 472 } // namespace device
OLDNEW
« no previous file with comments | « device/generic_sensor/platform_sensor_provider_win.cc ('k') | device/sensors/data_fetcher_shared_memory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698