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

Side by Side Diff: content/browser/device_sensors/device_inertial_sensor_service.h

Issue 2037513002: Convert device_sensors to use mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@conversion--mime-registry
Patch Set: rebase Created 4 years, 5 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 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_ 5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_
6 #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_ 6 #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "content/browser/device_sensors/device_sensors_consts.h" 15 #include "content/browser/device_sensors/device_sensors_consts.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "mojo/public/cpp/system/buffer.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 class DataFetcherSharedMemory; 21 class DataFetcherSharedMemory;
21 22
22 // Owns the data fetcher for Device Motion and Orientation and keeps track of 23 // Owns the data fetcher for Device Motion and Orientation and keeps track of
23 // the number of consumers currently using the data. The data fetcher is stopped 24 // the number of consumers currently using the data. The data fetcher is stopped
24 // when there are no consumers. 25 // when there are no consumers.
25 class CONTENT_EXPORT DeviceInertialSensorService { 26 class CONTENT_EXPORT DeviceInertialSensorService {
26 public: 27 public:
27 // Returns the DeviceInertialSensorService singleton. 28 // Returns the DeviceInertialSensorService singleton.
28 static DeviceInertialSensorService* GetInstance(); 29 static DeviceInertialSensorService* GetInstance();
29 30
30 // Increments the number of users of the provider. The Provider is running 31 // Increments the number of users of the provider. The Provider is running
31 // when there's > 0 users, and is paused when the count drops to 0. 32 // when there's > 0 users, and is paused when the count drops to 0.
32 // Must be called on the I/O thread. 33 // Must be called on the I/O thread.
33 void AddConsumer(ConsumerType consumer_type); 34 void AddConsumer(ConsumerType consumer_type);
34 35
35 // Removes a consumer. Should be matched with an AddConsumer call. 36 // Removes a consumer. Should be matched with an AddConsumer call.
36 // Must be called on the I/O thread. 37 // Must be called on the I/O thread.
37 void RemoveConsumer(ConsumerType cosumer_type); 38 void RemoveConsumer(ConsumerType cosumer_type);
38 39
39 // Returns the shared memory handle of the device motion data duplicated 40 // Returns the shared memory handle of the device motion data.
40 // into the given process. 41 mojo::ScopedSharedBufferHandle GetSharedMemoryHandle(
41 base::SharedMemoryHandle GetSharedMemoryHandleForProcess( 42 ConsumerType consumer_type);
42 ConsumerType consumer_type, base::ProcessHandle handle);
43 43
44 // Stop/join with the background polling thread in |provider_|. 44 // Stop/join with the background polling thread in |provider_|.
45 void Shutdown(); 45 void Shutdown();
46 46
47 // Injects a custom data fetcher for testing purposes. This class takes 47 // Injects a custom data fetcher for testing purposes. This class takes
48 // ownership of the injected object. 48 // ownership of the injected object.
49 void SetDataFetcherForTesting(DataFetcherSharedMemory* test_data_fetcher); 49 void SetDataFetcherForTesting(DataFetcherSharedMemory* test_data_fetcher);
50 50
51 private: 51 private:
52 friend struct base::DefaultSingletonTraits<DeviceInertialSensorService>; 52 friend struct base::DefaultSingletonTraits<DeviceInertialSensorService>;
(...skipping 11 matching lines...) Expand all
64 bool is_shutdown_; 64 bool is_shutdown_;
65 std::unique_ptr<DataFetcherSharedMemory> data_fetcher_; 65 std::unique_ptr<DataFetcherSharedMemory> data_fetcher_;
66 base::ThreadChecker thread_checker_; 66 base::ThreadChecker thread_checker_;
67 67
68 DISALLOW_COPY_AND_ASSIGN(DeviceInertialSensorService); 68 DISALLOW_COPY_AND_ASSIGN(DeviceInertialSensorService);
69 }; 69 };
70 70
71 } // namespace content 71 } // namespace content
72 72
73 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_ 73 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698