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" | |
9 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
10 | 9 |
11 namespace device_orientation { | 10 namespace device_orientation { |
12 | 11 |
13 class Orientation; | 12 class Orientation; |
14 | 13 |
15 class Provider : public base::RefCountedThreadSafe<Provider> { | 14 class Provider : public base::RefCountedThreadSafe<Provider> { |
16 public: | 15 public: |
17 class Observer { | 16 class Observer { |
18 public: | 17 public: |
(...skipping 16 matching lines...) Expand all Loading... |
35 | 34 |
36 // Get the current instance. Used for testing. | 35 // Get the current instance. Used for testing. |
37 static Provider* GetInstanceForTests(); | 36 static Provider* GetInstanceForTests(); |
38 | 37 |
39 // Note: AddObserver may call back synchronously to the observer with | 38 // Note: AddObserver may call back synchronously to the observer with |
40 // orientation data. | 39 // orientation data. |
41 virtual void AddObserver(Observer* observer) = 0; | 40 virtual void AddObserver(Observer* observer) = 0; |
42 virtual void RemoveObserver(Observer* observer) = 0; | 41 virtual void RemoveObserver(Observer* observer) = 0; |
43 | 42 |
44 protected: | 43 protected: |
45 Provider() {} | 44 Provider(); |
46 virtual ~Provider() { | 45 virtual ~Provider(); |
47 DCHECK(instance_ == this); | |
48 instance_ = NULL; | |
49 } | |
50 | 46 |
51 private: | 47 private: |
52 friend class base::RefCountedThreadSafe<Provider>; | 48 friend class base::RefCountedThreadSafe<Provider>; |
53 static Provider* instance_; | 49 static Provider* instance_; |
54 | 50 |
55 DISALLOW_COPY_AND_ASSIGN(Provider); | 51 DISALLOW_COPY_AND_ASSIGN(Provider); |
56 }; | 52 }; |
57 | 53 |
58 } // namespace device_orientation | 54 } // namespace device_orientation |
59 | 55 |
60 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ | 56 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ |
OLD | NEW |