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

Side by Side Diff: device/device_sensors/device_inertial_sensor_service.h

Issue 1164563003: Extract device_sensors to /device via Mojofication (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 DEVICE_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_
6 #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_ 6 #define DEVICE_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "content/browser/device_sensors/inertial_sensor_consts.h" 14 #include "device/device_sensors/device_sensors_export.h"
15 #include "content/common/content_export.h" 15 #include "device/device_sensors/inertial_sensor_consts.h"
16 16
17 namespace content { 17 namespace device {
18 18
19 class DataFetcherSharedMemory; 19 class DataFetcherSharedMemory;
20 20
21 // Owns the data fetcher for Device Motion and Orientation and keeps track of 21 // Owns the data fetcher for Device Motion and Orientation and keeps track of
22 // the number of consumers currently using the data. The data fetcher is stopped 22 // the number of consumers currently using the data. The data fetcher is stopped
23 // when there are no consumers. 23 // when there are no consumers.
24 class CONTENT_EXPORT DeviceInertialSensorService { 24 class DEVICE_SENSORS_EXPORT DeviceInertialSensorService {
25 public: 25 public:
26 // Returns the DeviceInertialSensorService singleton. 26 // Returns the DeviceInertialSensorService singleton.
27 static DeviceInertialSensorService* GetInstance(); 27 static DeviceInertialSensorService* GetInstance();
28 28
29 // Increments the number of users of the provider. The Provider is running 29 // Increments the number of users of the provider. The Provider is running
30 // when there's > 0 users, and is paused when the count drops to 0. 30 // when there's > 0 users, and is paused when the count drops to 0.
31 // Must be called on the I/O thread. 31 // Must be called on the I/O thread.
32 void AddConsumer(ConsumerType consumer_type); 32 void AddConsumer(ConsumerType consumer_type);
33 33
34 // Removes a consumer. Should be matched with an AddConsumer call. 34 // Removes a consumer. Should be matched with an AddConsumer call.
35 // Must be called on the I/O thread. 35 // Must be called on the I/O thread.
36 void RemoveConsumer(ConsumerType cosumer_type); 36 void RemoveConsumer(ConsumerType cosumer_type);
37 37
38 // Returns the shared memory handle of the device motion data duplicated 38 // Returns the shared memory handle of the device motion data duplicated
39 // into the given process. 39 // into the given process.
40 base::SharedMemoryHandle GetSharedMemoryHandleForProcess( 40 base::SharedMemoryHandle GetSharedMemoryHandleForProcess(
41 ConsumerType consumer_type, base::ProcessHandle handle); 41 ConsumerType consumer_type,
42 base::ProcessHandle handle);
42 43
43 // Stop/join with the background polling thread in |provider_|. 44 // Stop/join with the background polling thread in |provider_|.
44 void Shutdown(); 45 void Shutdown();
45 46
46 // Injects a custom data fetcher for testing purposes. This class takes 47 // Injects a custom data fetcher for testing purposes. This class takes
47 // ownership of the injected object. 48 // ownership of the injected object.
48 void SetDataFetcherForTesting(DataFetcherSharedMemory* test_data_fetcher); 49 void SetDataFetcherForTesting(DataFetcherSharedMemory* test_data_fetcher);
49 50
50 private: 51 private:
51 friend struct DefaultSingletonTraits<DeviceInertialSensorService>; 52 friend struct DefaultSingletonTraits<DeviceInertialSensorService>;
52 53
53 DeviceInertialSensorService(); 54 DeviceInertialSensorService();
54 virtual ~DeviceInertialSensorService(); 55 virtual ~DeviceInertialSensorService();
55 56
56 bool ChangeNumberConsumers(ConsumerType consumer_type, 57 bool ChangeNumberConsumers(ConsumerType consumer_type, int delta);
57 int delta);
58 int GetNumberConsumers(ConsumerType consumer_type) const; 58 int GetNumberConsumers(ConsumerType consumer_type) const;
59 59
60 int num_light_readers_; 60 int num_light_readers_;
61 int num_motion_readers_; 61 int num_motion_readers_;
62 int num_orientation_readers_; 62 int num_orientation_readers_;
63 bool is_shutdown_; 63 bool is_shutdown_;
64 scoped_ptr<DataFetcherSharedMemory> data_fetcher_; 64 scoped_ptr<DataFetcherSharedMemory> data_fetcher_;
65 base::ThreadChecker thread_checker_; 65 base::ThreadChecker thread_checker_;
66 66
67 DISALLOW_COPY_AND_ASSIGN(DeviceInertialSensorService); 67 DISALLOW_COPY_AND_ASSIGN(DeviceInertialSensorService);
68 }; 68 };
69 69
70 } // namespace content 70 } // namespace device
71 71
72 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_ 72 #endif // DEVICE_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_
OLDNEW
« no previous file with comments | « device/device_sensors/device_inertial_sensor_browsertest.cc ('k') | device/device_sensors/device_inertial_sensor_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698