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

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

Issue 2332903002: [sensors] [mac] Implement ambient light sensor for macOS (Closed)
Patch Set: Created 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "device/generic_sensor/platform_sensor_polling_mac.h"
6
7 #include "device/generic_sensor/platform_sensor_mac.h"
8
9 namespace device {
10
11 SensorsPollingThreadMac::SensorsPollingThreadMac(const char* name)
12 : base::Thread(name) {}
13
14 SensorsPollingThreadMac::~SensorsPollingThreadMac() = default;
15
16 void SensorsPollingThreadMac::BeginPollingSensor(
17 PlatformSensorMac* sensor,
18 const PlatformSensorConfiguration& configuration) {
19 auto it = sensors_.find(sensor);
20 if (it != sensors_.end())
21 return;
22
23 std::unique_ptr<base::RepeatingTimer> timer(new base::RepeatingTimer);
24 timer->Start(FROM_HERE, base::TimeDelta::FromMicroseconds(
25 base::Time::kMicrosecondsPerSecond /
26 configuration.frequency()),
27 sensor, &PlatformSensorMac::UpdateReading);
28 sensors_.insert({sensor, std::move(timer)});
29 }
30
31 void SensorsPollingThreadMac::StopPollingSensor(PlatformSensorMac* sensor) {
32 auto it = sensors_.find(sensor);
33 if (it == sensors_.end())
34 return;
35
36 it->second.reset();
37 sensors_.erase(it);
38 }
39
40 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698