Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_BASE_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_BASE_H_ |
| 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_BASE_H_ | 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 base::MessageLoop* GetPollingMessageLoop() const; | 52 base::MessageLoop* GetPollingMessageLoop() const; |
| 53 | 53 |
| 54 // If IsPolling() is true this method is called from the |polling_thread_| | 54 // If IsPolling() is true this method is called from the |polling_thread_| |
| 55 // at regular intervals. | 55 // at regular intervals. |
| 56 virtual void Fetch(unsigned consumer_bitmask); | 56 virtual void Fetch(unsigned consumer_bitmask); |
| 57 | 57 |
| 58 // Returns true if this fetcher needs to use a polling thread to | 58 // Returns true if this fetcher needs to use a polling thread to |
| 59 // fetch the sensor data. | 59 // fetch the sensor data. |
| 60 virtual bool IsPolling() const; | 60 virtual bool IsPolling() const; |
| 61 | 61 |
| 62 // Start() method should call InitSharedMemoryBuffer() and cache the obtained | 62 // Start() method should call InitSharedMemoryBuffer() to get the shared |
|
bulach
2013/08/23 16:03:34
nit: s/shared shared/shared/ :)
timvolodine
2013/08/23 16:34:55
Done.
| |
| 63 // pointer for efficienty and thread-safety. | 63 // shared memory pointer. If IsPolling() is true both Start() and Stop() |
| 64 // methods are called from the |polling_thread_|. | |
| 64 virtual bool Start(ConsumerType consumer_type) = 0; | 65 virtual bool Start(ConsumerType consumer_type) = 0; |
| 65 virtual bool Stop(ConsumerType consumer_type) = 0; | 66 virtual bool Stop(ConsumerType consumer_type) = 0; |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 bool InitAndStartPollingThreadIfNecessary(); | 69 bool InitAndStartPollingThreadIfNecessary(); |
| 69 base::SharedMemory* InitSharedMemory(ConsumerType consumer_type, | 70 base::SharedMemory* InitSharedMemory(ConsumerType consumer_type, |
| 70 size_t buffer_size); | 71 size_t buffer_size); |
| 71 | 72 |
| 72 unsigned started_consumers_; | 73 unsigned started_consumers_; |
| 73 | 74 |
| 74 scoped_ptr<PollingThread> polling_thread_; | 75 scoped_ptr<PollingThread> polling_thread_; |
| 75 | 76 |
| 76 // Owning pointers. Objects in the map are deleted in dtor. | 77 // Owning pointers. Objects in the map are deleted in dtor. |
| 77 typedef std::map<ConsumerType, base::SharedMemory*> SharedMemoryMap; | 78 typedef std::map<ConsumerType, base::SharedMemory*> SharedMemoryMap; |
| 78 SharedMemoryMap shared_memory_map_; | 79 SharedMemoryMap shared_memory_map_; |
| 79 | 80 |
| 80 DISALLOW_COPY_AND_ASSIGN(DataFetcherSharedMemoryBase); | 81 DISALLOW_COPY_AND_ASSIGN(DataFetcherSharedMemoryBase); |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 } | 84 } |
| 84 | 85 |
| 85 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_BASE_H_ | 86 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_SHARED_MEMORY_BASE_H_ |
| OLD | NEW |