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_OBSERVER_DELEGATE_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_ |
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_ | 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_ |
7 | 7 |
8 #include "content/browser/device_orientation/device_data.h" | 8 #include "content/browser/device_orientation/device_data.h" |
9 #include "content/browser/device_orientation/provider.h" | 9 #include "content/browser/device_orientation/provider.h" |
10 | 10 |
11 namespace IPC { | 11 namespace IPC { |
12 class Sender; | 12 class Sender; |
13 } | 13 } |
14 | 14 |
15 namespace device_orientation { | 15 namespace content { |
16 | 16 |
17 class ObserverDelegate | 17 class ObserverDelegate |
18 : public base::RefCounted<ObserverDelegate>, public Provider::Observer { | 18 : public base::RefCounted<ObserverDelegate>, public Provider::Observer { |
19 public: | 19 public: |
20 // Create ObserverDelegate that observes provider and forwards updates to | 20 // Create ObserverDelegate that observes provider and forwards updates to |
21 // render_view_id. | 21 // render_view_id. |
22 // Will stop observing provider when destructed. | 22 // Will stop observing provider when destructed. |
23 ObserverDelegate(DeviceData::Type device_data_type, Provider* provider, | 23 ObserverDelegate(DeviceData::Type device_data_type, Provider* provider, |
24 int render_view_id, IPC::Sender* sender); | 24 int render_view_id, IPC::Sender* sender); |
25 | 25 |
26 // From Provider::Observer. | 26 // From Provider::Observer. |
27 virtual void OnDeviceDataUpdate(const DeviceData* device_data, | 27 virtual void OnDeviceDataUpdate(const DeviceData* device_data, |
28 DeviceData::Type device_data_type) OVERRIDE; | 28 DeviceData::Type device_data_type) OVERRIDE; |
29 | 29 |
30 private: | 30 private: |
31 static DeviceData* EmptyDeviceData(DeviceData::Type type); | 31 static DeviceData* EmptyDeviceData(DeviceData::Type type); |
32 | 32 |
33 friend class base::RefCounted<ObserverDelegate>; | 33 friend class base::RefCounted<ObserverDelegate>; |
34 virtual ~ObserverDelegate(); | 34 virtual ~ObserverDelegate(); |
35 | 35 |
36 scoped_refptr<Provider> provider_; | 36 scoped_refptr<Provider> provider_; |
37 int render_view_id_; | 37 int render_view_id_; |
38 IPC::Sender* sender_; // Weak pointer. | 38 IPC::Sender* sender_; // Weak pointer. |
39 | 39 |
40 DISALLOW_COPY_AND_ASSIGN(ObserverDelegate); | 40 DISALLOW_COPY_AND_ASSIGN(ObserverDelegate); |
41 }; | 41 }; |
42 | 42 |
43 } // namespace device_orientation | 43 } // namespace content |
44 | 44 |
45 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_ | 45 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_ |
OLD | NEW |