Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__ |
| 7 | 7 |
| 8 #include <base/logging.h> | |
| 9 | 8 |
| 10 #include <deque> | 9 #include <deque> |
| 11 #include <string> | 10 #include <string> |
| 12 | 11 |
| 12 #include <base/logging.h> | |
| 13 #include <google/protobuf/stubs/common.h> | |
| 14 | |
| 15 #include "update_engine/utils.h" | |
| 16 | |
| 13 namespace chromeos_update_engine { | 17 namespace chromeos_update_engine { |
| 14 | 18 |
| 15 extern const char kNoProxy[]; | 19 extern const char kNoProxy[]; |
| 16 | 20 |
| 21 // Callback for a call to GetProxiesForUrl(). | |
| 22 // Resultant proxies are in |out_proxy|. Each will be in one of the | |
| 23 // following forms: | |
| 24 // http://<host>[:<port>] - HTTP proxy | |
| 25 // socks{4,5}://<host>[:<port>] - SOCKS4/5 proxy | |
| 26 // kNoProxy - no proxy | |
| 27 typedef void (*ProxiesResolvedFn)(const std::deque<std::string>& proxies, | |
| 28 void* data); | |
| 29 | |
| 17 class ProxyResolver { | 30 class ProxyResolver { |
| 18 public: | 31 public: |
| 19 ProxyResolver() {} | 32 ProxyResolver() {} |
| 20 virtual ~ProxyResolver() {} | 33 virtual ~ProxyResolver() {} |
| 21 | 34 |
| 22 // Stores a list of proxies for a given |url| in |out_proxy|. | 35 // Finds proxies for the given URL and returns them via the callback. |
| 23 // Returns true on success. The resultant proxy will be in one of the | 36 // |data| will be passed to the callback. |
| 24 // following forms: | 37 // Returns true on success. |
| 25 // http://<host>[:<port>] - HTTP proxy | |
| 26 // socks{4,5}://<host>[:<port>] - SOCKS4/5 proxy | |
| 27 // kNoProxy - no proxy | |
| 28 virtual bool GetProxiesForUrl(const std::string& url, | 38 virtual bool GetProxiesForUrl(const std::string& url, |
| 29 std::deque<std::string>* out_proxies) = 0; | 39 ProxiesResolvedFn callback, |
| 40 void* data) = 0; | |
| 30 | 41 |
| 31 private: | 42 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(ProxyResolver); | 43 DISALLOW_COPY_AND_ASSIGN(ProxyResolver); |
| 33 }; | 44 }; |
| 34 | 45 |
| 35 // Always says to not use a proxy | 46 // Always says to not use a proxy |
| 36 class DirectProxyResolver : public ProxyResolver { | 47 class DirectProxyResolver : public ProxyResolver { |
| 37 public: | 48 public: |
| 38 DirectProxyResolver() {} | 49 DirectProxyResolver() : idle_callback_id_(0) {} |
| 50 » virtual ~DirectProxyResolver(); | |
|
petkov
2011/02/14 22:13:50
s/tab/spaces/
adlr
2011/02/16 18:18:22
Done.
| |
| 39 virtual bool GetProxiesForUrl(const std::string& url, | 51 virtual bool GetProxiesForUrl(const std::string& url, |
| 40 std::deque<std::string>* out_proxies); | 52 ProxiesResolvedFn callback, |
| 53 void* data); | |
| 41 | 54 |
| 42 private: | 55 private: |
| 56 // The ID of the idle main loop callback | |
| 57 guint idle_callback_id_; | |
|
petkov
2011/02/14 22:13:50
fix indentation
adlr
2011/02/16 18:18:22
Done.
| |
| 58 | |
| 59 // The MainLoop callback, from here we return to the client. | |
| 60 void ReturnCallback(ProxiesResolvedFn callback, void* data); | |
| 43 DISALLOW_COPY_AND_ASSIGN(DirectProxyResolver); | 61 DISALLOW_COPY_AND_ASSIGN(DirectProxyResolver); |
| 44 }; | 62 }; |
| 45 | 63 |
| 46 } // namespace chromeos_update_engine | 64 } // namespace chromeos_update_engine |
| 47 | 65 |
| 48 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__ | 66 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__ |
| OLD | NEW |