diff options
author | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 12:54:51 +0000 |
---|---|---|
committer | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 12:54:51 +0000 |
commit | fbc7150171f0ea8202a8427bed6944a2a0b60f6e (patch) | |
tree | 0904cd11c6e2cd546be8ef5c4611bb0c13a6a755 /chrome/browser/device_orientation/dispatcher_host.h | |
parent | a2dad7cd5803a7f3ac3a15b0e31ac53515c64c07 (diff) | |
download | chromium_src-fbc7150171f0ea8202a8427bed6944a2a0b60f6e.zip chromium_src-fbc7150171f0ea8202a8427bed6944a2a0b60f6e.tar.gz chromium_src-fbc7150171f0ea8202a8427bed6944a2a0b60f6e.tar.bz2 |
device_orientation::DispatcherHost: one Provider observer per render_view_id.
Refactor device_orientation::DispatcherHost to create a 1-to-1 relationship
between a RenderView and an observer of the Provider. The intention is
to remove the need for logic from DispatcherHost, and in effect have the
RenderView observe the Provider.
BUG=44654
TEST=browser_tests --gtest_filter=DeviceOrientationBrowserTest.BasicTest
Review URL: http://codereview.chromium.org/3152043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/device_orientation/dispatcher_host.h')
-rw-r--r-- | chrome/browser/device_orientation/dispatcher_host.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/chrome/browser/device_orientation/dispatcher_host.h b/chrome/browser/device_orientation/dispatcher_host.h index f43a68b..d30e8201 100644 --- a/chrome/browser/device_orientation/dispatcher_host.h +++ b/chrome/browser/device_orientation/dispatcher_host.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_ #define CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_ -#include <set> +#include <map> #include "base/ref_counted.h" #include "chrome/browser/device_orientation/provider.h" @@ -16,24 +16,26 @@ namespace device_orientation { class Orientation; -class DispatcherHost : public base::RefCountedThreadSafe<DispatcherHost>, - public Provider::Observer { +class DispatcherHost : public base::RefCounted<DispatcherHost> { public: explicit DispatcherHost(int process_id); bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); - // From Provider::Observer. - virtual void OnOrientationUpdate(const Orientation& orientation); - private: virtual ~DispatcherHost(); - friend class base::RefCountedThreadSafe<DispatcherHost>; + friend class base::RefCounted<DispatcherHost>; void OnStartUpdating(int render_view_id); void OnStopUpdating(int render_view_id); + // Helper class that observes a Provider and forwards updates to a RenderView. + class ObserverDelegate; + int process_id_; - std::set<int> render_view_ids_; + + // map from render_view_id to ObserverDelegate. + std::map<int, scoped_refptr<ObserverDelegate> > observers_map_; + scoped_refptr<Provider> provider_; DISALLOW_COPY_AND_ASSIGN(DispatcherHost); |