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

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

Issue 2370343002: [sensors] Ambient light sensor implementation for ChromeOS and Linux. (Closed)
Patch Set: rebased on top of Mihail's cl Created 4 years, 2 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_provider_base.h" 5 #include "device/generic_sensor/platform_sensor_provider_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h" 10 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (shared_buffer_handle_.is_valid()) 69 if (shared_buffer_handle_.is_valid())
70 return true; 70 return true;
71 71
72 shared_buffer_handle_ = 72 shared_buffer_handle_ =
73 mojo::SharedBufferHandle::Create(kSharedBufferSizeInBytes); 73 mojo::SharedBufferHandle::Create(kSharedBufferSizeInBytes);
74 return shared_buffer_handle_.is_valid(); 74 return shared_buffer_handle_.is_valid();
75 } 75 }
76 76
77 void PlatformSensorProviderBase::RemoveSensor(mojom::SensorType type) { 77 void PlatformSensorProviderBase::RemoveSensor(mojom::SensorType type) {
78 DCHECK(CalledOnValidThread()); 78 DCHECK(CalledOnValidThread());
79 DCHECK(ContainsKey(sensor_map_, type)); 79 if (ContainsKey(sensor_map_, type))
80 sensor_map_.erase(type); 80 sensor_map_.erase(type);
81 81
82 if (sensor_map_.empty()) 82 if (sensor_map_.empty())
83 shared_buffer_handle_.reset(); 83 shared_buffer_handle_.reset();
84 } 84 }
85 85
86 mojo::ScopedSharedBufferHandle 86 mojo::ScopedSharedBufferHandle
87 PlatformSensorProviderBase::CloneSharedBufferHandle() { 87 PlatformSensorProviderBase::CloneSharedBufferHandle() {
88 DCHECK(CalledOnValidThread()); 88 DCHECK(CalledOnValidThread());
89 CreateSharedBufferIfNeeded(); 89 CreateSharedBufferIfNeeded();
90 return shared_buffer_handle_->Clone(); 90 return shared_buffer_handle_->Clone();
(...skipping 19 matching lines...) Expand all
110 } 110 }
111 111
112 uint64_t PlatformSensorProviderBase::GetSharedBufferOffset( 112 uint64_t PlatformSensorProviderBase::GetSharedBufferOffset(
113 mojom::SensorType type) { 113 mojom::SensorType type) {
114 return (static_cast<uint64_t>(mojom::SensorType::LAST) - 114 return (static_cast<uint64_t>(mojom::SensorType::LAST) -
115 static_cast<uint64_t>(type)) * 115 static_cast<uint64_t>(type)) *
116 kReadingBufferSize; 116 kReadingBufferSize;
117 } 117 }
118 118
119 } // namespace device 119 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698