Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: net/proxy/proxy_service.h

Issue 19502: Get rid of synchronous ResolveProxy API. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/proxy/proxy_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « no previous file | net/proxy/proxy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698