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

Unified Diff: proxy_resolver.h

Issue 6516026: AU: Make proxy resolution asynchronous. (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: fix utils.* include paths Created 9 years, 10 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 | « libcurl_http_fetcher.cc ('k') | proxy_resolver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: proxy_resolver.h
diff --git a/proxy_resolver.h b/proxy_resolver.h
index af228d2a5a875f993ae487a7272e1ae2c7b2bdf1..53fd9207b5e77bfe348e2d8f959132136295e8ef 100644
--- a/proxy_resolver.h
+++ b/proxy_resolver.h
@@ -5,28 +5,39 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__
-#include <base/logging.h>
#include <deque>
#include <string>
+#include <base/logging.h>
+#include <google/protobuf/stubs/common.h>
+
+#include "update_engine/utils.h"
+
namespace chromeos_update_engine {
extern const char kNoProxy[];
+// Callback for a call to GetProxiesForUrl().
+// Resultant proxies are in |out_proxy|. Each will be in one of the
+// following forms:
+// http://<host>[:<port>] - HTTP proxy
+// socks{4,5}://<host>[:<port>] - SOCKS4/5 proxy
+// kNoProxy - no proxy
+typedef void (*ProxiesResolvedFn)(const std::deque<std::string>& proxies,
+ void* data);
+
class ProxyResolver {
public:
ProxyResolver() {}
virtual ~ProxyResolver() {}
- // Stores a list of proxies for a given |url| in |out_proxy|.
- // Returns true on success. The resultant proxy will be in one of the
- // following forms:
- // http://<host>[:<port>] - HTTP proxy
- // socks{4,5}://<host>[:<port>] - SOCKS4/5 proxy
- // kNoProxy - no proxy
+ // Finds proxies for the given URL and returns them via the callback.
+ // |data| will be passed to the callback.
+ // Returns true on success.
virtual bool GetProxiesForUrl(const std::string& url,
- std::deque<std::string>* out_proxies) = 0;
+ ProxiesResolvedFn callback,
+ void* data) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ProxyResolver);
@@ -35,11 +46,18 @@ class ProxyResolver {
// Always says to not use a proxy
class DirectProxyResolver : public ProxyResolver {
public:
- DirectProxyResolver() {}
+ DirectProxyResolver() : idle_callback_id_(0) {}
+ virtual ~DirectProxyResolver();
virtual bool GetProxiesForUrl(const std::string& url,
- std::deque<std::string>* out_proxies);
+ ProxiesResolvedFn callback,
+ void* data);
private:
+ // The ID of the idle main loop callback
+ guint idle_callback_id_;
+
+ // The MainLoop callback, from here we return to the client.
+ void ReturnCallback(ProxiesResolvedFn callback, void* data);
DISALLOW_COPY_AND_ASSIGN(DirectProxyResolver);
};
« no previous file with comments | « libcurl_http_fetcher.cc ('k') | proxy_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698