| Index: headless/lib/browser/headless_url_request_context_getter.cc
|
| diff --git a/blimp/engine/app/blimp_url_request_context_getter.cc b/headless/lib/browser/headless_url_request_context_getter.cc
|
| similarity index 79%
|
| copy from blimp/engine/app/blimp_url_request_context_getter.cc
|
| copy to headless/lib/browser/headless_url_request_context_getter.cc
|
| index 09a96f9a0d85205bf1bee0222b9fc3cc306d63a3..4e8a195458811ad8e85d5652e8a59fdd781aebdf 100644
|
| --- a/blimp/engine/app/blimp_url_request_context_getter.cc
|
| +++ b/headless/lib/browser/headless_url_request_context_getter.cc
|
| @@ -1,28 +1,17 @@
|
| -// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "blimp/engine/app/blimp_url_request_context_getter.h"
|
| -
|
| -#include <algorithm>
|
| +#include "headless/lib/browser/headless_url_request_context_getter.h"
|
|
|
| #include "base/command_line.h"
|
| -#include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/single_thread_task_runner.h"
|
| -#include "base/strings/string_number_conversions.h"
|
| -#include "base/strings/string_split.h"
|
| -#include "base/strings/string_util.h"
|
| -#include "base/threading/sequenced_worker_pool.h"
|
| #include "base/threading/worker_pool.h"
|
| -#include "blimp/engine/app/blimp_network_delegate.h"
|
| -#include "blimp/engine/common/blimp_content_client.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/cookie_store_factory.h"
|
| #include "content/public/common/content_switches.h"
|
| -#include "net/base/cache_type.h"
|
| #include "net/cert/cert_verifier.h"
|
| -#include "net/cookies/cookie_monster.h"
|
| #include "net/dns/host_resolver.h"
|
| #include "net/dns/mapped_host_resolver.h"
|
| #include "net/http/http_auth_handler_factory.h"
|
| @@ -30,7 +19,6 @@
|
| #include "net/http/http_network_session.h"
|
| #include "net/http/http_server_properties_impl.h"
|
| #include "net/http/transport_security_state.h"
|
| -#include "net/proxy/proxy_config_service.h"
|
| #include "net/proxy/proxy_service.h"
|
| #include "net/ssl/channel_id_service.h"
|
| #include "net/ssl/default_channel_id_store.h"
|
| @@ -42,10 +30,8 @@
|
| #include "net/url_request/url_request_context_storage.h"
|
| #include "net/url_request/url_request_intercepting_job_factory.h"
|
| #include "net/url_request/url_request_job_factory_impl.h"
|
| -#include "url/url_constants.h"
|
|
|
| -namespace blimp {
|
| -namespace engine {
|
| +namespace headless {
|
|
|
| namespace {
|
|
|
| @@ -62,19 +48,21 @@ void InstallProtocolHandlers(net::URLRequestJobFactoryImpl* job_factory,
|
|
|
| } // namespace
|
|
|
| -BlimpURLRequestContextGetter::BlimpURLRequestContextGetter(
|
| +HeadlessURLRequestContextGetter::HeadlessURLRequestContextGetter(
|
| bool ignore_certificate_errors,
|
| const base::FilePath& base_path,
|
| - const scoped_refptr<base::SingleThreadTaskRunner>& io_loop_task_runner,
|
| - const scoped_refptr<base::SingleThreadTaskRunner>& file_loop_task_runner,
|
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
|
| + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
|
| content::ProtocolHandlerMap* protocol_handlers,
|
| content::URLRequestInterceptorScopedVector request_interceptors,
|
| - net::NetLog* net_log)
|
| + net::NetLog* net_log,
|
| + const HeadlessBrowser::Options& options)
|
| : ignore_certificate_errors_(ignore_certificate_errors),
|
| base_path_(base_path),
|
| - io_loop_task_runner_(io_loop_task_runner),
|
| - file_loop_task_runner_(file_loop_task_runner),
|
| + io_task_runner_(std::move(io_task_runner)),
|
| + file_task_runner_(std::move(file_task_runner)),
|
| net_log_(net_log),
|
| + options_(options),
|
| request_interceptors_(std::move(request_interceptors)) {
|
| // Must first be created on the UI thread.
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| @@ -87,25 +75,27 @@ BlimpURLRequestContextGetter::BlimpURLRequestContextGetter(
|
| proxy_config_service_ = GetProxyConfigService();
|
| }
|
|
|
| -BlimpURLRequestContextGetter::~BlimpURLRequestContextGetter() {}
|
| +HeadlessURLRequestContextGetter::~HeadlessURLRequestContextGetter() {}
|
|
|
| scoped_ptr<net::NetworkDelegate>
|
| -BlimpURLRequestContextGetter::CreateNetworkDelegate() {
|
| - return make_scoped_ptr(new BlimpNetworkDelegate);
|
| +HeadlessURLRequestContextGetter::CreateNetworkDelegate() {
|
| + return nullptr;
|
| }
|
|
|
| scoped_ptr<net::ProxyConfigService>
|
| -BlimpURLRequestContextGetter::GetProxyConfigService() {
|
| - return net::ProxyService::CreateSystemProxyConfigService(
|
| - io_loop_task_runner_, file_loop_task_runner_);
|
| +HeadlessURLRequestContextGetter::GetProxyConfigService() {
|
| + return net::ProxyService::CreateSystemProxyConfigService(io_task_runner_,
|
| + file_task_runner_);
|
| }
|
|
|
| -scoped_ptr<net::ProxyService> BlimpURLRequestContextGetter::GetProxyService() {
|
| +scoped_ptr<net::ProxyService>
|
| +HeadlessURLRequestContextGetter::GetProxyService() {
|
| return net::ProxyService::CreateUsingSystemProxyResolver(
|
| std::move(proxy_config_service_), 0, url_request_context_->net_log());
|
| }
|
|
|
| -net::URLRequestContext* BlimpURLRequestContextGetter::GetURLRequestContext() {
|
| +net::URLRequestContext*
|
| +HeadlessURLRequestContextGetter::GetURLRequestContext() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
|
|
| if (!url_request_context_) {
|
| @@ -121,11 +111,11 @@ net::URLRequestContext* BlimpURLRequestContextGetter::GetURLRequestContext() {
|
| storage_->set_cookie_store(
|
| content::CreateCookieStore(content::CookieStoreConfig()));
|
| storage_->set_channel_id_service(make_scoped_ptr(
|
| - new net::ChannelIDService(new net::DefaultChannelIDStore(NULL),
|
| + new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr),
|
| base::WorkerPool::GetTaskRunner(true))));
|
| - storage_->set_http_user_agent_settings(
|
| - make_scoped_ptr(new net::StaticHttpUserAgentSettings(
|
| - "en-us,en", GetBlimpEngineUserAgent())));
|
| + // TODO(skyostil): Make language settings configurable.
|
| + storage_->set_http_user_agent_settings(make_scoped_ptr(
|
| + new net::StaticHttpUserAgentSettings("en-us,en", options_.user_agent)));
|
|
|
| scoped_ptr<net::HostResolver> host_resolver(
|
| net::HostResolver::CreateDefaultResolver(
|
| @@ -183,16 +173,23 @@ net::URLRequestContext* BlimpURLRequestContextGetter::GetURLRequestContext() {
|
| storage_->set_http_network_session(
|
| make_scoped_ptr(new net::HttpNetworkSession(network_session_params)));
|
| storage_->set_http_transaction_factory(make_scoped_ptr(new net::HttpCache(
|
| - storage_->http_network_session(), std::move(main_backend), true)));
|
| + storage_->http_network_session(), std::move(main_backend),
|
| + true /* set_up_quic_server_info */)));
|
|
|
| scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
|
| new net::URLRequestJobFactoryImpl());
|
| - // Keep ProtocolHandlers added in sync with
|
| - // BlimpContentBrowserClient::IsHandledURL().
|
| +
|
| InstallProtocolHandlers(job_factory.get(), &protocol_handlers_);
|
| bool set_protocol = job_factory->SetProtocolHandler(
|
| url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler));
|
| DCHECK(set_protocol);
|
| + set_protocol = job_factory->SetProtocolHandler(
|
| + url::kFileScheme,
|
| + make_scoped_ptr(new net::FileProtocolHandler(
|
| + content::BrowserThread::GetBlockingPool()
|
| + ->GetTaskRunnerWithShutdownBehavior(
|
| + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))));
|
| + DCHECK(set_protocol);
|
|
|
| // Set up interceptors in the reverse order so that the last inceptor is at
|
| // the end of the linked list of job factories.
|
| @@ -212,14 +209,13 @@ net::URLRequestContext* BlimpURLRequestContextGetter::GetURLRequestContext() {
|
| }
|
|
|
| scoped_refptr<base::SingleThreadTaskRunner>
|
| -BlimpURLRequestContextGetter::GetNetworkTaskRunner() const {
|
| +HeadlessURLRequestContextGetter::GetNetworkTaskRunner() const {
|
| return content::BrowserThread::GetMessageLoopProxyForThread(
|
| content::BrowserThread::IO);
|
| }
|
|
|
| -net::HostResolver* BlimpURLRequestContextGetter::host_resolver() {
|
| +net::HostResolver* HeadlessURLRequestContextGetter::host_resolver() const {
|
| return url_request_context_->host_resolver();
|
| }
|
|
|
| -} // namespace engine
|
| -} // namespace blimp
|
| +} // namespace headless
|
|
|