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

Side by Side Diff: chrome/service/net/service_url_request_context.cc

Issue 10912132: Move ProxyConfigService construction onto the IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adjust comments Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/service/net/service_url_request_context.h" 5 #include "chrome/service/net/service_url_request_context.h"
6 6
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) 7 #if defined(OS_POSIX) && !defined(OS_MACOSX)
8 #include <sys/utsname.h> 8 #include <sys/utsname.h>
9 #endif 9 #endif
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/sys_info.h" 14 #include "base/sys_info.h"
15 #include "base/thread_task_runner_handle.h"
15 #include "chrome/common/chrome_version_info.h" 16 #include "chrome/common/chrome_version_info.h"
16 #include "chrome/service/service_process.h" 17 #include "chrome/service/service_process.h"
17 #include "net/base/cert_verifier.h" 18 #include "net/base/cert_verifier.h"
18 #include "net/base/host_resolver.h" 19 #include "net/base/host_resolver.h"
19 #include "net/base/ssl_config_service_defaults.h" 20 #include "net/base/ssl_config_service_defaults.h"
20 #include "net/cookies/cookie_monster.h" 21 #include "net/cookies/cookie_monster.h"
21 #include "net/ftp/ftp_network_layer.h" 22 #include "net/ftp/ftp_network_layer.h"
22 #include "net/http/http_auth_handler_factory.h" 23 #include "net/http/http_auth_handler_factory.h"
23 #include "net/http/http_cache.h" 24 #include "net/http/http_cache.h"
24 #include "net/http/http_network_session.h" 25 #include "net/http/http_network_session.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // If the user agent is set explicitly return that, otherwise call the 151 // If the user agent is set explicitly return that, otherwise call the
151 // base class method to return default value. 152 // base class method to return default value.
152 return user_agent_.empty() ? 153 return user_agent_.empty() ?
153 net::URLRequestContext::GetUserAgent(url) : user_agent_; 154 net::URLRequestContext::GetUserAgent(url) : user_agent_;
154 } 155 }
155 156
156 ServiceURLRequestContext::~ServiceURLRequestContext() { 157 ServiceURLRequestContext::~ServiceURLRequestContext() {
157 } 158 }
158 159
159 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() 160 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter()
160 : network_task_runner_( 161 : glib_task_runner_(base::ThreadTaskRunnerHandle::Get()),
162 network_task_runner_(
161 g_service_process->io_thread()->message_loop_proxy()) { 163 g_service_process->io_thread()->message_loop_proxy()) {
162 // Build the default user agent. 164 // Build the default user agent.
163 user_agent_ = MakeUserAgentForServiceProcess(); 165 user_agent_ = MakeUserAgentForServiceProcess();
166 }
164 167
165 // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a 168 void ServiceURLRequestContextGetter::StartTearDown() {
166 // MessageLoopProxy* instead of MessageLoop*. 169 if (url_request_context_.get())
167 DCHECK(g_service_process); 170 url_request_context_->proxy_service()->StartTearDown();
168 proxy_config_service_.reset(
169 net::ProxyService::CreateSystemProxyConfigService(
170 g_service_process->io_thread()->message_loop_proxy(),
171 g_service_process->file_thread()->message_loop()));
172 } 171 }
173 172
174 net::URLRequestContext* 173 net::URLRequestContext*
175 ServiceURLRequestContextGetter::GetURLRequestContext() { 174 ServiceURLRequestContextGetter::GetURLRequestContext() {
176 if (!url_request_context_.get()) 175 if (!url_request_context_.get()) {
176 // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a
177 // MessageLoopProxy* instead of MessageLoop*.
178 DCHECK(g_service_process);
177 url_request_context_.reset( 179 url_request_context_.reset(
178 new ServiceURLRequestContext(user_agent_, 180 new ServiceURLRequestContext(
179 proxy_config_service_.release())); 181 user_agent_,
182 net::ProxyService::CreateSystemProxyConfigService(
183 glib_task_runner_,
184 g_service_process->file_thread()->message_loop())));
185 }
180 return url_request_context_.get(); 186 return url_request_context_.get();
181 } 187 }
182 188
183 scoped_refptr<base::SingleThreadTaskRunner> 189 scoped_refptr<base::SingleThreadTaskRunner>
184 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { 190 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const {
185 return network_task_runner_; 191 return network_task_runner_;
186 } 192 }
187 193
188 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} 194 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698