Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(787)

Unified Diff: content/browser/device_orientation/observer_delegate.h

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Handles null device_data in observer Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/device_orientation/observer_delegate.h
diff --git a/content/browser/device_orientation/observer_delegate.h b/content/browser/device_orientation/observer_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..6ee954b01f2ece5cee552374fe8b2c93e1aa0f48
--- /dev/null
+++ b/content/browser/device_orientation/observer_delegate.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_
+#define CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_
+
+#include "content/browser/device_orientation/device_data.h"
+#include "content/browser/device_orientation/provider.h"
+
+namespace device_orientation {
+
+class ObserverDelegate
+ : public base::RefCounted<ObserverDelegate>, public Provider::Observer {
+ public:
+ // Create ObserverDelegate that observes provider and forwards updates to
hans 2012/07/18 17:21:02 this and the lines below are indented too much
aousterh 2012/07/20 11:18:52 Done.
+ // render_view_id in process_id.
+ // Will stop observing provider when destructed.
+ ObserverDelegate(DeviceData::Type device_data_type, Provider* provider,
+ int render_view_id, IPC::Sender* sender);
+
+ // From Provider::Observer.
+ virtual void OnDeviceDataUpdate(const DeviceData* device_data,
+ DeviceData::Type device_data_type) OVERRIDE;
+
+ private:
+ static DeviceData* EmptyDeviceData(DeviceData::Type type);
+
+ friend class base::RefCounted<ObserverDelegate>;
+ virtual ~ObserverDelegate();
+
+ scoped_refptr<Provider> provider_;
+ int render_view_id_;
+ IPC::Sender* sender_; // Weak pointer.
+
+ DISALLOW_COPY_AND_ASSIGN(ObserverDelegate);
+};
+
+} // namespace device_orientation
+
+#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_OBSERVER_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698