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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « proxy_resolver.h ('k') | utils.h » ('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) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 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/proxy_resolver.h" 5 #include "update_engine/proxy_resolver.h"
6 6
7 using std::deque; 7 using std::deque;
8 using std::string; 8 using std::string;
9 9
10 namespace chromeos_update_engine { 10 namespace chromeos_update_engine {
11 11
12 const char kNoProxy[] = "direct://"; 12 const char kNoProxy[] = "direct://";
13 13
14 bool DirectProxyResolver::GetProxiesForUrl(const string& url, 14 DirectProxyResolver::~DirectProxyResolver() {
15 deque<string>* out_proxies) { 15 if (idle_callback_id_) {
16 out_proxies->clear(); 16 g_source_remove(idle_callback_id_);
17 out_proxies->push_back(kNoProxy); 17 idle_callback_id_ = 0;
18 }
19 }
20
21 bool DirectProxyResolver::GetProxiesForUrl(const std::string& url,
22 ProxiesResolvedFn callback,
23 void* data) {
24 google::protobuf::Closure* closure =
25 google::protobuf::NewCallback(this,
26 &DirectProxyResolver::ReturnCallback,
27 callback,
28 data);
29 idle_callback_id_ = g_idle_add(utils::GlibRunClosure, closure);
18 return true; 30 return true;
19 } 31 }
20 32
33 void DirectProxyResolver::ReturnCallback(ProxiesResolvedFn callback,
34 void* data) {
35 idle_callback_id_ = 0;
36 std::deque<std::string> proxies;
37 proxies.push_back(kNoProxy);
38 (*callback)(proxies, data);
39 }
40
41
21 } // namespace chromeos_update_engine 42 } // namespace chromeos_update_engine
OLDNEW
« 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