Index: net/proxy/proxy_service.h |
=================================================================== |
--- net/proxy/proxy_service.h (revision 8870) |
+++ net/proxy/proxy_service.h (working copy) |
@@ -13,13 +13,10 @@ |
#include "base/string_util.h" |
#include "base/thread.h" |
#include "base/time.h" |
+#include "base/waitable_event.h" |
#include "googleurl/src/gurl.h" |
#include "net/base/completion_callback.h" |
-#if defined(OS_WIN) |
-typedef LPVOID HINTERNET; // From winhttp.h |
-#endif |
- |
class GURL; |
namespace net { |
@@ -93,9 +90,9 @@ |
// Used internally to handle PAC queries. |
class PacRequest; |
- // Returns OK if proxy information could be provided synchronously. Else, |
- // ERR_IO_PENDING is returned to indicate that the result will be available |
- // when the callback is run. The callback is run on the thread that calls |
+ // Returns ERR_IO_PENDING if the proxy information could not be provided |
wtc
2009/01/30 23:06:06
Ah, so this block comment still needs to be update
|
+ // synchronously, to indicate that the result will be available when the |
+ // callback is run. The callback is run on the thread that calls |
// ResolveProxy. |
// |
// The caller is responsible for ensuring that |results| and |callback| |
@@ -245,11 +242,6 @@ |
// This may optionally be a semi-colon delimited list of proxy servers. |
void UseNamedProxy(const std::string& proxy_server); |
-#if defined(OS_WIN) |
- // Apply this proxy information to the given WinHTTP request handle. |
- void Apply(HINTERNET request_handle); |
-#endif |
- |
// Returns true if this proxy info specifies a direct connection. |
bool is_direct() const { return proxy_list_.Get().empty(); } |
@@ -312,6 +304,31 @@ |
ProxyInfo* results) = 0; |
}; |
+// Wrapper for invoking methods on a ProxyService synchronously. |
+class SyncProxyServiceHelper |
+ : public base::RefCountedThreadSafe<SyncProxyServiceHelper> { |
+ public: |
+ SyncProxyServiceHelper(MessageLoop* io_message_loop, |
+ ProxyService* proxy_service); |
+ |
+ int ResolveProxy(const GURL& url, ProxyInfo* proxy_info); |
+ int ReconsiderProxyAfterError(const GURL& url, ProxyInfo* proxy_info); |
+ |
+ private: |
+ void StartAsyncResolve(const GURL& url); |
+ void StartAsyncReconsider(const GURL& url); |
+ |
+ void OnCompletion(int result); |
+ |
+ MessageLoop* io_message_loop_; |
+ ProxyService* proxy_service_; |
+ |
+ base::WaitableEvent event_; |
+ CompletionCallbackImpl<SyncProxyServiceHelper> callback_; |
+ ProxyInfo proxy_info_; |
+ int result_; |
+}; |
+ |
} // namespace net |
#endif // NET_PROXY_PROXY_SERVICE_H_ |