Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_DATA_FETCHER_SHARED_MEMORY_BASE_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_BASE_H_ |
| 6 #define CONTENT_BROWSER_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_BASE_H_ | 6 #define CONTENT_BROWSER_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_BASE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 virtual base::TimeDelta GetInterval() const; | 70 virtual base::TimeDelta GetInterval() const; |
| 71 | 71 |
| 72 // Start() method should call InitSharedMemoryBuffer() to get the shared | 72 // Start() method should call InitSharedMemoryBuffer() to get the shared |
| 73 // memory pointer. If IsPolling() is true both Start() and Stop() methods | 73 // memory pointer. If IsPolling() is true both Start() and Stop() methods |
| 74 // are called from the |polling_thread_|. | 74 // are called from the |polling_thread_|. |
| 75 virtual bool Start(ConsumerType consumer_type, void* buffer) = 0; | 75 virtual bool Start(ConsumerType consumer_type, void* buffer) = 0; |
| 76 virtual bool Stop(ConsumerType consumer_type) = 0; | 76 virtual bool Stop(ConsumerType consumer_type) = 0; |
| 77 | 77 |
| 78 bool IsPollingTimerRunningForTesting() const; | 78 bool IsPollingTimerRunningForTesting() const; |
| 79 | 79 |
| 80 // Should be used in deriving classes to make sure all active sensors are | |
|
Bernhard Bauer
2014/09/17 16:41:00
Nit: "derived"
timvolodine
2014/09/17 18:25:00
Done.
| |
| 81 // unregistered upon destruction. | |
| 82 void StopFetchingAllDeviceData(); | |
|
Bernhard Bauer
2014/09/17 16:41:00
Instead of requiring each subclass to call this me
timvolodine
2014/09/17 18:25:00
Done. though not sure it's that much better..
Bernhard Bauer
2014/09/17 21:36:37
Well, it means you only have to care about this in
| |
| 83 | |
| 80 private: | 84 private: |
| 81 bool InitAndStartPollingThreadIfNecessary(); | 85 bool InitAndStartPollingThreadIfNecessary(); |
| 82 base::SharedMemory* GetSharedMemory(ConsumerType consumer_type); | 86 base::SharedMemory* GetSharedMemory(ConsumerType consumer_type); |
| 83 void* GetSharedMemoryBuffer(ConsumerType consumer_type); | 87 void* GetSharedMemoryBuffer(ConsumerType consumer_type); |
| 84 | 88 |
| 85 unsigned started_consumers_; | 89 unsigned started_consumers_; |
| 86 | 90 |
| 87 scoped_ptr<PollingThread> polling_thread_; | 91 scoped_ptr<PollingThread> polling_thread_; |
| 88 | 92 |
| 89 // Owning pointers. Objects in the map are deleted in dtor. | 93 // Owning pointers. Objects in the map are deleted in dtor. |
| 90 typedef std::map<ConsumerType, base::SharedMemory*> SharedMemoryMap; | 94 typedef std::map<ConsumerType, base::SharedMemory*> SharedMemoryMap; |
| 91 SharedMemoryMap shared_memory_map_; | 95 SharedMemoryMap shared_memory_map_; |
| 92 | 96 |
| 93 DISALLOW_COPY_AND_ASSIGN(DataFetcherSharedMemoryBase); | 97 DISALLOW_COPY_AND_ASSIGN(DataFetcherSharedMemoryBase); |
| 94 }; | 98 }; |
| 95 | 99 |
| 96 } // namespace content | 100 } // namespace content |
| 97 | 101 |
| 98 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_BASE_H_ | 102 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_BASE_H_ |
| OLD | NEW |