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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const char kNetworkQualityEstimatorFieldTrialName[] = "NetworkQualityEstimator"; | 133 const char kNetworkQualityEstimatorFieldTrialName[] = "NetworkQualityEstimator"; |
134 | 134 |
135 // Field trial for NPN. | 135 // Field trial for NPN. |
136 const char kNpnTrialName[] = "NPN"; | 136 const char kNpnTrialName[] = "NPN"; |
137 const char kNpnTrialEnabledGroupNamePrefix[] = "Enable"; | 137 const char kNpnTrialEnabledGroupNamePrefix[] = "Enable"; |
138 const char kNpnTrialDisabledGroupNamePrefix[] = "Disable"; | 138 const char kNpnTrialDisabledGroupNamePrefix[] = "Disable"; |
139 | 139 |
140 // Used for the "system" URLRequestContext. | 140 // Used for the "system" URLRequestContext. |
141 class SystemURLRequestContext : public net::URLRequestContext { | 141 class SystemURLRequestContext : public net::URLRequestContext { |
142 public: | 142 public: |
143 SystemURLRequestContext() { net::SetURLRequestContextForNSSHttpIO(this); } | 143 SystemURLRequestContext() { |
| 144 #if defined(USE_NSS_VERIFIER) |
| 145 net::SetURLRequestContextForNSSHttpIO(this); |
| 146 #endif |
| 147 } |
144 | 148 |
145 private: | 149 private: |
146 ~SystemURLRequestContext() override { | 150 ~SystemURLRequestContext() override { |
147 AssertNoURLRequests(); | 151 AssertNoURLRequests(); |
| 152 #if defined(USE_NSS_VERIFIER) |
148 net::SetURLRequestContextForNSSHttpIO(nullptr); | 153 net::SetURLRequestContextForNSSHttpIO(nullptr); |
| 154 #endif |
149 } | 155 } |
150 }; | 156 }; |
151 | 157 |
152 scoped_ptr<net::HostResolver> CreateGlobalHostResolver(net::NetLog* net_log) { | 158 scoped_ptr<net::HostResolver> CreateGlobalHostResolver(net::NetLog* net_log) { |
153 TRACE_EVENT0("startup", "IOSChromeIOThread::CreateGlobalHostResolver"); | 159 TRACE_EVENT0("startup", "IOSChromeIOThread::CreateGlobalHostResolver"); |
154 const base::CommandLine& command_line = | 160 const base::CommandLine& command_line = |
155 *base::CommandLine::ForCurrentProcess(); | 161 *base::CommandLine::ForCurrentProcess(); |
156 | 162 |
157 scoped_ptr<net::HostResolver> global_host_resolver = | 163 scoped_ptr<net::HostResolver> global_host_resolver = |
158 net::HostResolver::CreateSystemResolver(net::HostResolver::Options(), | 164 net::HostResolver::CreateSystemResolver(net::HostResolver::Options(), |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 if (!system_url_request_context_getter_.get()) { | 376 if (!system_url_request_context_getter_.get()) { |
371 InitSystemRequestContext(); | 377 InitSystemRequestContext(); |
372 } | 378 } |
373 return system_url_request_context_getter_.get(); | 379 return system_url_request_context_getter_.get(); |
374 } | 380 } |
375 | 381 |
376 void IOSChromeIOThread::Init() { | 382 void IOSChromeIOThread::Init() { |
377 TRACE_EVENT0("startup", "IOSChromeIOThread::Init"); | 383 TRACE_EVENT0("startup", "IOSChromeIOThread::Init"); |
378 DCHECK_CURRENTLY_ON(web::WebThread::IO); | 384 DCHECK_CURRENTLY_ON(web::WebThread::IO); |
379 | 385 |
| 386 #if defined(USE_NSS_VERIFIER) |
380 net::SetMessageLoopForNSSHttpIO(); | 387 net::SetMessageLoopForNSSHttpIO(); |
| 388 #endif |
381 | 389 |
382 const base::CommandLine& command_line = | 390 const base::CommandLine& command_line = |
383 *base::CommandLine::ForCurrentProcess(); | 391 *base::CommandLine::ForCurrentProcess(); |
384 | 392 |
385 DCHECK(!globals_); | 393 DCHECK(!globals_); |
386 globals_ = new Globals; | 394 globals_ = new Globals; |
387 | 395 |
388 // Add an observer that will emit network change events to the ChromeNetLog. | 396 // Add an observer that will emit network change events to the ChromeNetLog. |
389 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be | 397 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
390 // logging the network change before other IO thread consumers respond to it. | 398 // logging the network change before other IO thread consumers respond to it. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // get it onto the message loop while the IOSChromeIOThread object still | 475 // get it onto the message loop while the IOSChromeIOThread object still |
468 // exists. However, the message might not be processed on the UI | 476 // exists. However, the message might not be processed on the UI |
469 // thread until after IOSChromeIOThread is gone, so use a weak pointer. | 477 // thread until after IOSChromeIOThread is gone, so use a weak pointer. |
470 web::WebThread::PostTask( | 478 web::WebThread::PostTask( |
471 web::WebThread::UI, FROM_HERE, | 479 web::WebThread::UI, FROM_HERE, |
472 base::Bind(&IOSChromeIOThread::InitSystemRequestContext, | 480 base::Bind(&IOSChromeIOThread::InitSystemRequestContext, |
473 weak_factory_.GetWeakPtr())); | 481 weak_factory_.GetWeakPtr())); |
474 } | 482 } |
475 | 483 |
476 void IOSChromeIOThread::CleanUp() { | 484 void IOSChromeIOThread::CleanUp() { |
| 485 #if defined(USE_NSS_VERIFIER) |
477 net::ShutdownNSSHttpIO(); | 486 net::ShutdownNSSHttpIO(); |
| 487 #endif |
478 | 488 |
479 system_url_request_context_getter_ = nullptr; | 489 system_url_request_context_getter_ = nullptr; |
480 | 490 |
481 // Release objects that the net::URLRequestContext could have been pointing | 491 // Release objects that the net::URLRequestContext could have been pointing |
482 // to. | 492 // to. |
483 | 493 |
484 // Shutdown the HistogramWatcher on the IO thread. | 494 // Shutdown the HistogramWatcher on the IO thread. |
485 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); | 495 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
486 | 496 |
487 // This must be reset before the ChromeNetLog is destroyed. | 497 // This must be reset before the ChromeNetLog is destroyed. |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 | 1054 |
1045 globals->system_http_network_session.reset( | 1055 globals->system_http_network_session.reset( |
1046 new net::HttpNetworkSession(system_params)); | 1056 new net::HttpNetworkSession(system_params)); |
1047 globals->system_http_transaction_factory.reset( | 1057 globals->system_http_transaction_factory.reset( |
1048 new net::HttpNetworkLayer(globals->system_http_network_session.get())); | 1058 new net::HttpNetworkLayer(globals->system_http_network_session.get())); |
1049 context->set_http_transaction_factory( | 1059 context->set_http_transaction_factory( |
1050 globals->system_http_transaction_factory.get()); | 1060 globals->system_http_transaction_factory.get()); |
1051 | 1061 |
1052 return context; | 1062 return context; |
1053 } | 1063 } |
OLD | NEW |