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" |
11 #include "base/lock.h" | 11 #include "base/lock.h" |
12 #include "base/platform_thread.h" | 12 #include "base/platform_thread.h" |
13 #include "ipc/ipc_channel_proxy.h" | 13 #include "ipc/ipc_channel_proxy.h" |
14 | 14 |
15 class URLRequestAutomationJob; | 15 class URLRequestAutomationJob; |
16 class MessageLoop; | |
17 | 16 |
18 // This class filters out incoming automation IPC messages for network | 17 // This class filters out incoming automation IPC messages for network |
19 // requests and processes them on the IPC thread. As a result, network | 18 // requests and processes them on the IPC thread. As a result, network |
20 // requests are not delayed by costly UI processing that may be occurring | 19 // requests are not delayed by costly UI processing that may be occurring |
21 // on the main thread of the browser. It also means that any hangs in | 20 // on the main thread of the browser. It also means that any hangs in |
22 // starting a network request will not interfere with browser UI. | 21 // starting a network request will not interfere with browser UI. |
23 class AutomationResourceMessageFilter | 22 class AutomationResourceMessageFilter |
24 : public IPC::ChannelProxy::MessageFilter, | 23 : public IPC::ChannelProxy::MessageFilter, |
25 public IPC::Message::Sender { | 24 public IPC::Message::Sender { |
26 public: | 25 public: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return ((pid_ == rhs.pid_) ? (id_ < rhs.id_) : (pid_ < rhs.pid_)); | 90 return ((pid_ == rhs.pid_) ? (id_ < rhs.id_) : (pid_ < rhs.pid_)); |
92 } | 91 } |
93 }; | 92 }; |
94 | 93 |
95 typedef std::map<RendererId, AutomationDetails> RenderViewMap; | 94 typedef std::map<RendererId, AutomationDetails> RenderViewMap; |
96 typedef std::map<int, scoped_refptr<URLRequestAutomationJob> > RequestMap; | 95 typedef std::map<int, scoped_refptr<URLRequestAutomationJob> > RequestMap; |
97 | 96 |
98 // The channel associated with the automation connection. This pointer is not | 97 // The channel associated with the automation connection. This pointer is not |
99 // owned by this class. | 98 // owned by this class. |
100 IPC::Channel* channel_; | 99 IPC::Channel* channel_; |
101 static MessageLoop* io_loop_; | |
102 | 100 |
103 // A unique request id per process. | 101 // A unique request id per process. |
104 static int unique_request_id_; | 102 static int unique_request_id_; |
105 | 103 |
106 // Map of outstanding requests. | 104 // Map of outstanding requests. |
107 RequestMap request_map_; | 105 RequestMap request_map_; |
108 | 106 |
109 // Map of render views interested in diverting url requests over automation. | 107 // Map of render views interested in diverting url requests over automation. |
110 static RenderViewMap filtered_render_views_; | 108 static RenderViewMap filtered_render_views_; |
111 | 109 |
112 DISALLOW_COPY_AND_ASSIGN(AutomationResourceMessageFilter); | 110 DISALLOW_COPY_AND_ASSIGN(AutomationResourceMessageFilter); |
113 }; | 111 }; |
114 | 112 |
115 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_MSG_FILTER_H_ | 113 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_MSG_FILTER_H_ |
116 | 114 |
OLD | NEW |