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

Side by Side Diff: chrome/browser/device_orientation/provider_impl.h

Issue 6586001: Move appcache/file_sytem/device_orientation subdirectories of chrome\browser ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_
6 #define CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/scoped_ptr.h"
12 #include "base/task.h"
13 #include "chrome/browser/device_orientation/data_fetcher.h"
14 #include "chrome/browser/device_orientation/orientation.h"
15 #include "chrome/browser/device_orientation/provider.h"
16
17 class MessageLoop;
18
19 namespace base {
20 class Thread;
21 }
22
23 namespace device_orientation {
24
25 class ProviderImpl : public Provider {
26 public:
27 typedef DataFetcher* (*DataFetcherFactory)();
28
29 // Create a ProviderImpl that uses the NULL-terminated factories array to find
30 // a DataFetcher that can provide orientation data.
31 ProviderImpl(const DataFetcherFactory factories[]);
32
33 // From Provider.
34 virtual void AddObserver(Observer* observer);
35 virtual void RemoveObserver(Observer* observer);
36
37 private:
38 virtual ~ProviderImpl();
39
40 // Starts or Stops the provider. Called from creator_loop_.
41 void Start();
42 void Stop();
43
44 // Method for finding a suitable DataFetcher and starting the polling.
45 // Runs on the polling_thread_.
46 void DoInitializePollingThread(std::vector<DataFetcherFactory> factories);
47 void ScheduleInitializePollingThread();
48
49 // Method for polling a DataFetcher. Runs on the polling_thread_.
50 void DoPoll();
51 void ScheduleDoPoll();
52
53 // Method for notifying observers of an orientation update.
54 // Runs on the creator_thread_.
55 void DoNotify(const Orientation& orientation);
56 void ScheduleDoNotify(const Orientation& orientation);
57
58 static bool SignificantlyDifferent(const Orientation& orientation1,
59 const Orientation& orientation2);
60
61 enum { kDesiredSamplingIntervalMs = 100 };
62 int SamplingIntervalMs() const;
63
64 // The Message Loop on which this object was created.
65 // Typically the I/O loop, but may be something else during testing.
66 MessageLoop* creator_loop_;
67
68 // Members below are only to be used from the creator_loop_.
69 std::vector<DataFetcherFactory> factories_;
70 std::set<Observer*> observers_;
71 Orientation last_notification_;
72
73 // When polling_thread_ is running, members below are only to be used
74 // from that thread.
75 scoped_ptr<DataFetcher> data_fetcher_;
76 Orientation last_orientation_;
77 ScopedRunnableMethodFactory<ProviderImpl> do_poll_method_factory_;
78
79 // Polling is done on this background thread.
80 scoped_ptr<base::Thread> polling_thread_;
81 };
82
83 } // namespace device_orientation
84
85 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/device_orientation/provider.cc ('k') | chrome/browser/device_orientation/provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698