Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / device_orientation / observer_delegate.h
blob8c7dab84b08caae7c7d0128c25cabb4c20ff9a4c
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.
5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_
8 #include "content/browser/device_orientation/device_data.h"
9 #include "content/browser/device_orientation/provider.h"
11 namespace IPC {
12 class Sender;
15 namespace content {
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);
26 // From Provider::Observer.
27 virtual void OnDeviceDataUpdate(const DeviceData* device_data,
28 DeviceData::Type device_data_type) OVERRIDE;
30 private:
31 static DeviceData* EmptyDeviceData(DeviceData::Type type);
33 friend class base::RefCounted<ObserverDelegate>;
34 virtual ~ObserverDelegate();
36 scoped_refptr<Provider> provider_;
37 int render_view_id_;
38 IPC::Sender* sender_; // Weak pointer.
40 DISALLOW_COPY_AND_ASSIGN(ObserverDelegate);
43 } // namespace content
45 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_