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

Unified Diff: chrome_proxy_resolver.cc

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 | « chrome_proxy_resolver.h ('k') | chrome_proxy_resolver_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_proxy_resolver.cc
diff --git a/chrome_proxy_resolver.cc b/chrome_proxy_resolver.cc
index 66bc5dc4785ec35c99a670c047871f719a6c39c9..1deab113a2484196892637a16b0117112e56daa6 100644
--- a/chrome_proxy_resolver.cc
+++ b/chrome_proxy_resolver.cc
@@ -10,6 +10,9 @@
#include "update_engine/utils.h"
+using google::protobuf::Closure;
+using google::protobuf::NewCallback;
+using std::deque;
using std::string;
using std::vector;
@@ -24,16 +27,32 @@ const char kSessionManagerProxySettingsKey[] = "cros.proxy.everywhere";
bool ChromeProxyResolver::GetProxiesForUrl(
const std::string& url,
- std::deque<std::string>* out_proxies) {
+ ProxiesResolvedFn callback,
+ void* data) {
+ ChromeProxyResolverClosureArgs args;
+ args.url = url;
+ args.callback = callback;
+ args.data = data;
+ Closure* closure = NewCallback(this,
+ &ChromeProxyResolver::GetProxiesForUrlCallback,
+ args);
+ g_idle_add(utils::GlibRunClosure, closure);
+ return true;
+}
+
+void ChromeProxyResolver::GetProxiesForUrlCallback(
+ ChromeProxyResolverClosureArgs args) {
+ deque<string> proxies;
// First, query dbus for the currently stored settings
DBusGProxy* proxy = DbusProxy();
- TEST_AND_RETURN_FALSE(proxy);
- string json_settings;
- TEST_AND_RETURN_FALSE(GetJsonProxySettings(proxy, &json_settings));
- LOG(INFO) << "got settings:" << json_settings;
- TEST_AND_RETURN_FALSE(
- GetProxiesForUrlWithSettings(url, json_settings, out_proxies));
- return true;
+ if (proxy) {
+ string json_settings;
+ if (GetJsonProxySettings(proxy, &json_settings)) {
+ LOG(INFO) << "got settings:" << json_settings;
+ GetProxiesForUrlWithSettings(args.url, json_settings, &proxies);
+ }
+ }
+ (*args.callback)(proxies, args.data);
}
bool ChromeProxyResolver::GetJsonProxySettings(DBusGProxy* proxy,
« no previous file with comments | « chrome_proxy_resolver.h ('k') | chrome_proxy_resolver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698