OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_ | 5 #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_ |
6 #define CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_ | 6 #define CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_ |
7 | 7 |
8 #include <set> | 8 #include <map> |
9 | 9 |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "chrome/browser/device_orientation/provider.h" | 11 #include "chrome/browser/device_orientation/provider.h" |
12 | 12 |
13 namespace IPC { class Message; } | 13 namespace IPC { class Message; } |
14 | 14 |
15 namespace device_orientation { | 15 namespace device_orientation { |
16 | 16 |
17 class Orientation; | 17 class Orientation; |
18 | 18 |
19 class DispatcherHost : public base::RefCountedThreadSafe<DispatcherHost>, | 19 class DispatcherHost : public base::RefCounted<DispatcherHost> { |
20 public Provider::Observer { | |
21 public: | 20 public: |
22 explicit DispatcherHost(int process_id); | 21 explicit DispatcherHost(int process_id); |
23 bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); | 22 bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); |
24 | 23 |
25 // From Provider::Observer. | |
26 virtual void OnOrientationUpdate(const Orientation& orientation); | |
27 | |
28 private: | 24 private: |
29 virtual ~DispatcherHost(); | 25 virtual ~DispatcherHost(); |
30 friend class base::RefCountedThreadSafe<DispatcherHost>; | 26 friend class base::RefCounted<DispatcherHost>; |
31 | 27 |
32 void OnStartUpdating(int render_view_id); | 28 void OnStartUpdating(int render_view_id); |
33 void OnStopUpdating(int render_view_id); | 29 void OnStopUpdating(int render_view_id); |
34 | 30 |
| 31 // Helper class that observes a Provider and forwards updates to a RenderView. |
| 32 class ObserverDelegate; |
| 33 |
35 int process_id_; | 34 int process_id_; |
36 std::set<int> render_view_ids_; | 35 |
| 36 // map from render_view_id to ObserverDelegate. |
| 37 std::map<int, scoped_refptr<ObserverDelegate> > observers_map_; |
| 38 |
37 scoped_refptr<Provider> provider_; | 39 scoped_refptr<Provider> provider_; |
38 | 40 |
39 DISALLOW_COPY_AND_ASSIGN(DispatcherHost); | 41 DISALLOW_COPY_AND_ASSIGN(DispatcherHost); |
40 }; | 42 }; |
41 | 43 |
42 } // namespace device_orientation | 44 } // namespace device_orientation |
43 | 45 |
44 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_ | 46 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_ |
OLD | NEW |