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

Side by Side Diff: chrome/browser/device_orientation/provider.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_H_
6 #define CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_
7
8 #include "base/ref_counted.h"
9
10 namespace device_orientation {
11
12 class Orientation;
13
14 class Provider : public base::RefCountedThreadSafe<Provider> {
15 public:
16 class Observer {
17 public:
18 // Called when the orientation changes.
19 // An Observer must not synchronously call Provider::RemoveObserver
20 // or Provider::AddObserver when this is called.
21 virtual void OnOrientationUpdate(const Orientation& orientation) = 0;
22 };
23
24 // Returns a pointer to the singleton instance of this class.
25 // The caller should store the returned pointer in a scoped_refptr.
26 // The Provider instance is lazily constructed when GetInstance() is called,
27 // and destructed when the last scoped_refptr referring to it is destructed.
28 static Provider* GetInstance();
29
30 // Inject a mock Provider for testing. Only a weak pointer to the injected
31 // object will be held by Provider, i.e. it does not itself contribute to the
32 // injected object's reference count.
33 static void SetInstanceForTests(Provider* provider);
34
35 // Get the current instance. Used for testing.
36 static Provider* GetInstanceForTests();
37
38 // Note: AddObserver may call back synchronously to the observer with
39 // orientation data.
40 virtual void AddObserver(Observer* observer) = 0;
41 virtual void RemoveObserver(Observer* observer) = 0;
42
43 protected:
44 Provider();
45 virtual ~Provider();
46
47 private:
48 friend class base::RefCountedThreadSafe<Provider>;
49 static Provider* instance_;
50
51 DISALLOW_COPY_AND_ASSIGN(Provider);
52 };
53
54 } // namespace device_orientation
55
56 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/device_orientation/orientation.h ('k') | chrome/browser/device_orientation/provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698