OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 NET_PROXY_PROXY_SERVICE_H_ | 5 #ifndef NET_PROXY_PROXY_SERVICE_H_ |
6 #define NET_PROXY_PROXY_SERVICE_H_ | 6 #define NET_PROXY_PROXY_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/thread.h" | 14 #include "base/thread.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "base/waitable_event.h" |
16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
17 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
18 | 19 |
19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
20 typedef LPVOID HINTERNET; // From winhttp.h | 21 typedef LPVOID HINTERNET; // From winhttp.h |
21 #endif | 22 #endif |
22 | 23 |
23 class GURL; | 24 class GURL; |
24 | 25 |
25 namespace net { | 26 namespace net { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 virtual ~ProxyResolver() {} | 306 virtual ~ProxyResolver() {} |
306 | 307 |
307 // Query the proxy auto-config file (specified by |pac_url|) for the proxy to | 308 // Query the proxy auto-config file (specified by |pac_url|) for the proxy to |
308 // use to load the given |query_url|. Returns OK if successful or an error | 309 // use to load the given |query_url|. Returns OK if successful or an error |
309 // code otherwise. | 310 // code otherwise. |
310 virtual int GetProxyForURL(const GURL& query_url, | 311 virtual int GetProxyForURL(const GURL& query_url, |
311 const GURL& pac_url, | 312 const GURL& pac_url, |
312 ProxyInfo* results) = 0; | 313 ProxyInfo* results) = 0; |
313 }; | 314 }; |
314 | 315 |
| 316 // Wrapper for invoking methods on a ProxyService synchronously. |
| 317 class SyncProxyServiceHelper |
| 318 : public base::RefCountedThreadSafe<SyncProxyServiceHelper> { |
| 319 public: |
| 320 SyncProxyServiceHelper(MessageLoop* io_message_loop, |
| 321 ProxyService* proxy_service); |
| 322 |
| 323 int ResolveProxy(const GURL& url, ProxyInfo* proxy_info); |
| 324 int ReconsiderProxyAfterError(const GURL& url, ProxyInfo* proxy_info); |
| 325 |
| 326 private: |
| 327 void StartAsyncResolve(const GURL& url); |
| 328 void StartAsyncReconsider(const GURL& url); |
| 329 |
| 330 void OnCompletion(int result); |
| 331 |
| 332 MessageLoop* io_message_loop_; |
| 333 ProxyService* proxy_service_; |
| 334 |
| 335 base::WaitableEvent event_; |
| 336 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; |
| 337 ProxyInfo proxy_info_; |
| 338 int result_; |
| 339 }; |
| 340 |
315 } // namespace net | 341 } // namespace net |
316 | 342 |
317 #endif // NET_PROXY_PROXY_SERVICE_H_ | 343 #endif // NET_PROXY_PROXY_SERVICE_H_ |
318 | 344 |
OLD | NEW |