OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_url_request_context_getter.h" | 5 #include "content/shell/browser/shell_url_request_context_getter.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 storage_->set_http_transaction_factory(main_cache); | 203 storage_->set_http_transaction_factory(main_cache); |
204 | 204 |
205 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 205 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
206 new net::URLRequestJobFactoryImpl()); | 206 new net::URLRequestJobFactoryImpl()); |
207 // Keep ProtocolHandlers added in sync with | 207 // Keep ProtocolHandlers added in sync with |
208 // ShellContentBrowserClient::IsHandledURL(). | 208 // ShellContentBrowserClient::IsHandledURL(). |
209 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); | 209 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); |
210 bool set_protocol = job_factory->SetProtocolHandler( | 210 bool set_protocol = job_factory->SetProtocolHandler( |
211 url::kDataScheme, new net::DataProtocolHandler); | 211 url::kDataScheme, new net::DataProtocolHandler); |
212 DCHECK(set_protocol); | 212 DCHECK(set_protocol); |
| 213 #if !defined(DISABLE_FILE_SUPPORT) |
213 set_protocol = job_factory->SetProtocolHandler( | 214 set_protocol = job_factory->SetProtocolHandler( |
214 url::kFileScheme, | 215 url::kFileScheme, |
215 new net::FileProtocolHandler( | 216 new net::FileProtocolHandler( |
216 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 217 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
217 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); | 218 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); |
218 DCHECK(set_protocol); | 219 DCHECK(set_protocol); |
| 220 #endif |
219 | 221 |
220 // Set up interceptors in the reverse order. | 222 // Set up interceptors in the reverse order. |
221 scoped_ptr<net::URLRequestJobFactory> top_job_factory = | 223 scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
222 job_factory.PassAs<net::URLRequestJobFactory>(); | 224 job_factory.PassAs<net::URLRequestJobFactory>(); |
223 for (URLRequestInterceptorScopedVector::reverse_iterator i = | 225 for (URLRequestInterceptorScopedVector::reverse_iterator i = |
224 request_interceptors_.rbegin(); | 226 request_interceptors_.rbegin(); |
225 i != request_interceptors_.rend(); | 227 i != request_interceptors_.rend(); |
226 ++i) { | 228 ++i) { |
227 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | 229 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
228 top_job_factory.Pass(), make_scoped_ptr(*i))); | 230 top_job_factory.Pass(), make_scoped_ptr(*i))); |
229 } | 231 } |
230 request_interceptors_.weak_clear(); | 232 request_interceptors_.weak_clear(); |
231 | 233 |
232 storage_->set_job_factory(top_job_factory.release()); | 234 storage_->set_job_factory(top_job_factory.release()); |
233 } | 235 } |
234 | 236 |
235 return url_request_context_.get(); | 237 return url_request_context_.get(); |
236 } | 238 } |
237 | 239 |
238 scoped_refptr<base::SingleThreadTaskRunner> | 240 scoped_refptr<base::SingleThreadTaskRunner> |
239 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { | 241 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
240 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 242 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
241 } | 243 } |
242 | 244 |
243 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 245 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
244 return url_request_context_->host_resolver(); | 246 return url_request_context_->host_resolver(); |
245 } | 247 } |
246 | 248 |
247 } // namespace content | 249 } // namespace content |
OLD | NEW |