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

Side by Side Diff: chrome_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome_proxy_resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_CHROME_PROXY_RESOLVER_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_CHROME_PROXY_RESOLVER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_CHROME_PROXY_RESOLVER_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_CHROME_PROXY_RESOLVER_H__
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 10
11 #include <curl/curl.h> 11 #include <curl/curl.h>
12 #include <gtest/gtest_prod.h> // for FRIEND_TEST 12 #include <gtest/gtest_prod.h> // for FRIEND_TEST
13 13
14 #include "update_engine/dbus_interface.h" 14 #include "update_engine/dbus_interface.h"
15 #include "update_engine/proxy_resolver.h" 15 #include "update_engine/proxy_resolver.h"
16 16
17 namespace chromeos_update_engine { 17 namespace chromeos_update_engine {
18 18
19 extern const char kSessionManagerService[]; 19 extern const char kSessionManagerService[];
20 extern const char kSessionManagerPath[]; 20 extern const char kSessionManagerPath[];
21 extern const char kSessionManagerInterface[]; 21 extern const char kSessionManagerInterface[];
22 extern const char kSessionManagerRetrievePropertyMethod[]; 22 extern const char kSessionManagerRetrievePropertyMethod[];
23 extern const char kSessionManagerProxySettingsKey[]; 23 extern const char kSessionManagerProxySettingsKey[];
24 24
25 // Class to resolve proxy for a url based on Chrome's proxy settings. 25 // Class to resolve proxy for a url based on Chrome's proxy settings.
26 26
27 // Currently only supports manual settings, not PAC files or autodetected 27 // Currently only supports manual settings, not PAC files or autodetected
28 // settings. 28 // settings.
29 29
30 struct ChromeProxyResolverClosureArgs {
31 std::string url;
32 ProxiesResolvedFn callback;
33 void* data;
34 };
35
30 class ChromeProxyResolver : public ProxyResolver { 36 class ChromeProxyResolver : public ProxyResolver {
31 public: 37 public:
32 explicit ChromeProxyResolver(DbusGlibInterface* dbus) : dbus_(dbus) {} 38 explicit ChromeProxyResolver(DbusGlibInterface* dbus) : dbus_(dbus) {}
33 virtual ~ChromeProxyResolver() {} 39 virtual ~ChromeProxyResolver() {}
34 40
35 virtual bool GetProxiesForUrl(const std::string& url, 41 virtual bool GetProxiesForUrl(const std::string& url,
36 std::deque<std::string>* out_proxies); 42 ProxiesResolvedFn callback,
43 void* data);
37 44
38 // Get the curl proxy type for a given proxy url. Returns true on success. 45 // Get the curl proxy type for a given proxy url. Returns true on success.
39 // Note: if proxy is kNoProxy, this will return false. 46 // Note: if proxy is kNoProxy, this will return false.
40 static bool GetProxyType(const std::string& proxy, curl_proxytype* out_type); 47 static bool GetProxyType(const std::string& proxy, curl_proxytype* out_type);
41 48
42 private: 49 private:
43 FRIEND_TEST(ChromeProxyResolverTest, GetProxiesForUrlWithSettingsTest); 50 FRIEND_TEST(ChromeProxyResolverTest, GetProxiesForUrlWithSettingsTest);
44 51
52 // Closure callback, so we can pretend we need to wait on the main loop
53 // before returing proxies to the client.
54 void GetProxiesForUrlCallback(ChromeProxyResolverClosureArgs args);
55
45 // Fetches a dbus proxy to session manager. Returns NULL on failure. 56 // Fetches a dbus proxy to session manager. Returns NULL on failure.
46 DBusGProxy* DbusProxy(); 57 DBusGProxy* DbusProxy();
47 58
48 // Fetches the json-encoded proxy settings string from the session manager. 59 // Fetches the json-encoded proxy settings string from the session manager.
49 bool GetJsonProxySettings(DBusGProxy* proxy, std::string* out_json); 60 bool GetJsonProxySettings(DBusGProxy* proxy, std::string* out_json);
50 61
51 // Given a |url| and the json encoded settings |json_settings|, 62 // Given a |url| and the json encoded settings |json_settings|,
52 // returns the proper proxy servers in |out_proxies|. Returns true on 63 // returns the proper proxy servers in |out_proxies|. Returns true on
53 // success. 64 // success.
54 bool GetProxiesForUrlWithSettings(const std::string& url, 65 bool GetProxiesForUrlWithSettings(const std::string& url,
55 const std::string& json_settings, 66 const std::string& json_settings,
56 std::deque<std::string>* out_proxies); 67 std::deque<std::string>* out_proxies);
57 68
58 DbusGlibInterface* dbus_; 69 DbusGlibInterface* dbus_;
59 70
60 DISALLOW_COPY_AND_ASSIGN(ChromeProxyResolver); 71 DISALLOW_COPY_AND_ASSIGN(ChromeProxyResolver);
61 }; 72 };
62 73
63 } // namespace chromeos_update_engine 74 } // namespace chromeos_update_engine
64 75
65 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_CHROME_PROXY_RESOLVER_H__ 76 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_CHROME_PROXY_RESOLVER_H__
OLDNEW
« no previous file with comments | « no previous file | chrome_proxy_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698