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

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

Issue 2144623003: [sensors] Introduce Generic Sensor API interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Definition for PlatformSensorProvider ctor/dtor Created 4 years, 4 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 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_
6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_
7
8 #include "base/macros.h"
9
10 #include "base/threading/non_thread_safe.h"
11 #include "device/generic_sensor/platform_sensor.h"
12
13 namespace device {
14
15 // Base class that defines factory methods for PlatformSensor creation.
16 // Its implementations must be accessed via GetInstance() method.
17 class PlatformSensorProviderBase : public base::NonThreadSafe {
18 public:
19 // Returns the PlatformSensorProviderBase singleton.
20 // Note: returns 'nullptr' if there is no available implementation for
21 // the current platform.
22 static PlatformSensorProviderBase* GetInstance();
23
24 // Creates new instance of PlatformSensor.
25 scoped_refptr<PlatformSensor> CreateSensor(mojom::SensorType type,
26 uint64_t size,
27 uint64_t offset);
28
29 // Gets previously created instance of PlatformSensor by sensor type |type|.
30 scoped_refptr<PlatformSensor> GetSensor(mojom::SensorType type);
31
32 // Shared buffer getters.
33 mojo::ScopedSharedBufferHandle CloneSharedBufferHandle();
34
35 protected:
36 PlatformSensorProviderBase();
37 virtual ~PlatformSensorProviderBase();
38
39 // Method that must be implemented by platform specific classes.
40 virtual scoped_refptr<PlatformSensor> CreateSensorInternal(
41 mojom::SensorType type,
42 mojo::ScopedSharedBufferMapping mapping,
43 uint64_t buffer_size) = 0;
44
45 private:
46 friend class PlatformSensor; // To call RemoveSensor();
47
48 bool CreateSharedBufferIfNeeded();
49 void RemoveSensor(mojom::SensorType type);
50
51 private:
52 std::map<mojom::SensorType, PlatformSensor*> sensor_map_;
53 mojo::ScopedSharedBufferHandle shared_buffer_handle_;
54
55 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase);
56 };
57
58 } // namespace device
59
60 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_
OLDNEW
« no previous file with comments | « device/generic_sensor/platform_sensor_provider.h ('k') | device/generic_sensor/platform_sensor_provider_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698