OLD | NEW |
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 "net/url_request/url_request_context_builder.h" | 5 #include "net/url_request/url_request_context_builder.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 void StartFileThread() { | 149 void StartFileThread() { |
150 file_thread_.StartWithOptions( | 150 file_thread_.StartWithOptions( |
151 base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0)); | 151 base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0)); |
152 } | 152 } |
153 | 153 |
154 base::MessageLoop* file_message_loop() { | 154 base::MessageLoop* file_message_loop() { |
155 DCHECK(file_thread_.IsRunning()); | 155 DCHECK(file_thread_.IsRunning()); |
156 return file_thread_.message_loop(); | 156 return file_thread_.message_loop(); |
157 } | 157 } |
158 | 158 |
| 159 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy() { |
| 160 DCHECK(file_thread_.IsRunning()); |
| 161 return file_thread_.message_loop_proxy(); |
| 162 } |
| 163 |
159 protected: | 164 protected: |
160 virtual ~BasicURLRequestContext() {} | 165 virtual ~BasicURLRequestContext() {} |
161 | 166 |
162 private: | 167 private: |
163 base::Thread cache_thread_; | 168 base::Thread cache_thread_; |
164 base::Thread file_thread_; | 169 base::Thread file_thread_; |
165 URLRequestContextStorage storage_; | 170 URLRequestContextStorage storage_; |
166 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext); | 171 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext); |
167 }; | 172 }; |
168 | 173 |
(...skipping 14 matching lines...) Expand all Loading... |
183 | 188 |
184 URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() | 189 URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() |
185 {} | 190 {} |
186 | 191 |
187 URLRequestContextBuilder::URLRequestContextBuilder() | 192 URLRequestContextBuilder::URLRequestContextBuilder() |
188 : data_enabled_(false), | 193 : data_enabled_(false), |
189 file_enabled_(false), | 194 file_enabled_(false), |
190 #if !defined(DISABLE_FTP_SUPPORT) | 195 #if !defined(DISABLE_FTP_SUPPORT) |
191 ftp_enabled_(false), | 196 ftp_enabled_(false), |
192 #endif | 197 #endif |
193 http_cache_enabled_(true) {} | 198 http_cache_enabled_(true) { |
| 199 } |
| 200 |
194 URLRequestContextBuilder::~URLRequestContextBuilder() {} | 201 URLRequestContextBuilder::~URLRequestContextBuilder() {} |
195 | 202 |
196 #if defined(OS_LINUX) || defined(OS_ANDROID) | 203 #if defined(OS_LINUX) || defined(OS_ANDROID) |
197 void URLRequestContextBuilder::set_proxy_config_service( | 204 void URLRequestContextBuilder::set_proxy_config_service( |
198 ProxyConfigService* proxy_config_service) { | 205 ProxyConfigService* proxy_config_service) { |
199 proxy_config_service_.reset(proxy_config_service); | 206 proxy_config_service_.reset(proxy_config_service); |
200 } | 207 } |
201 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 208 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
202 | 209 |
203 URLRequestContext* URLRequestContextBuilder::Build() { | 210 URLRequestContext* URLRequestContextBuilder::Build() { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 new net::HttpNetworkSession(network_session_params)); | 301 new net::HttpNetworkSession(network_session_params)); |
295 | 302 |
296 http_transaction_factory = new HttpNetworkLayer(network_session.get()); | 303 http_transaction_factory = new HttpNetworkLayer(network_session.get()); |
297 } | 304 } |
298 storage->set_http_transaction_factory(http_transaction_factory); | 305 storage->set_http_transaction_factory(http_transaction_factory); |
299 | 306 |
300 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl; | 307 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl; |
301 if (data_enabled_) | 308 if (data_enabled_) |
302 job_factory->SetProtocolHandler("data", new DataProtocolHandler); | 309 job_factory->SetProtocolHandler("data", new DataProtocolHandler); |
303 if (file_enabled_) | 310 if (file_enabled_) |
304 job_factory->SetProtocolHandler("file", new FileProtocolHandler); | 311 job_factory->SetProtocolHandler( |
| 312 "file", new FileProtocolHandler(context->file_message_loop_proxy())); |
305 #if !defined(DISABLE_FTP_SUPPORT) | 313 #if !defined(DISABLE_FTP_SUPPORT) |
306 if (ftp_enabled_) { | 314 if (ftp_enabled_) { |
307 ftp_transaction_factory_.reset( | 315 ftp_transaction_factory_.reset( |
308 new FtpNetworkLayer(context->host_resolver())); | 316 new FtpNetworkLayer(context->host_resolver())); |
309 job_factory->SetProtocolHandler("ftp", | 317 job_factory->SetProtocolHandler("ftp", |
310 new FtpProtocolHandler(ftp_transaction_factory_.get())); | 318 new FtpProtocolHandler(ftp_transaction_factory_.get())); |
311 } | 319 } |
312 #endif | 320 #endif |
313 storage->set_job_factory(job_factory); | 321 storage->set_job_factory(job_factory); |
314 | 322 |
315 // TODO(willchan): Support sdch. | 323 // TODO(willchan): Support sdch. |
316 | 324 |
317 return context; | 325 return context; |
318 } | 326 } |
319 | 327 |
320 } // namespace net | 328 } // namespace net |
OLD | NEW |