OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_MESSAGE_FILTER_H_ |
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_MESSAGE_FILTER_H_ | 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "content/browser/device_orientation/provider.h" | 10 #include "content/browser/device_orientation/device_data.h" |
11 #include "content/public/browser/browser_message_filter.h" | 11 #include "content/public/browser/browser_message_filter.h" |
12 | 12 |
13 namespace device_orientation { | 13 namespace device_orientation { |
14 | 14 |
15 class OrientationMessageFilter : public content::BrowserMessageFilter { | 15 // Helper class that observes a Provider and forwards updates to a RenderView. |
| 16 class ObserverDelegate; |
| 17 |
| 18 class Provider; |
| 19 |
| 20 class MessageFilter : public content::BrowserMessageFilter { |
16 public: | 21 public: |
17 OrientationMessageFilter(); | |
18 | |
19 // content::BrowserMessageFilter implementation. | 22 // content::BrowserMessageFilter implementation. |
20 virtual bool OnMessageReceived(const IPC::Message& message, | 23 virtual bool OnMessageReceived(const IPC::Message& message, |
21 bool* message_was_ok) OVERRIDE; | 24 bool* message_was_ok) OVERRIDE = 0; |
22 | 25 |
23 private: | 26 protected: |
24 virtual ~OrientationMessageFilter(); | 27 MessageFilter(DeviceData::Type device_data_type); |
| 28 virtual ~MessageFilter(); |
25 | 29 |
26 void OnStartUpdating(int render_view_id); | 30 void OnStartUpdating(int render_view_id); |
27 void OnStopUpdating(int render_view_id); | 31 void OnStopUpdating(int render_view_id); |
28 | 32 |
29 // Helper class that observes a Provider and forwards updates to a RenderView. | 33 private: |
30 class ObserverDelegate; | |
31 | 34 |
32 // map from render_view_id to ObserverDelegate. | 35 // map from render_view_id to ObserverDelegate. |
33 std::map<int, scoped_refptr<ObserverDelegate> > observers_map_; | 36 std::map<int, scoped_refptr<ObserverDelegate> > observers_map_; |
34 | 37 |
35 scoped_refptr<Provider> provider_; | 38 scoped_refptr<Provider> provider_; |
36 | 39 DeviceData::Type device_data_type_; |
37 DISALLOW_COPY_AND_ASSIGN(OrientationMessageFilter); | |
38 }; | 40 }; |
39 | 41 |
40 } // namespace device_orientation | 42 } // namespace device_orientation |
41 | 43 |
42 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_MESSAGE_FILTER_H_ | 44 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_MESSAGE_FILTER_H_ |
OLD | NEW |