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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « http_fetcher.h ('k') | http_fetcher_unittest.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) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "update_engine/http_fetcher.h" 5 #include "update_engine/http_fetcher.h"
6 6
7 using google::protobuf::Closure;
7 using std::deque; 8 using std::deque;
8 using std::string; 9 using std::string;
9 10
10 namespace chromeos_update_engine { 11 namespace chromeos_update_engine {
11 12
13 HttpFetcher::~HttpFetcher() {
14 if (no_resolver_idle_id_) {
15 g_source_remove(no_resolver_idle_id_);
16 no_resolver_idle_id_ = 0;
17 }
18 }
19
12 void HttpFetcher::SetPostData(const void* data, size_t size) { 20 void HttpFetcher::SetPostData(const void* data, size_t size) {
13 post_data_set_ = true; 21 post_data_set_ = true;
14 post_data_.clear(); 22 post_data_.clear();
15 const char *char_data = reinterpret_cast<const char*>(data); 23 const char *char_data = reinterpret_cast<const char*>(data);
16 post_data_.insert(post_data_.end(), char_data, char_data + size); 24 post_data_.insert(post_data_.end(), char_data, char_data + size);
17 } 25 }
18 26
19 // Proxy methods to set the proxies, then to pop them off. 27 // Proxy methods to set the proxies, then to pop them off.
20 void HttpFetcher::ResolveProxiesForUrl(const string& url) { 28 bool HttpFetcher::ResolveProxiesForUrl(const string& url, Closure* callback) {
21 if (!proxy_resolver_) { 29 if (!proxy_resolver_) {
22 LOG(INFO) << "Not resolving proxies (no proxy resolver)."; 30 LOG(INFO) << "Not resolving proxies (no proxy resolver).";
23 return; 31 no_resolver_idle_id_ = g_idle_add(utils::GlibRunClosure, callback);
32 return true;
24 } 33 }
25 deque<string> proxies; 34 callback_ = callback;
26 if (proxy_resolver_->GetProxiesForUrl(url, &proxies)) { 35 return proxy_resolver_->GetProxiesForUrl(url,
36 &HttpFetcher::StaticProxiesResolved,
37 this);
38 }
39
40 void HttpFetcher::ProxiesResolved(const std::deque<std::string>& proxies) {
41 no_resolver_idle_id_ = 0;
42 if (!proxies.empty())
27 SetProxies(proxies); 43 SetProxies(proxies);
28 } 44 callback_->Run();
45 callback_ = NULL;
29 } 46 }
30 47
31 } // namespace chromeos_update_engine 48 } // namespace chromeos_update_engine
OLDNEW
« 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