OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ |
6 #define CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ | 6 #define CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // The caller should store the returned pointer in a scoped_refptr. | 26 // The caller should store the returned pointer in a scoped_refptr. |
27 // The Provider instance is lazily constructed when GetInstance() is called, | 27 // The Provider instance is lazily constructed when GetInstance() is called, |
28 // and destructed when the last scoped_refptr referring to it is destructed. | 28 // and destructed when the last scoped_refptr referring to it is destructed. |
29 static Provider* GetInstance(); | 29 static Provider* GetInstance(); |
30 | 30 |
31 // Inject a mock Provider for testing. Only a weak pointer to the injected | 31 // Inject a mock Provider for testing. Only a weak pointer to the injected |
32 // object will be held by Provider, i.e. it does not itself contribute to the | 32 // object will be held by Provider, i.e. it does not itself contribute to the |
33 // injected object's reference count. | 33 // injected object's reference count. |
34 static void SetInstanceForTests(Provider* provider); | 34 static void SetInstanceForTests(Provider* provider); |
35 | 35 |
| 36 // Note: AddObserver may call back synchronously to the observer with |
| 37 // orientation data. |
36 virtual void AddObserver(Observer* observer) = 0; | 38 virtual void AddObserver(Observer* observer) = 0; |
37 virtual void RemoveObserver(Observer* observer) = 0; | 39 virtual void RemoveObserver(Observer* observer) = 0; |
38 | 40 |
39 protected: | 41 protected: |
40 Provider() {} | 42 Provider() {} |
41 virtual ~Provider() { | 43 virtual ~Provider() { |
42 DCHECK(instance_ == this); | 44 DCHECK(instance_ == this); |
43 instance_ = NULL; | 45 instance_ = NULL; |
44 } | 46 } |
45 | 47 |
46 private: | 48 private: |
47 friend class base::RefCountedThreadSafe<Provider>; | 49 friend class base::RefCountedThreadSafe<Provider>; |
48 static Provider* instance_; | 50 static Provider* instance_; |
49 | 51 |
50 DISALLOW_COPY_AND_ASSIGN(Provider); | 52 DISALLOW_COPY_AND_ASSIGN(Provider); |
51 }; | 53 }; |
52 | 54 |
53 } // namespace device_orientation | 55 } // namespace device_orientation |
54 | 56 |
55 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ | 57 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ |
OLD | NEW |