| 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 #include <memory> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "content/browser/device_sensors/device_sensors_consts.h" | 14 #include "content/browser/device_sensors/device_sensors_consts.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 // Sensor data fetchers should derive from this base class and implement | 19 // Sensor data fetchers should derive from this base class and implement |
| 20 // the abstract Start() and Stop() methods. | 20 // the abstract Start() and Stop() methods. |
| 21 // If the fetcher requires polling it should also implement IsPolling() | 21 // If the fetcher requires polling it should also implement IsPolling() |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 bool IsPollingTimerRunningForTesting() const; | 83 bool IsPollingTimerRunningForTesting() const; |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 bool InitAndStartPollingThreadIfNecessary(); | 86 bool InitAndStartPollingThreadIfNecessary(); |
| 87 base::SharedMemory* GetSharedMemory(ConsumerType consumer_type); | 87 base::SharedMemory* GetSharedMemory(ConsumerType consumer_type); |
| 88 void* GetSharedMemoryBuffer(ConsumerType consumer_type); | 88 void* GetSharedMemoryBuffer(ConsumerType consumer_type); |
| 89 | 89 |
| 90 unsigned started_consumers_; | 90 unsigned started_consumers_; |
| 91 | 91 |
| 92 scoped_ptr<PollingThread> polling_thread_; | 92 std::unique_ptr<PollingThread> polling_thread_; |
| 93 | 93 |
| 94 // Owning pointers. Objects in the map are deleted in dtor. | 94 // Owning pointers. Objects in the map are deleted in dtor. |
| 95 typedef std::map<ConsumerType, base::SharedMemory*> SharedMemoryMap; | 95 typedef std::map<ConsumerType, base::SharedMemory*> SharedMemoryMap; |
| 96 SharedMemoryMap shared_memory_map_; | 96 SharedMemoryMap shared_memory_map_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(DataFetcherSharedMemoryBase); | 98 DISALLOW_COPY_AND_ASSIGN(DataFetcherSharedMemoryBase); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace content | 101 } // namespace content |
| 102 | 102 |
| 103 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_BASE_H_ | 103 #endif // CONTENT_BROWSER_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_BASE_H_ |
| OLD | NEW |