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

Side by Side Diff: chrome/browser/net/resolve_proxy_msg_helper.cc

Issue 258008: Move initialization of ChromeURLRequestContexts to the IO thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync again, just in case Created 11 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium 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 "chrome/browser/net/resolve_proxy_msg_helper.h" 5 #include "chrome/browser/net/resolve_proxy_msg_helper.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "chrome/browser/profile.h" 8 #include "chrome/browser/profile.h"
9 #include "chrome/browser/net/url_request_context_getter.h"
9 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
10 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
11 12
12 ResolveProxyMsgHelper::ResolveProxyMsgHelper(Delegate* delegate, 13 ResolveProxyMsgHelper::ResolveProxyMsgHelper(Delegate* delegate,
13 net::ProxyService* proxy_service) 14 net::ProxyService* proxy_service)
14 : proxy_service_(NULL), 15 : proxy_service_(NULL),
15 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( 16 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
16 this, &ResolveProxyMsgHelper::OnResolveProxyCompleted)), 17 this, &ResolveProxyMsgHelper::OnResolveProxyCompleted)),
17 delegate_(delegate), 18 delegate_(delegate),
18 proxy_service_override_(proxy_service) { 19 proxy_service_override_(proxy_service) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 bool ResolveProxyMsgHelper::GetProxyService( 75 bool ResolveProxyMsgHelper::GetProxyService(
75 scoped_refptr<net::ProxyService>* out) const { 76 scoped_refptr<net::ProxyService>* out) const {
76 // Unit-tests specify their own proxy service to use. 77 // Unit-tests specify their own proxy service to use.
77 if (proxy_service_override_) { 78 if (proxy_service_override_) {
78 *out = proxy_service_override_; 79 *out = proxy_service_override_;
79 return true; 80 return true;
80 } 81 }
81 82
82 // If there is no default request context (say during shut down). 83 // If there is no default request context (say during shut down).
83 URLRequestContext* context = Profile::GetDefaultRequestContext(); 84 URLRequestContextGetter* context_getter =
84 if (!context) 85 Profile::GetDefaultRequestContext();
86 if (!context_getter)
85 return false; 87 return false;
86 88
87 // Otherwise use the browser's global proxy service. 89 // Otherwise use the browser's global proxy service.
88 *out = context->proxy_service(); 90 *out = context_getter->GetURLRequestContext()->proxy_service();
89 return true; 91 return true;
90 } 92 }
91 93
92 ResolveProxyMsgHelper::~ResolveProxyMsgHelper() { 94 ResolveProxyMsgHelper::~ResolveProxyMsgHelper() {
93 // Clear all pending requests. 95 // Clear all pending requests.
94 if (!pending_requests_.empty()) { 96 if (!pending_requests_.empty()) {
95 PendingRequest req = pending_requests_.front(); 97 PendingRequest req = pending_requests_.front();
96 proxy_service_->CancelPacRequest(req.pac_req); 98 proxy_service_->CancelPacRequest(req.pac_req);
97 } 99 }
98 100
99 for (PendingRequestList::iterator it = pending_requests_.begin(); 101 for (PendingRequestList::iterator it = pending_requests_.begin();
100 it != pending_requests_.end(); 102 it != pending_requests_.end();
101 ++it) { 103 ++it) {
102 delete it->reply_msg; 104 delete it->reply_msg;
103 } 105 }
104 106
105 proxy_service_ = NULL; 107 proxy_service_ = NULL;
106 pending_requests_.clear(); 108 pending_requests_.clear();
107 } 109 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.cc ('k') | chrome/browser/net/sdch_dictionary_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698