OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_AUTOMATION_AUTOMATION_RESOURCE_MSG_FILTER_H_ | 5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_MSG_FILTER_H_ |
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_MSG_FILTER_H_ | 6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_MSG_FILTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 int tab_handle; | 33 int tab_handle; |
34 int ref_count; | 34 int ref_count; |
35 scoped_refptr<AutomationResourceMessageFilter> filter; | 35 scoped_refptr<AutomationResourceMessageFilter> filter; |
36 }; | 36 }; |
37 | 37 |
38 // Create the filter. | 38 // Create the filter. |
39 AutomationResourceMessageFilter(); | 39 AutomationResourceMessageFilter(); |
40 virtual ~AutomationResourceMessageFilter(); | 40 virtual ~AutomationResourceMessageFilter(); |
41 | 41 |
| 42 // Returns a new automation request id. This is unique across all instances |
| 43 // of AutomationResourceMessageFilter. |
| 44 int NewAutomationRequestId() { |
| 45 return base::subtle::Barrier_AtomicIncrement(&unique_request_id_, 1); |
| 46 } |
| 47 |
42 // IPC::ChannelProxy::MessageFilter methods: | 48 // IPC::ChannelProxy::MessageFilter methods: |
43 virtual void OnFilterAdded(IPC::Channel* channel); | 49 virtual void OnFilterAdded(IPC::Channel* channel); |
44 virtual void OnChannelConnected(int32 peer_pid); | 50 virtual void OnChannelConnected(int32 peer_pid); |
45 virtual void OnChannelClosing(); | 51 virtual void OnChannelClosing(); |
46 virtual bool OnMessageReceived(const IPC::Message& message); | 52 virtual bool OnMessageReceived(const IPC::Message& message); |
47 | 53 |
48 // ResourceDispatcherHost::Receiver methods: | 54 // ResourceDispatcherHost::Receiver methods: |
49 virtual bool Send(IPC::Message* message); | 55 virtual bool Send(IPC::Message* message); |
50 | 56 |
51 // Add request to the list of outstanding requests. | 57 // Add request to the list of outstanding requests. |
52 virtual bool RegisterRequest(URLRequestAutomationJob* job); | 58 virtual bool RegisterRequest(URLRequestAutomationJob* job); |
53 | 59 |
54 // Remove request from the list of outstanding requests. | 60 // Remove request from the list of outstanding requests. |
55 virtual void UnRegisterRequest(URLRequestAutomationJob* job); | 61 virtual void UnRegisterRequest(URLRequestAutomationJob* job); |
56 | 62 |
57 // Can be called from the UI thread. | 63 // Can be called from the UI thread. |
58 static bool RegisterRenderView(int renderer_pid, int renderer_id, | 64 static bool RegisterRenderView(int renderer_pid, int renderer_id, |
59 int tab_handle, AutomationResourceMessageFilter* filter); | 65 int tab_handle, AutomationResourceMessageFilter* filter); |
60 static void UnRegisterRenderView(int renderer_pid, int renderer_id); | 66 static void UnRegisterRenderView(int renderer_pid, int renderer_id); |
61 | 67 |
62 // Called only on the IO thread. | 68 // Called only on the IO thread. |
63 static bool LookupRegisteredRenderView( | 69 static bool LookupRegisteredRenderView( |
64 int renderer_pid, int renderer_id, AutomationDetails* details); | 70 int renderer_pid, int renderer_id, AutomationDetails* details); |
65 | 71 |
| 72 // Sends the download request to the automation host. |
| 73 bool SendDownloadRequestToHost(int routing_id, int tab_handle, |
| 74 int request_id); |
| 75 |
66 protected: | 76 protected: |
| 77 // Retrieves the automation request id for the passed in chrome request |
| 78 // id and returns it in the automation_request_id parameter. |
| 79 // Returns true on success. |
| 80 bool GetAutomationRequestId(int request_id, int* automation_request_id); |
| 81 |
67 static void RegisterRenderViewInIOThread(int renderer_pid, int renderer_id, | 82 static void RegisterRenderViewInIOThread(int renderer_pid, int renderer_id, |
68 int tab_handle, AutomationResourceMessageFilter* filter); | 83 int tab_handle, AutomationResourceMessageFilter* filter); |
69 static void UnRegisterRenderViewInIOThread(int renderer_pid, int renderer_id); | 84 static void UnRegisterRenderViewInIOThread(int renderer_pid, int renderer_id); |
70 | 85 |
71 private: | 86 private: |
72 void OnSetFilteredInet(bool enable); | 87 void OnSetFilteredInet(bool enable); |
73 void OnGetFilteredInetHitCount(int* hit_count); | 88 void OnGetFilteredInetHitCount(int* hit_count); |
74 void OnRecordHistograms(const std::vector<std::string>& histogram_list); | 89 void OnRecordHistograms(const std::vector<std::string>& histogram_list); |
75 | 90 |
76 // A unique renderer id is a combination of renderer process id and | 91 // A unique renderer id is a combination of renderer process id and |
(...skipping 10 matching lines...) Expand all Loading... |
87 } | 102 } |
88 }; | 103 }; |
89 | 104 |
90 typedef std::map<RendererId, AutomationDetails> RenderViewMap; | 105 typedef std::map<RendererId, AutomationDetails> RenderViewMap; |
91 typedef std::map<int, scoped_refptr<URLRequestAutomationJob> > RequestMap; | 106 typedef std::map<int, scoped_refptr<URLRequestAutomationJob> > RequestMap; |
92 | 107 |
93 // The channel associated with the automation connection. This pointer is not | 108 // The channel associated with the automation connection. This pointer is not |
94 // owned by this class. | 109 // owned by this class. |
95 IPC::Channel* channel_; | 110 IPC::Channel* channel_; |
96 | 111 |
| 112 // A unique request id per process. |
| 113 static int unique_request_id_; |
| 114 |
97 // Map of outstanding requests. | 115 // Map of outstanding requests. |
98 RequestMap request_map_; | 116 RequestMap request_map_; |
99 | 117 |
100 // Map of render views interested in diverting url requests over automation. | 118 // Map of render views interested in diverting url requests over automation. |
101 static RenderViewMap filtered_render_views_; | 119 static RenderViewMap filtered_render_views_; |
102 | 120 |
103 DISALLOW_COPY_AND_ASSIGN(AutomationResourceMessageFilter); | 121 DISALLOW_COPY_AND_ASSIGN(AutomationResourceMessageFilter); |
104 }; | 122 }; |
105 | 123 |
106 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_MSG_FILTER_H_ | 124 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_MSG_FILTER_H_ |
107 | 125 |
OLD | NEW |