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

Unified Diff: 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 | « proxy_resolver.h ('k') | utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: proxy_resolver.cc
diff --git a/proxy_resolver.cc b/proxy_resolver.cc
index 4ec8d1e73b9c58ef99cabebbd9ef5a5263f8ddcd..26dff7bc112be1346d4fded4c25deae10cb2702b 100644
--- a/proxy_resolver.cc
+++ b/proxy_resolver.cc
@@ -11,11 +11,32 @@ namespace chromeos_update_engine {
const char kNoProxy[] = "direct://";
-bool DirectProxyResolver::GetProxiesForUrl(const string& url,
- deque<string>* out_proxies) {
- out_proxies->clear();
- out_proxies->push_back(kNoProxy);
+DirectProxyResolver::~DirectProxyResolver() {
+ if (idle_callback_id_) {
+ g_source_remove(idle_callback_id_);
+ idle_callback_id_ = 0;
+ }
+}
+
+bool DirectProxyResolver::GetProxiesForUrl(const std::string& url,
+ ProxiesResolvedFn callback,
+ void* data) {
+ google::protobuf::Closure* closure =
+ google::protobuf::NewCallback(this,
+ &DirectProxyResolver::ReturnCallback,
+ callback,
+ data);
+ idle_callback_id_ = g_idle_add(utils::GlibRunClosure, closure);
return true;
}
+void DirectProxyResolver::ReturnCallback(ProxiesResolvedFn callback,
+ void* data) {
+ idle_callback_id_ = 0;
+ std::deque<std::string> proxies;
+ proxies.push_back(kNoProxy);
+ (*callback)(proxies, data);
+}
+
+
} // namespace chromeos_update_engine
« no previous file with comments | « proxy_resolver.h ('k') | utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698