Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: chrome/browser/io_thread.cc

Issue 7690006: Revert 97446 - Modifying prefetch to account for multi-profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browsing_data_remover.cc ('k') | chrome/browser/net/connect_interceptor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/leak_tracker.h" 10 #include "base/debug/leak_tracker.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_split.h" 15 #include "base/string_split.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/extensions/extension_event_router_forwarder.h" 20 #include "chrome/browser/extensions/extension_event_router_forwarder.h"
21 #include "chrome/browser/media/media_internals.h" 21 #include "chrome/browser/media/media_internals.h"
22 #include "chrome/browser/net/chrome_network_delegate.h" 22 #include "chrome/browser/net/chrome_network_delegate.h"
23 #include "chrome/browser/net/chrome_net_log.h" 23 #include "chrome/browser/net/chrome_net_log.h"
24 #include "chrome/browser/net/chrome_url_request_context.h" 24 #include "chrome/browser/net/chrome_url_request_context.h"
25 #include "chrome/browser/net/connect_interceptor.h" 25 #include "chrome/browser/net/connect_interceptor.h"
26 #include "chrome/browser/net/passive_log_collector.h" 26 #include "chrome/browser/net/passive_log_collector.h"
27 #include "chrome/browser/net/predictor_api.h"
27 #include "chrome/browser/net/pref_proxy_config_service.h" 28 #include "chrome/browser/net/pref_proxy_config_service.h"
28 #include "chrome/browser/net/proxy_service_factory.h" 29 #include "chrome/browser/net/proxy_service_factory.h"
29 #include "chrome/browser/prefs/pref_service.h" 30 #include "chrome/browser/prefs/pref_service.h"
30 #include "chrome/common/chrome_switches.h" 31 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
32 #include "content/browser/browser_thread.h" 33 #include "content/browser/browser_thread.h"
33 #include "content/browser/gpu/gpu_process_host.h" 34 #include "content/browser/gpu/gpu_process_host.h"
34 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" 35 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h"
35 #include "content/common/url_fetcher.h" 36 #include "content/common/url_fetcher.h"
36 #include "net/base/cert_verifier.h" 37 #include "net/base/cert_verifier.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // |local_state| is passed in explicitly in order to (1) reduce implicit 337 // |local_state| is passed in explicitly in order to (1) reduce implicit
337 // dependencies and (2) make IOThread more flexible for testing. 338 // dependencies and (2) make IOThread more flexible for testing.
338 IOThread::IOThread( 339 IOThread::IOThread(
339 PrefService* local_state, 340 PrefService* local_state,
340 ChromeNetLog* net_log, 341 ChromeNetLog* net_log,
341 ExtensionEventRouterForwarder* extension_event_router_forwarder) 342 ExtensionEventRouterForwarder* extension_event_router_forwarder)
342 : BrowserProcessSubThread(BrowserThread::IO), 343 : BrowserProcessSubThread(BrowserThread::IO),
343 net_log_(net_log), 344 net_log_(net_log),
344 extension_event_router_forwarder_(extension_event_router_forwarder), 345 extension_event_router_forwarder_(extension_event_router_forwarder),
345 globals_(NULL), 346 globals_(NULL),
347 speculative_interceptor_(NULL),
348 predictor_(NULL),
346 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 349 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
347 // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make 350 // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make
348 // sure that everything is initialized in the right order. 351 // sure that everything is initialized in the right order.
349 RegisterPrefs(local_state); 352 RegisterPrefs(local_state);
350 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); 353 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes);
351 negotiate_disable_cname_lookup_ = local_state->GetBoolean( 354 negotiate_disable_cname_lookup_ = local_state->GetBoolean(
352 prefs::kDisableAuthNegotiateCnameLookup); 355 prefs::kDisableAuthNegotiateCnameLookup);
353 negotiate_enable_port_ = local_state->GetBoolean( 356 negotiate_enable_port_ = local_state->GetBoolean(
354 prefs::kEnableAuthNegotiatePort); 357 prefs::kEnableAuthNegotiatePort);
355 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); 358 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist);
(...skipping 21 matching lines...) Expand all
377 380
378 IOThread::Globals* IOThread::globals() { 381 IOThread::Globals* IOThread::globals() {
379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
380 return globals_; 383 return globals_;
381 } 384 }
382 385
383 ChromeNetLog* IOThread::net_log() { 386 ChromeNetLog* IOThread::net_log() {
384 return net_log_; 387 return net_log_;
385 } 388 }
386 389
390 void IOThread::InitNetworkPredictor(
391 bool prefetching_enabled,
392 base::TimeDelta max_dns_queue_delay,
393 size_t max_speculative_parallel_resolves,
394 const chrome_common_net::UrlList& startup_urls,
395 ListValue* referral_list,
396 bool preconnect_enabled) {
397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
398 message_loop()->PostTask(
399 FROM_HERE,
400 NewRunnableMethod(
401 this,
402 &IOThread::InitNetworkPredictorOnIOThread,
403 prefetching_enabled, max_dns_queue_delay,
404 max_speculative_parallel_resolves,
405 startup_urls, referral_list, preconnect_enabled));
406 }
407
408 void IOThread::ChangedToOnTheRecord() {
409 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
410 message_loop()->PostTask(
411 FROM_HERE,
412 NewRunnableMethod(
413 this,
414 &IOThread::ChangedToOnTheRecordOnIOThread));
415 }
416
387 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { 417 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() {
388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
389 if (!system_url_request_context_getter_) { 419 if (!system_url_request_context_getter_) {
390 InitSystemRequestContext(); 420 InitSystemRequestContext();
391 } 421 }
392 return system_url_request_context_getter_; 422 return system_url_request_context_getter_;
393 } 423 }
394 424
425 void IOThread::ClearNetworkingHistory() {
426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
427 ClearHostCache();
428 // Discard acrued data used to speculate in the future.
429 chrome_browser_net::DiscardInitialNavigationHistory();
430 if (predictor_)
431 predictor_->DiscardAllResults();
432 }
433
395 void IOThread::Init() { 434 void IOThread::Init() {
396 // Though this thread is called the "IO" thread, it actually just routes 435 // Though this thread is called the "IO" thread, it actually just routes
397 // messages around; it shouldn't be allowed to perform any blocking disk I/O. 436 // messages around; it shouldn't be allowed to perform any blocking disk I/O.
398 base::ThreadRestrictions::SetIOAllowed(false); 437 base::ThreadRestrictions::SetIOAllowed(false);
399 438
400 BrowserProcessSubThread::Init(); 439 BrowserProcessSubThread::Init();
401 440
402 DCHECK_EQ(MessageLoop::TYPE_IO, message_loop()->type()); 441 DCHECK_EQ(MessageLoop::TYPE_IO, message_loop()->type());
403 442
404 #if defined(USE_NSS) 443 #if defined(USE_NSS)
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 BrowserChildProcessHost::TerminateAll(); 520 BrowserChildProcessHost::TerminateAll();
482 521
483 system_url_request_context_getter_ = NULL; 522 system_url_request_context_getter_ = NULL;
484 523
485 // Step 2: Release objects that the net::URLRequestContext could have been 524 // Step 2: Release objects that the net::URLRequestContext could have been
486 // pointing to. 525 // pointing to.
487 526
488 // This must be reset before the ChromeNetLog is destroyed. 527 // This must be reset before the ChromeNetLog is destroyed.
489 network_change_observer_.reset(); 528 network_change_observer_.reset();
490 529
530 // Not initialized in Init(). May not be initialized.
531 if (predictor_) {
532 predictor_->Shutdown();
533
534 // TODO(willchan): Stop reference counting Predictor. It's owned by
535 // IOThread now.
536 predictor_->Release();
537 predictor_ = NULL;
538 chrome_browser_net::FreePredictorResources();
539 }
540
541 // Deletion will unregister this interceptor.
542 delete speculative_interceptor_;
543 speculative_interceptor_ = NULL;
544
491 system_proxy_config_service_.reset(); 545 system_proxy_config_service_.reset();
492 546
493 delete globals_; 547 delete globals_;
494 globals_ = NULL; 548 globals_ = NULL;
495 549
496 // net::URLRequest instances must NOT outlive the IO thread. 550 // net::URLRequest instances must NOT outlive the IO thread.
497 base::debug::LeakTracker<net::URLRequest>::CheckForLeaks(); 551 base::debug::LeakTracker<net::URLRequest>::CheckForLeaks();
498 552
499 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); 553 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks();
500 554
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 591
538 return net::HttpAuthHandlerRegistryFactory::Create( 592 return net::HttpAuthHandlerRegistryFactory::Create(
539 supported_schemes, 593 supported_schemes,
540 globals_->url_security_manager.get(), 594 globals_->url_security_manager.get(),
541 resolver, 595 resolver,
542 gssapi_library_name_, 596 gssapi_library_name_,
543 negotiate_disable_cname_lookup_, 597 negotiate_disable_cname_lookup_,
544 negotiate_enable_port_); 598 negotiate_enable_port_);
545 } 599 }
546 600
601 void IOThread::InitNetworkPredictorOnIOThread(
602 bool prefetching_enabled,
603 base::TimeDelta max_dns_queue_delay,
604 size_t max_speculative_parallel_resolves,
605 const chrome_common_net::UrlList& startup_urls,
606 ListValue* referral_list,
607 bool preconnect_enabled) {
608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
609 CHECK(!predictor_);
610
611 chrome_browser_net::EnablePredictor(prefetching_enabled);
612
613 predictor_ = new chrome_browser_net::Predictor(
614 globals_->host_resolver.get(),
615 max_dns_queue_delay,
616 max_speculative_parallel_resolves,
617 preconnect_enabled);
618 predictor_->AddRef();
619
620 // Speculative_interceptor_ is used to predict subresource usage.
621 DCHECK(!speculative_interceptor_);
622 speculative_interceptor_ = new chrome_browser_net::ConnectInterceptor;
623
624 FinalizePredictorInitialization(predictor_, startup_urls, referral_list);
625 }
626
627 void IOThread::ChangedToOnTheRecordOnIOThread() {
628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
629
630 if (predictor_) {
631 // Destroy all evidence of our OTR session.
632 // Note: OTR mode never saves InitialNavigationHistory data.
633 predictor_->Predictor::DiscardAllResults();
634 }
635
636 // Clear the host cache to avoid showing entries from the OTR session
637 // in about:net-internals.
638 ClearHostCache();
639
640 // Clear all of the passively logged data.
641 // TODO(eroman): this is a bit heavy handed, really all we need to do is
642 // clear the data pertaining to incognito context.
643 net_log_->ClearAllPassivelyCapturedEvents();
644 }
645
547 void IOThread::ClearHostCache() { 646 void IOThread::ClearHostCache() {
548 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 647 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
549 648
550 if (globals_->host_resolver->GetAsHostResolverImpl()) { 649 if (globals_->host_resolver->GetAsHostResolverImpl()) {
551 net::HostCache* host_cache = 650 net::HostCache* host_cache =
552 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); 651 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache();
553 if (host_cache) 652 if (host_cache)
554 host_cache->clear(); 653 host_cache->clear();
555 } 654 }
556 } 655 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 system_params.network_delegate = globals_->system_network_delegate.get(); 703 system_params.network_delegate = globals_->system_network_delegate.get();
605 system_params.net_log = net_log_; 704 system_params.net_log = net_log_;
606 globals_->system_http_transaction_factory.reset( 705 globals_->system_http_transaction_factory.reset(
607 new net::HttpNetworkLayer( 706 new net::HttpNetworkLayer(
608 new net::HttpNetworkSession(system_params))); 707 new net::HttpNetworkSession(system_params)));
609 globals_->system_ftp_transaction_factory.reset( 708 globals_->system_ftp_transaction_factory.reset(
610 new net::FtpNetworkLayer(globals_->host_resolver.get())); 709 new net::FtpNetworkLayer(globals_->host_resolver.get()));
611 globals_->system_request_context = 710 globals_->system_request_context =
612 ConstructSystemRequestContext(globals_, net_log_); 711 ConstructSystemRequestContext(globals_, net_log_);
613 } 712 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_remover.cc ('k') | chrome/browser/net/connect_interceptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698