OLD | NEW |
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/browser/device_orientation/device_data.h" | 9 #include "content/browser/device_orientation/device_data.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 class CONTENT_EXPORT Provider : public base::RefCountedThreadSafe<Provider> { | 14 class CONTENT_EXPORT Provider : public base::RefCountedThreadSafe<Provider> { |
15 public: | 15 public: |
16 class Observer { | 16 class Observer { |
17 public: | 17 public: |
18 // Called when device data changes. | 18 // Called when device data changes. |
19 // An Observer must not synchronously call Provider::RemoveObserver | 19 // An Observer must not synchronously call Provider::RemoveObserver |
20 // or Provider::AddObserver when this is called. | 20 // or Provider::AddObserver when this is called. |
21 virtual void OnDeviceDataUpdate(const DeviceData* device_data, | 21 virtual void OnDeviceDataUpdate(const DeviceData* device_data, |
22 DeviceData::Type device_data_type) = 0; | 22 DeviceData::Type device_data_type) = 0; |
23 DeviceData::Type device_data_type() { return device_data_type_; } | 23 DeviceData::Type device_data_type() { return device_data_type_; } |
24 | 24 |
25 protected: | 25 protected: |
26 Observer(DeviceData::Type device_data_type) | 26 explicit Observer(DeviceData::Type device_data_type) |
27 : device_data_type_(device_data_type) { | 27 : device_data_type_(device_data_type) { |
28 } | 28 } |
29 virtual ~Observer() {} | 29 virtual ~Observer() {} |
30 | 30 |
31 private: | 31 private: |
32 // Each Observer observes exactly one type of DeviceData. | 32 // Each Observer observes exactly one type of DeviceData. |
33 DeviceData::Type device_data_type_; | 33 DeviceData::Type device_data_type_; |
34 }; | 34 }; |
35 | 35 |
36 // Returns a pointer to the singleton instance of this class. | 36 // Returns a pointer to the singleton instance of this class. |
(...skipping 21 matching lines...) Expand all Loading... |
58 private: | 58 private: |
59 friend class base::RefCountedThreadSafe<Provider>; | 59 friend class base::RefCountedThreadSafe<Provider>; |
60 static Provider* instance_; | 60 static Provider* instance_; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(Provider); | 62 DISALLOW_COPY_AND_ASSIGN(Provider); |
63 }; | 63 }; |
64 | 64 |
65 } // namespace content | 65 } // namespace content |
66 | 66 |
67 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ | 67 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_ |
OLD | NEW |