| 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_RESOLVE_PROXY_MSG_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_RESOLVE_PROXY_MSG_HELPER_H_ |
| 6 #define CONTENT_BROWSER_RESOLVE_PROXY_MSG_HELPER_H_ | 6 #define CONTENT_BROWSER_RESOLVE_PROXY_MSG_HELPER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "content/public/browser/browser_message_filter.h" | 13 #include "content/public/browser/browser_message_filter.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "net/proxy/proxy_service.h" | 16 #include "net/proxy/proxy_service.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 class URLRequestContextGetter; | 19 class URLRequestContextGetter; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace content { |
| 23 |
| 22 // Responds to ChildProcessHostMsg_ResolveProxy, kicking off a ProxyResolve | 24 // Responds to ChildProcessHostMsg_ResolveProxy, kicking off a ProxyResolve |
| 23 // request on the IO thread using the specified proxy service. Completion is | 25 // request on the IO thread using the specified proxy service. Completion is |
| 24 // notified through the delegate. If multiple requests are started at the same | 26 // notified through the delegate. If multiple requests are started at the same |
| 25 // time, they will run in FIFO order, with only 1 being outstanding at a time. | 27 // time, they will run in FIFO order, with only 1 being outstanding at a time. |
| 26 // | 28 // |
| 27 // When an instance of ResolveProxyMsgHelper is destroyed, it cancels any | 29 // When an instance of ResolveProxyMsgHelper is destroyed, it cancels any |
| 28 // outstanding proxy resolve requests with the proxy service. It also deletes | 30 // outstanding proxy resolve requests with the proxy service. It also deletes |
| 29 // the stored IPC::Message pointers for pending requests. | 31 // the stored IPC::Message pointers for pending requests. |
| 30 // | 32 // |
| 31 // This object is expected to live on the IO thread. | 33 // This object is expected to live on the IO thread. |
| 32 class CONTENT_EXPORT ResolveProxyMsgHelper | 34 class CONTENT_EXPORT ResolveProxyMsgHelper : public BrowserMessageFilter { |
| 33 : public content::BrowserMessageFilter { | |
| 34 public: | 35 public: |
| 35 explicit ResolveProxyMsgHelper(net::URLRequestContextGetter* getter); | 36 explicit ResolveProxyMsgHelper(net::URLRequestContextGetter* getter); |
| 36 // Constructor used by unittests. | 37 // Constructor used by unittests. |
| 37 explicit ResolveProxyMsgHelper(net::ProxyService* proxy_service); | 38 explicit ResolveProxyMsgHelper(net::ProxyService* proxy_service); |
| 38 | 39 |
| 39 // content::BrowserMessageFilter implementation | 40 // BrowserMessageFilter implementation |
| 40 virtual bool OnMessageReceived(const IPC::Message& message, | 41 virtual bool OnMessageReceived(const IPC::Message& message, |
| 41 bool* message_was_ok) OVERRIDE; | 42 bool* message_was_ok) OVERRIDE; |
| 42 | 43 |
| 43 void OnResolveProxy(const GURL& url, IPC::Message* reply_msg); | 44 void OnResolveProxy(const GURL& url, IPC::Message* reply_msg); |
| 44 | 45 |
| 45 protected: | 46 protected: |
| 46 // Destruction cancels the current outstanding request, and clears the | 47 // Destruction cancels the current outstanding request, and clears the |
| 47 // pending queue. | 48 // pending queue. |
| 48 virtual ~ResolveProxyMsgHelper(); | 49 virtual ~ResolveProxyMsgHelper(); |
| 49 | 50 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 74 net::ProxyInfo proxy_info_; | 75 net::ProxyInfo proxy_info_; |
| 75 | 76 |
| 76 // FIFO queue of pending requests. The first entry is always the current one. | 77 // FIFO queue of pending requests. The first entry is always the current one. |
| 77 typedef std::deque<PendingRequest> PendingRequestList; | 78 typedef std::deque<PendingRequest> PendingRequestList; |
| 78 PendingRequestList pending_requests_; | 79 PendingRequestList pending_requests_; |
| 79 | 80 |
| 80 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 81 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 81 net::ProxyService* proxy_service_; | 82 net::ProxyService* proxy_service_; |
| 82 }; | 83 }; |
| 83 | 84 |
| 85 } // namespace content |
| 86 |
| 84 #endif // CONTENT_BROWSER_RESOLVE_PROXY_MSG_HELPER_H_ | 87 #endif // CONTENT_BROWSER_RESOLVE_PROXY_MSG_HELPER_H_ |
| OLD | NEW |