Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/task_scheduler/post_task.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/cookie_store_factory.h" | 20 #include "content/public/browser/cookie_store_factory.h" |
| 21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 #include "content/shell/browser/shell_network_delegate.h" | 22 #include "content/shell/browser/shell_network_delegate.h" |
| 23 #include "content/shell/common/shell_content_client.h" | 23 #include "content/shell/common/shell_content_client.h" |
| 24 #include "content/shell/common/shell_switches.h" | 24 #include "content/shell/common/shell_switches.h" |
| 25 #include "net/base/cache_type.h" | 25 #include "net/base/cache_type.h" |
| 26 #include "net/cert/cert_verifier.h" | 26 #include "net/cert/cert_verifier.h" |
| 27 #include "net/cert/ct_policy_enforcer.h" | 27 #include "net/cert/ct_policy_enforcer.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 // Keep ProtocolHandlers added in sync with | 250 // Keep ProtocolHandlers added in sync with |
| 251 // ShellContentBrowserClient::IsHandledURL(). | 251 // ShellContentBrowserClient::IsHandledURL(). |
| 252 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); | 252 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); |
| 253 bool set_protocol = job_factory->SetProtocolHandler( | 253 bool set_protocol = job_factory->SetProtocolHandler( |
| 254 url::kDataScheme, base::WrapUnique(new net::DataProtocolHandler)); | 254 url::kDataScheme, base::WrapUnique(new net::DataProtocolHandler)); |
| 255 DCHECK(set_protocol); | 255 DCHECK(set_protocol); |
| 256 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) | 256 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) |
| 257 set_protocol = job_factory->SetProtocolHandler( | 257 set_protocol = job_factory->SetProtocolHandler( |
| 258 url::kFileScheme, | 258 url::kFileScheme, |
| 259 base::MakeUnique<net::FileProtocolHandler>( | 259 base::MakeUnique<net::FileProtocolHandler>( |
| 260 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 260 base::CreateTaskRunnerWithTraits( |
| 261 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); | 261 base::TaskTraits() |
| 262 .MayBlock() | |
| 263 .WithPriority(base::TaskPriority::BACKGROUND) | |
|
Peter Beverloo
2017/04/26 14:30:37
The protocol handlers for file:// and content:// (
fdoray
2017/04/26 18:00:37
Done. https://codereview.chromium.org/2845683002/
| |
| 264 .WithShutdownBehavior( | |
| 265 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN)))); | |
| 262 DCHECK(set_protocol); | 266 DCHECK(set_protocol); |
| 263 #endif | 267 #endif |
| 264 | 268 |
| 265 // Set up interceptors in the reverse order. | 269 // Set up interceptors in the reverse order. |
| 266 std::unique_ptr<net::URLRequestJobFactory> top_job_factory = | 270 std::unique_ptr<net::URLRequestJobFactory> top_job_factory = |
| 267 std::move(job_factory); | 271 std::move(job_factory); |
| 268 for (auto i = request_interceptors_.rbegin(); | 272 for (auto i = request_interceptors_.rbegin(); |
| 269 i != request_interceptors_.rend(); ++i) { | 273 i != request_interceptors_.rend(); ++i) { |
| 270 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | 274 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
| 271 std::move(top_job_factory), std::move(*i))); | 275 std::move(top_job_factory), std::move(*i))); |
| 272 } | 276 } |
| 273 request_interceptors_.clear(); | 277 request_interceptors_.clear(); |
| 274 | 278 |
| 275 storage_->set_job_factory(std::move(top_job_factory)); | 279 storage_->set_job_factory(std::move(top_job_factory)); |
| 276 } | 280 } |
| 277 | 281 |
| 278 return url_request_context_.get(); | 282 return url_request_context_.get(); |
| 279 } | 283 } |
| 280 | 284 |
| 281 scoped_refptr<base::SingleThreadTaskRunner> | 285 scoped_refptr<base::SingleThreadTaskRunner> |
| 282 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { | 286 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 283 return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); | 287 return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
| 284 } | 288 } |
| 285 | 289 |
| 286 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 290 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
| 287 return url_request_context_->host_resolver(); | 291 return url_request_context_->host_resolver(); |
| 288 } | 292 } |
| 289 | 293 |
| 290 } // namespace content | 294 } // namespace content |
| OLD | NEW |