| 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 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "net/http/http_network_layer.h" | 33 #include "net/http/http_network_layer.h" |
| 34 #include "net/http/http_server_properties_impl.h" | 34 #include "net/http/http_server_properties_impl.h" |
| 35 #include "net/http/http_server_properties_manager.h" | 35 #include "net/http/http_server_properties_manager.h" |
| 36 #include "net/http/transport_security_persister.h" | 36 #include "net/http/transport_security_persister.h" |
| 37 #include "net/http/transport_security_state.h" | 37 #include "net/http/transport_security_state.h" |
| 38 #include "net/quic/chromium/quic_stream_factory.h" | 38 #include "net/quic/chromium/quic_stream_factory.h" |
| 39 #include "net/ssl/channel_id_service.h" | 39 #include "net/ssl/channel_id_service.h" |
| 40 #include "net/ssl/default_channel_id_store.h" | 40 #include "net/ssl/default_channel_id_store.h" |
| 41 #include "net/ssl/ssl_config_service_defaults.h" | 41 #include "net/ssl/ssl_config_service_defaults.h" |
| 42 #include "net/url_request/data_protocol_handler.h" | 42 #include "net/url_request/data_protocol_handler.h" |
| 43 #include "net/url_request/http_protocol_handler.h" |
| 43 #include "net/url_request/static_http_user_agent_settings.h" | 44 #include "net/url_request/static_http_user_agent_settings.h" |
| 44 #include "net/url_request/url_request_context.h" | 45 #include "net/url_request/url_request_context.h" |
| 45 #include "net/url_request/url_request_context_storage.h" | 46 #include "net/url_request/url_request_context_storage.h" |
| 46 #include "net/url_request/url_request_intercepting_job_factory.h" | 47 #include "net/url_request/url_request_intercepting_job_factory.h" |
| 47 #include "net/url_request/url_request_interceptor.h" | 48 #include "net/url_request/url_request_interceptor.h" |
| 48 #include "net/url_request/url_request_job_factory_impl.h" | 49 #include "net/url_request/url_request_job_factory_impl.h" |
| 49 #include "net/url_request/url_request_throttler_manager.h" | 50 #include "net/url_request/url_request_throttler_manager.h" |
| 50 | 51 |
| 51 #if !defined(DISABLE_FILE_SUPPORT) | 52 #if !defined(DISABLE_FILE_SUPPORT) |
| 52 #include "net/url_request/file_protocol_handler.h" // nogncheck | 53 #include "net/url_request/file_protocol_handler.h" // nogncheck |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 } | 476 } |
| 476 | 477 |
| 477 http_transaction_factory.reset(new HttpCache( | 478 http_transaction_factory.reset(new HttpCache( |
| 478 storage->http_network_session(), std::move(http_cache_backend), true)); | 479 storage->http_network_session(), std::move(http_cache_backend), true)); |
| 479 } else { | 480 } else { |
| 480 http_transaction_factory.reset( | 481 http_transaction_factory.reset( |
| 481 new HttpNetworkLayer(storage->http_network_session())); | 482 new HttpNetworkLayer(storage->http_network_session())); |
| 482 } | 483 } |
| 483 storage->set_http_transaction_factory(std::move(http_transaction_factory)); | 484 storage->set_http_transaction_factory(std::move(http_transaction_factory)); |
| 484 | 485 |
| 485 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl; | 486 std::unique_ptr<URLRequestJobFactoryImpl> job_factory = |
| 487 base::WrapUnique(new URLRequestJobFactoryImpl); |
| 486 // Adds caller-provided protocol handlers first so that these handlers are | 488 // Adds caller-provided protocol handlers first so that these handlers are |
| 487 // used over data/file/ftp handlers below. | 489 // used over http/ws/data/file/ftp handlers below. |
| 488 for (auto& scheme_handler : protocol_handlers_) { | 490 for (auto& scheme_handler : protocol_handlers_) { |
| 489 job_factory->SetProtocolHandler(scheme_handler.first, | 491 job_factory->SetProtocolHandler(scheme_handler.first, |
| 490 std::move(scheme_handler.second)); | 492 std::move(scheme_handler.second)); |
| 491 } | 493 } |
| 492 protocol_handlers_.clear(); | 494 protocol_handlers_.clear(); |
| 493 | 495 |
| 496 job_factory->SetProtocolHandler("http", |
| 497 base::WrapUnique(new HttpProtocolHandler)); |
| 498 job_factory->SetProtocolHandler("https", |
| 499 base::WrapUnique(new HttpProtocolHandler)); |
| 500 |
| 501 #if !defined(OS_IOS) |
| 502 job_factory->SetProtocolHandler("ws", |
| 503 base::WrapUnique(new HttpProtocolHandler)); |
| 504 job_factory->SetProtocolHandler("wss", |
| 505 base::WrapUnique(new HttpProtocolHandler)); |
| 506 #endif // !defined(OS_IOS) |
| 507 |
| 494 if (data_enabled_) | 508 if (data_enabled_) |
| 495 job_factory->SetProtocolHandler("data", | 509 job_factory->SetProtocolHandler("data", |
| 496 base::WrapUnique(new DataProtocolHandler)); | 510 base::WrapUnique(new DataProtocolHandler)); |
| 497 | 511 |
| 498 #if !defined(DISABLE_FILE_SUPPORT) | 512 #if !defined(DISABLE_FILE_SUPPORT) |
| 499 if (file_enabled_) { | 513 if (file_enabled_) { |
| 500 job_factory->SetProtocolHandler( | 514 job_factory->SetProtocolHandler( |
| 501 "file", | 515 "file", |
| 502 base::MakeUnique<FileProtocolHandler>(context->GetFileTaskRunner())); | 516 base::MakeUnique<FileProtocolHandler>(context->GetFileTaskRunner())); |
| 503 } | 517 } |
| 504 #endif // !defined(DISABLE_FILE_SUPPORT) | 518 #endif // !defined(DISABLE_FILE_SUPPORT) |
| 505 | 519 |
| 506 #if !defined(DISABLE_FTP_SUPPORT) | 520 #if !defined(DISABLE_FTP_SUPPORT) |
| 507 if (ftp_enabled_) { | 521 if (ftp_enabled_) { |
| 508 ftp_transaction_factory_.reset( | 522 ftp_transaction_factory_.reset( |
| 509 new FtpNetworkLayer(context->host_resolver())); | 523 new FtpNetworkLayer(context->host_resolver())); |
| 510 job_factory->SetProtocolHandler("ftp", base::MakeUnique<FtpProtocolHandler>( | 524 job_factory->SetProtocolHandler("ftp", base::MakeUnique<FtpProtocolHandler>( |
| 511 ftp_transaction_factory_.get())); | 525 ftp_transaction_factory_.get())); |
| 512 } | 526 } |
| 513 #endif // !defined(DISABLE_FTP_SUPPORT) | 527 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 514 | 528 |
| 515 std::unique_ptr<net::URLRequestJobFactory> top_job_factory(job_factory); | 529 std::unique_ptr<net::URLRequestJobFactory> top_job_factory = |
| 530 std::move(job_factory); |
| 531 |
| 516 if (!url_request_interceptors_.empty()) { | 532 if (!url_request_interceptors_.empty()) { |
| 517 // Set up interceptors in the reverse order. | 533 // Set up interceptors in the reverse order. |
| 518 | 534 |
| 519 for (auto i = url_request_interceptors_.rbegin(); | 535 for (auto i = url_request_interceptors_.rbegin(); |
| 520 i != url_request_interceptors_.rend(); ++i) { | 536 i != url_request_interceptors_.rend(); ++i) { |
| 521 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | 537 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
| 522 std::move(top_job_factory), std::move(*i))); | 538 std::move(top_job_factory), std::move(*i))); |
| 523 } | 539 } |
| 524 url_request_interceptors_.clear(); | 540 url_request_interceptors_.clear(); |
| 525 } | 541 } |
| 526 storage->set_job_factory(std::move(top_job_factory)); | 542 storage->set_job_factory(std::move(top_job_factory)); |
| 527 // TODO(willchan): Support sdch. | 543 // TODO(willchan): Support sdch. |
| 528 | 544 |
| 529 return std::move(context); | 545 return std::move(context); |
| 530 } | 546 } |
| 531 | 547 |
| 532 } // namespace net | 548 } // namespace net |
| OLD | NEW |