| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/ios_chrome_io_thread.h" | 5 #include "ios/chrome/browser/ios_chrome_io_thread.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 // Field trial for priority dependencies. | 141 // Field trial for priority dependencies. |
| 142 const char kSpdyDependenciesFieldTrial[] = "SpdyEnableDependencies"; | 142 const char kSpdyDependenciesFieldTrial[] = "SpdyEnableDependencies"; |
| 143 const char kSpdyDependenciesFieldTrialEnable[] = "Enable"; | 143 const char kSpdyDependenciesFieldTrialEnable[] = "Enable"; |
| 144 const char kSpdyDepencenciesFieldTrialDisable[] = "Disable"; | 144 const char kSpdyDepencenciesFieldTrialDisable[] = "Disable"; |
| 145 | 145 |
| 146 // Used for the "system" URLRequestContext. | 146 // Used for the "system" URLRequestContext. |
| 147 class SystemURLRequestContext : public net::URLRequestContext { | 147 class SystemURLRequestContext : public net::URLRequestContext { |
| 148 public: | 148 public: |
| 149 SystemURLRequestContext() { | 149 SystemURLRequestContext() { |
| 150 #if defined(USE_NSS_VERIFIER) | |
| 151 net::SetURLRequestContextForNSSHttpIO(this); | |
| 152 #endif | |
| 153 } | 150 } |
| 154 | 151 |
| 155 private: | 152 private: |
| 156 ~SystemURLRequestContext() override { | 153 ~SystemURLRequestContext() override { |
| 157 AssertNoURLRequests(); | 154 AssertNoURLRequests(); |
| 158 #if defined(USE_NSS_VERIFIER) | |
| 159 net::SetURLRequestContextForNSSHttpIO(nullptr); | |
| 160 #endif | |
| 161 } | 155 } |
| 162 }; | 156 }; |
| 163 | 157 |
| 164 std::unique_ptr<net::HostResolver> CreateGlobalHostResolver( | 158 std::unique_ptr<net::HostResolver> CreateGlobalHostResolver( |
| 165 net::NetLog* net_log) { | 159 net::NetLog* net_log) { |
| 166 TRACE_EVENT0("startup", "IOSChromeIOThread::CreateGlobalHostResolver"); | 160 TRACE_EVENT0("startup", "IOSChromeIOThread::CreateGlobalHostResolver"); |
| 167 const base::CommandLine& command_line = | 161 const base::CommandLine& command_line = |
| 168 *base::CommandLine::ForCurrentProcess(); | 162 *base::CommandLine::ForCurrentProcess(); |
| 169 | 163 |
| 170 std::unique_ptr<net::HostResolver> global_host_resolver = | 164 std::unique_ptr<net::HostResolver> global_host_resolver = |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 if (!system_url_request_context_getter_.get()) { | 377 if (!system_url_request_context_getter_.get()) { |
| 384 InitSystemRequestContext(); | 378 InitSystemRequestContext(); |
| 385 } | 379 } |
| 386 return system_url_request_context_getter_.get(); | 380 return system_url_request_context_getter_.get(); |
| 387 } | 381 } |
| 388 | 382 |
| 389 void IOSChromeIOThread::Init() { | 383 void IOSChromeIOThread::Init() { |
| 390 TRACE_EVENT0("startup", "IOSChromeIOThread::Init"); | 384 TRACE_EVENT0("startup", "IOSChromeIOThread::Init"); |
| 391 DCHECK_CURRENTLY_ON(web::WebThread::IO); | 385 DCHECK_CURRENTLY_ON(web::WebThread::IO); |
| 392 | 386 |
| 393 #if defined(USE_NSS_VERIFIER) | |
| 394 net::SetMessageLoopForNSSHttpIO(); | |
| 395 #endif | |
| 396 | |
| 397 const base::CommandLine& command_line = | 387 const base::CommandLine& command_line = |
| 398 *base::CommandLine::ForCurrentProcess(); | 388 *base::CommandLine::ForCurrentProcess(); |
| 399 | 389 |
| 400 DCHECK(!globals_); | 390 DCHECK(!globals_); |
| 401 globals_ = new Globals; | 391 globals_ = new Globals; |
| 402 | 392 |
| 403 // Add an observer that will emit network change events to the ChromeNetLog. | 393 // Add an observer that will emit network change events to the ChromeNetLog. |
| 404 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be | 394 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
| 405 // logging the network change before other IO thread consumers respond to it. | 395 // logging the network change before other IO thread consumers respond to it. |
| 406 network_change_observer_.reset(new LoggingNetworkChangeObserver(net_log_)); | 396 network_change_observer_.reset(new LoggingNetworkChangeObserver(net_log_)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // get it onto the message loop while the IOSChromeIOThread object still | 475 // get it onto the message loop while the IOSChromeIOThread object still |
| 486 // exists. However, the message might not be processed on the UI | 476 // exists. However, the message might not be processed on the UI |
| 487 // thread until after IOSChromeIOThread is gone, so use a weak pointer. | 477 // thread until after IOSChromeIOThread is gone, so use a weak pointer. |
| 488 web::WebThread::PostTask( | 478 web::WebThread::PostTask( |
| 489 web::WebThread::UI, FROM_HERE, | 479 web::WebThread::UI, FROM_HERE, |
| 490 base::Bind(&IOSChromeIOThread::InitSystemRequestContext, | 480 base::Bind(&IOSChromeIOThread::InitSystemRequestContext, |
| 491 weak_factory_.GetWeakPtr())); | 481 weak_factory_.GetWeakPtr())); |
| 492 } | 482 } |
| 493 | 483 |
| 494 void IOSChromeIOThread::CleanUp() { | 484 void IOSChromeIOThread::CleanUp() { |
| 495 #if defined(USE_NSS_VERIFIER) | |
| 496 net::ShutdownNSSHttpIO(); | |
| 497 #endif | |
| 498 | |
| 499 system_url_request_context_getter_ = nullptr; | 485 system_url_request_context_getter_ = nullptr; |
| 500 | 486 |
| 501 // Release objects that the net::URLRequestContext could have been pointing | 487 // Release objects that the net::URLRequestContext could have been pointing |
| 502 // to. | 488 // to. |
| 503 | 489 |
| 504 // Shutdown the HistogramWatcher on the IO thread. | 490 // Shutdown the HistogramWatcher on the IO thread. |
| 505 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); | 491 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
| 506 | 492 |
| 507 // This must be reset before the ChromeNetLog is destroyed. | 493 // This must be reset before the ChromeNetLog is destroyed. |
| 508 network_change_observer_.reset(); | 494 network_change_observer_.reset(); |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 | 1033 |
| 1048 globals->system_http_network_session.reset( | 1034 globals->system_http_network_session.reset( |
| 1049 new net::HttpNetworkSession(system_params)); | 1035 new net::HttpNetworkSession(system_params)); |
| 1050 globals->system_http_transaction_factory.reset( | 1036 globals->system_http_transaction_factory.reset( |
| 1051 new net::HttpNetworkLayer(globals->system_http_network_session.get())); | 1037 new net::HttpNetworkLayer(globals->system_http_network_session.get())); |
| 1052 context->set_http_transaction_factory( | 1038 context->set_http_transaction_factory( |
| 1053 globals->system_http_transaction_factory.get()); | 1039 globals->system_http_transaction_factory.get()); |
| 1054 | 1040 |
| 1055 return context; | 1041 return context; |
| 1056 } | 1042 } |
| OLD | NEW |