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

Side by Side Diff: content/browser/device_orientation/data_fetcher_shared_memory_base.h

Issue 22926029: Mac: implement orientation/motion shared memory data fetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FakeNonPollingDataFetcher on stack Created 7 years, 3 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 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
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
63 // pointer for efficienty and thread-safety. 63 // memory pointer. If IsPolling() is true both Start() and Stop() methods
64 // 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698