Chromium Code Reviews| 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 "chrome/browser/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 message_size, | 283 message_size, |
| 284 is_cellular)); | 284 is_cellular)); |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace | 287 } // namespace |
| 288 | 288 |
| 289 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { | 289 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { |
| 290 public: | 290 public: |
| 291 explicit SystemURLRequestContextGetter(IOThread* io_thread); | 291 explicit SystemURLRequestContextGetter(IOThread* io_thread); |
| 292 | 292 |
| 293 // Implementation for net::UrlRequestContextGetter. | 293 // net::URLRequestContextGetter implementation. |
|
eroman
2017/02/21 22:14:23
Was this a manual change or something the linter d
wangyix1
2017/02/22 01:28:18
I manually changed this. I don't really know why.
| |
| 294 net::URLRequestContext* GetURLRequestContext() override; | 294 net::URLRequestContext* GetURLRequestContext() override; |
| 295 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 295 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
| 296 const override; | 296 const override; |
| 297 | 297 |
| 298 protected: | 298 protected: |
| 299 ~SystemURLRequestContextGetter() override; | 299 ~SystemURLRequestContextGetter() override; |
| 300 | 300 |
| 301 private: | 301 private: |
| 302 IOThread* const io_thread_; // Weak pointer, owned by BrowserProcess. | 302 IOThread* const io_thread_; // Weak pointer, owned by BrowserProcess. |
| 303 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 303 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 318 DCHECK(io_thread_->globals()->system_request_context.get()); | 318 DCHECK(io_thread_->globals()->system_request_context.get()); |
| 319 | 319 |
| 320 return io_thread_->globals()->system_request_context.get(); | 320 return io_thread_->globals()->system_request_context.get(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 scoped_refptr<base::SingleThreadTaskRunner> | 323 scoped_refptr<base::SingleThreadTaskRunner> |
| 324 SystemURLRequestContextGetter::GetNetworkTaskRunner() const { | 324 SystemURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 325 return network_task_runner_; | 325 return network_task_runner_; |
| 326 } | 326 } |
| 327 | 327 |
| 328 class ProxyScriptFetcherContextGetter : public net::URLRequestContextGetter { | |
| 329 public: | |
| 330 explicit ProxyScriptFetcherContextGetter(IOThread* io_thread); | |
| 331 | |
| 332 // net::URLRequestContextGetter implementation. | |
| 333 net::URLRequestContext* GetURLRequestContext() override; | |
| 334 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | |
| 335 const override; | |
| 336 | |
| 337 protected: | |
| 338 ~ProxyScriptFetcherContextGetter() override; | |
| 339 | |
| 340 private: | |
| 341 IOThread* const io_thread_; // Weak pointer, owned by BrowserProcess. | |
|
eroman
2017/02/21 22:14:23
Can remove "weak pointer" (which has specific mean
wangyix1
2017/02/22 01:28:18
Done.
| |
| 342 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | |
|
eroman
2017/02/21 22:14:23
Instead of this member variable how about just ret
wangyix1
2017/02/22 01:28:18
Done.
| |
| 343 | |
| 344 base::debug::LeakTracker<ProxyScriptFetcherContextGetter> leak_tracker_; | |
| 345 }; | |
| 346 | |
| 347 ProxyScriptFetcherContextGetter::ProxyScriptFetcherContextGetter( | |
| 348 IOThread* io_thread) | |
| 349 : io_thread_(io_thread), | |
| 350 network_task_runner_( | |
| 351 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)) {} | |
| 352 | |
| 353 ProxyScriptFetcherContextGetter::~ProxyScriptFetcherContextGetter() {} | |
| 354 | |
| 355 net::URLRequestContext* | |
| 356 ProxyScriptFetcherContextGetter::GetURLRequestContext() { | |
| 357 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 358 DCHECK(io_thread_->globals()->proxy_script_fetcher_context.get()); | |
| 359 | |
| 360 return io_thread_->globals()->proxy_script_fetcher_context.get(); | |
| 361 } | |
| 362 | |
| 363 scoped_refptr<base::SingleThreadTaskRunner> | |
| 364 ProxyScriptFetcherContextGetter::GetNetworkTaskRunner() const { | |
| 365 return network_task_runner_; | |
| 366 } | |
| 367 | |
| 328 IOThread::Globals:: | 368 IOThread::Globals:: |
| 329 SystemRequestContextLeakChecker::SystemRequestContextLeakChecker( | 369 SystemRequestContextLeakChecker::SystemRequestContextLeakChecker( |
| 330 Globals* globals) | 370 Globals* globals) |
| 331 : globals_(globals) { | 371 : globals_(globals) { |
| 332 DCHECK(globals_); | 372 DCHECK(globals_); |
| 333 } | 373 } |
| 334 | 374 |
| 335 IOThread::Globals:: | 375 IOThread::Globals:: |
| 336 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { | 376 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { |
| 337 if (globals_->system_request_context.get()) | 377 if (globals_->system_request_context.get()) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 } | 522 } |
| 483 | 523 |
| 484 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { | 524 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { |
| 485 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 525 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 486 if (!system_url_request_context_getter_.get()) { | 526 if (!system_url_request_context_getter_.get()) { |
| 487 InitSystemRequestContext(); | 527 InitSystemRequestContext(); |
| 488 } | 528 } |
| 489 return system_url_request_context_getter_.get(); | 529 return system_url_request_context_getter_.get(); |
| 490 } | 530 } |
| 491 | 531 |
| 532 net::URLRequestContextGetter* IOThread::proxy_script_fetcher_context_getter() { | |
| 533 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 534 return proxy_script_fetcher_context_getter_.get(); | |
| 535 } | |
| 536 | |
| 492 void IOThread::Init() { | 537 void IOThread::Init() { |
| 493 TRACE_EVENT0("startup", "IOThread::InitAsync"); | 538 TRACE_EVENT0("startup", "IOThread::InitAsync"); |
| 494 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 539 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 495 | 540 |
| 496 #if defined(USE_NSS_CERTS) | 541 #if defined(USE_NSS_CERTS) |
| 497 net::SetMessageLoopForNSSHttpIO(); | 542 net::SetMessageLoopForNSSHttpIO(); |
| 498 #endif | 543 #endif |
| 499 | 544 |
| 500 const base::CommandLine& command_line = | 545 const base::CommandLine& command_line = |
| 501 *base::CommandLine::ForCurrentProcess(); | 546 *base::CommandLine::ForCurrentProcess(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 ConfigureParamsFromFieldTrialsAndCommandLine( | 694 ConfigureParamsFromFieldTrialsAndCommandLine( |
| 650 command_line, is_quic_allowed_by_policy_, | 695 command_line, is_quic_allowed_by_policy_, |
| 651 http_09_on_non_default_ports_enabled_, ¶ms_); | 696 http_09_on_non_default_ports_enabled_, ¶ms_); |
| 652 | 697 |
| 653 TRACE_EVENT_BEGIN0("startup", | 698 TRACE_EVENT_BEGIN0("startup", |
| 654 "IOThread::Init:ProxyScriptFetcherRequestContext"); | 699 "IOThread::Init:ProxyScriptFetcherRequestContext"); |
| 655 globals_->proxy_script_fetcher_context.reset( | 700 globals_->proxy_script_fetcher_context.reset( |
| 656 ConstructProxyScriptFetcherContext(globals_, params_, net_log_)); | 701 ConstructProxyScriptFetcherContext(globals_, params_, net_log_)); |
| 657 TRACE_EVENT_END0("startup", | 702 TRACE_EVENT_END0("startup", |
| 658 "IOThread::Init:ProxyScriptFetcherRequestContext"); | 703 "IOThread::Init:ProxyScriptFetcherRequestContext"); |
| 704 proxy_script_fetcher_context_getter_ = | |
| 705 new ProxyScriptFetcherContextGetter(this); | |
| 659 | 706 |
| 660 #if defined(OS_MACOSX) | 707 #if defined(OS_MACOSX) |
| 661 // Start observing Keychain events. This needs to be done on the UI thread, | 708 // Start observing Keychain events. This needs to be done on the UI thread, |
| 662 // as Keychain services requires a CFRunLoop. | 709 // as Keychain services requires a CFRunLoop. |
| 663 BrowserThread::PostTask(BrowserThread::UI, | 710 BrowserThread::PostTask(BrowserThread::UI, |
| 664 FROM_HERE, | 711 FROM_HERE, |
| 665 base::Bind(&ObserveKeychainEvents)); | 712 base::Bind(&ObserveKeychainEvents)); |
| 666 #endif | 713 #endif |
| 667 | 714 |
| 668 // InitSystemRequestContext turns right around and posts a task back | 715 // InitSystemRequestContext turns right around and posts a task back |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); | 763 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
| 717 | 764 |
| 718 // This must be reset before the ChromeNetLog is destroyed. | 765 // This must be reset before the ChromeNetLog is destroyed. |
| 719 network_change_observer_.reset(); | 766 network_change_observer_.reset(); |
| 720 | 767 |
| 721 system_proxy_config_service_.reset(); | 768 system_proxy_config_service_.reset(); |
| 722 delete globals_; | 769 delete globals_; |
| 723 globals_ = NULL; | 770 globals_ = NULL; |
| 724 | 771 |
| 725 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); | 772 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); |
| 773 base::debug::LeakTracker<ProxyScriptFetcherContextGetter>::CheckForLeaks(); | |
| 726 } | 774 } |
| 727 | 775 |
| 728 // static | 776 // static |
| 729 void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { | 777 void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { |
| 730 registry->RegisterStringPref(prefs::kAuthSchemes, | 778 registry->RegisterStringPref(prefs::kAuthSchemes, |
| 731 "basic,digest,ntlm,negotiate"); | 779 "basic,digest,ntlm,negotiate"); |
| 732 registry->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, false); | 780 registry->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, false); |
| 733 registry->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); | 781 registry->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); |
| 734 registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); | 782 registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); |
| 735 registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, | 783 registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1112 | 1160 |
| 1113 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1161 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 1114 // system URLRequestContext too. There's no reason this should be tied to a | 1162 // system URLRequestContext too. There's no reason this should be tied to a |
| 1115 // profile. | 1163 // profile. |
| 1116 return context; | 1164 return context; |
| 1117 } | 1165 } |
| 1118 | 1166 |
| 1119 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { | 1167 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { |
| 1120 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); | 1168 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); |
| 1121 } | 1169 } |
| OLD | NEW |