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