OLD | NEW |
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 google::protobuf::Closure; |
8 using std::deque; | 8 using std::deque; |
9 using std::string; | 9 using std::string; |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 post_data_.insert(post_data_.end(), char_data, char_data + size); | 24 post_data_.insert(post_data_.end(), char_data, char_data + size); |
25 } | 25 } |
26 | 26 |
27 // Proxy methods to set the proxies, then to pop them off. | 27 // Proxy methods to set the proxies, then to pop them off. |
28 bool HttpFetcher::ResolveProxiesForUrl(const string& url, Closure* callback) { | 28 bool HttpFetcher::ResolveProxiesForUrl(const string& url, Closure* callback) { |
29 if (!proxy_resolver_) { | 29 if (!proxy_resolver_) { |
30 LOG(INFO) << "Not resolving proxies (no proxy resolver)."; | 30 LOG(INFO) << "Not resolving proxies (no proxy resolver)."; |
31 no_resolver_idle_id_ = g_idle_add(utils::GlibRunClosure, callback); | 31 no_resolver_idle_id_ = g_idle_add(utils::GlibRunClosure, callback); |
32 return true; | 32 return true; |
33 } | 33 } |
| 34 CHECK_EQ(reinterpret_cast<Closure*>(NULL), callback_); |
34 callback_ = callback; | 35 callback_ = callback; |
35 return proxy_resolver_->GetProxiesForUrl(url, | 36 return proxy_resolver_->GetProxiesForUrl(url, |
36 &HttpFetcher::StaticProxiesResolved, | 37 &HttpFetcher::StaticProxiesResolved, |
37 this); | 38 this); |
38 } | 39 } |
39 | 40 |
40 void HttpFetcher::ProxiesResolved(const std::deque<std::string>& proxies) { | 41 void HttpFetcher::ProxiesResolved(const std::deque<std::string>& proxies) { |
41 no_resolver_idle_id_ = 0; | 42 no_resolver_idle_id_ = 0; |
42 if (!proxies.empty()) | 43 if (!proxies.empty()) |
43 SetProxies(proxies); | 44 SetProxies(proxies); |
44 callback_->Run(); | 45 CHECK_NE(reinterpret_cast<Closure*>(NULL), callback_); |
| 46 Closure* callback = callback_; |
45 callback_ = NULL; | 47 callback_ = NULL; |
| 48 // This may indirectly call back into ResolveProxiesForUrl(): |
| 49 callback->Run(); |
46 } | 50 } |
47 | 51 |
48 } // namespace chromeos_update_engine | 52 } // namespace chromeos_update_engine |
OLD | NEW |