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

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

Issue 2410123002: Remove content::BrowserThread knowledge from Device Sensors (Closed)
Patch Set: Rebase, avoid object creation on startup Created 4 years, 1 month 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_SENSOR_SERVICE_H_ 5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_SERVICE_H_
6 #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_SERVICE_H_ 6 #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_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"
(...skipping 12 matching lines...) Expand all
23 // 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
24 // 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
25 // when there are no consumers. 25 // when there are no consumers.
26 class CONTENT_EXPORT DeviceSensorService { 26 class CONTENT_EXPORT DeviceSensorService {
27 public: 27 public:
28 // Returns the DeviceSensorService singleton. 28 // Returns the DeviceSensorService singleton.
29 static DeviceSensorService* GetInstance(); 29 static DeviceSensorService* GetInstance();
30 30
31 // 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
32 // 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.
33 // Must be called on the I/O thread. 33 // Must be called on a thread that can perform I/O.
34 void AddConsumer(ConsumerType consumer_type); 34 void AddConsumer(ConsumerType consumer_type);
35 35
36 // Removes a consumer. Should be matched with an AddConsumer call. 36 // Removes a consumer. Should be matched with an AddConsumer call.
37 // Must be called on the I/O thread. 37 // Must be called on a thread that can perform I/O.
38 void RemoveConsumer(ConsumerType cosumer_type); 38 void RemoveConsumer(ConsumerType cosumer_type);
39 39
40 // Returns the shared memory handle of the device motion data. 40 // Returns the shared memory handle of the device motion data.
41 mojo::ScopedSharedBufferHandle GetSharedMemoryHandle( 41 mojo::ScopedSharedBufferHandle GetSharedMemoryHandle(
42 ConsumerType consumer_type); 42 ConsumerType consumer_type);
43 43
44 // Stop/join with the background polling thread in |provider_|. 44 // Stop/join with the background polling thread in |provider_|. Must be
45 void Shutdown(); 45 // called on the UI thread.
46 void ShutDownOnUIThread();
46 47
47 // Injects a custom data fetcher for testing purposes. This class takes 48 // Injects a custom data fetcher for testing purposes. This class takes
48 // ownership of the injected object. 49 // ownership of the injected object.
49 void SetDataFetcherForTesting(DataFetcherSharedMemory* test_data_fetcher); 50 void SetDataFetcherForTesting(DataFetcherSharedMemory* test_data_fetcher);
50 51
51 private: 52 private:
52 friend struct base::DefaultSingletonTraits<DeviceSensorService>; 53 friend struct base::DefaultSingletonTraits<DeviceSensorService>;
53 54
54 DeviceSensorService(); 55 DeviceSensorService();
55 virtual ~DeviceSensorService(); 56 virtual ~DeviceSensorService();
56 57
57 bool ChangeNumberConsumers(ConsumerType consumer_type, int delta); 58 bool ChangeNumberConsumers(ConsumerType consumer_type, int delta);
58 int GetNumberConsumers(ConsumerType consumer_type) const; 59 int GetNumberConsumers(ConsumerType consumer_type) const;
59 60
60 int num_light_readers_; 61 int num_light_readers_;
61 int num_motion_readers_; 62 int num_motion_readers_;
62 int num_orientation_readers_; 63 int num_orientation_readers_;
63 int num_orientation_absolute_readers_; 64 int num_orientation_absolute_readers_;
64 bool is_shutdown_; 65 bool is_shutdown_;
65 std::unique_ptr<DataFetcherSharedMemory> data_fetcher_; 66 std::unique_ptr<DataFetcherSharedMemory> data_fetcher_;
66 base::ThreadChecker thread_checker_; 67
68 // Associated with the IO thread.
69 base::ThreadChecker io_thread_checker_;
67 70
68 DISALLOW_COPY_AND_ASSIGN(DeviceSensorService); 71 DISALLOW_COPY_AND_ASSIGN(DeviceSensorService);
69 }; 72 };
70 73
71 } // namespace content 74 } // namespace content
72 75
73 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_SERVICE_H_ 76 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_SENSOR_SERVICE_H_
OLDNEW
« no previous file with comments | « content/browser/device_sensors/device_sensor_host.cc ('k') | content/browser/device_sensors/device_sensor_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698