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

Unified Diff: http_fetcher.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 | « http_fetcher.h ('k') | http_fetcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: http_fetcher.cc
diff --git a/http_fetcher.cc b/http_fetcher.cc
index 5d006607c6e3697fc29db2edefe867581d9803bd..7d9297a5048938fc8b2e6e11b9cc15fcde14e6a9 100644
--- a/http_fetcher.cc
+++ b/http_fetcher.cc
@@ -4,11 +4,19 @@
#include "update_engine/http_fetcher.h"
+using google::protobuf::Closure;
using std::deque;
using std::string;
namespace chromeos_update_engine {
+HttpFetcher::~HttpFetcher() {
+ if (no_resolver_idle_id_) {
+ g_source_remove(no_resolver_idle_id_);
+ no_resolver_idle_id_ = 0;
+ }
+}
+
void HttpFetcher::SetPostData(const void* data, size_t size) {
post_data_set_ = true;
post_data_.clear();
@@ -17,15 +25,24 @@ void HttpFetcher::SetPostData(const void* data, size_t size) {
}
// Proxy methods to set the proxies, then to pop them off.
-void HttpFetcher::ResolveProxiesForUrl(const string& url) {
+bool HttpFetcher::ResolveProxiesForUrl(const string& url, Closure* callback) {
if (!proxy_resolver_) {
LOG(INFO) << "Not resolving proxies (no proxy resolver).";
- return;
+ no_resolver_idle_id_ = g_idle_add(utils::GlibRunClosure, callback);
+ return true;
}
- deque<string> proxies;
- if (proxy_resolver_->GetProxiesForUrl(url, &proxies)) {
+ callback_ = callback;
+ return proxy_resolver_->GetProxiesForUrl(url,
+ &HttpFetcher::StaticProxiesResolved,
+ this);
+}
+
+void HttpFetcher::ProxiesResolved(const std::deque<std::string>& proxies) {
+ no_resolver_idle_id_ = 0;
+ if (!proxies.empty())
SetProxies(proxies);
- }
+ callback_->Run();
+ callback_ = NULL;
}
} // namespace chromeos_update_engine
« no previous file with comments | « http_fetcher.h ('k') | http_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698