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

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

Issue 10689106: Renaming Observer to OrientationObserver in DeviceOrientation (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PROVIDER_H_ 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "content/common/content_export.h" 9 #include "content/common/content_export.h"
10 10
11 namespace device_orientation { 11 namespace device_orientation {
12 12
13 class Orientation; 13 class Orientation;
14 14
15 class CONTENT_EXPORT Provider : public base::RefCountedThreadSafe<Provider> { 15 class CONTENT_EXPORT Provider : public base::RefCountedThreadSafe<Provider> {
16 public: 16 public:
17 class Observer { 17 class OrientationObserver {
18 public: 18 public:
19 // Called when the orientation changes. 19 // Called when the orientation changes.
20 // An Observer must not synchronously call Provider::RemoveObserver 20 // An OrientationObserver must not synchronously call Provider::
21 // or Provider::AddObserver when this is called. 21 // RemoveOrientationObserver or Provider::AddOrientationObserver when this
22 // is called.
22 virtual void OnOrientationUpdate(const Orientation& orientation) = 0; 23 virtual void OnOrientationUpdate(const Orientation& orientation) = 0;
23 24
24 protected: 25 protected:
25 virtual ~Observer() {} 26 virtual ~OrientationObserver() {}
26 }; 27 };
27 28
28 // Returns a pointer to the singleton instance of this class. 29 // Returns a pointer to the singleton instance of this class.
29 // The caller should store the returned pointer in a scoped_refptr. 30 // The caller should store the returned pointer in a scoped_refptr.
30 // The Provider instance is lazily constructed when GetInstance() is called, 31 // The Provider instance is lazily constructed when GetInstance() is called,
31 // and destructed when the last scoped_refptr referring to it is destructed. 32 // and destructed when the last scoped_refptr referring to it is destructed.
32 static Provider* GetInstance(); 33 static Provider* GetInstance();
33 34
34 // Inject a mock Provider for testing. Only a weak pointer to the injected 35 // Inject a mock Provider for testing. Only a weak pointer to the injected
35 // object will be held by Provider, i.e. it does not itself contribute to the 36 // object will be held by Provider, i.e. it does not itself contribute to the
36 // injected object's reference count. 37 // injected object's reference count.
37 static void SetInstanceForTests(Provider* provider); 38 static void SetInstanceForTests(Provider* provider);
38 39
39 // Get the current instance. Used for testing. 40 // Get the current instance. Used for testing.
40 static Provider* GetInstanceForTests(); 41 static Provider* GetInstanceForTests();
41 42
42 // Note: AddObserver may call back synchronously to the observer with 43 // Note: AddOrientationObserver may call back synchronously to the observer
43 // orientation data. 44 // with the orientation data.
44 virtual void AddObserver(Observer* observer) = 0; 45 virtual void AddOrientationObserver(OrientationObserver* observer) = 0;
45 virtual void RemoveObserver(Observer* observer) = 0; 46 virtual void RemoveOrientationObserver(OrientationObserver* observer) = 0;
46 47
47 protected: 48 protected:
48 Provider(); 49 Provider();
49 virtual ~Provider(); 50 virtual ~Provider();
50 51
51 private: 52 private:
52 friend class base::RefCountedThreadSafe<Provider>; 53 friend class base::RefCountedThreadSafe<Provider>;
53 static Provider* instance_; 54 static Provider* instance_;
54 55
55 DISALLOW_COPY_AND_ASSIGN(Provider); 56 DISALLOW_COPY_AND_ASSIGN(Provider);
56 }; 57 };
57 58
58 } // namespace device_orientation 59 } // namespace device_orientation
59 60
60 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ 61 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698