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); |
}; |