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

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

Issue 7688006: Revert 97465 - 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"
28 #include "chrome/browser/net/pref_proxy_config_service.h" 27 #include "chrome/browser/net/pref_proxy_config_service.h"
29 #include "chrome/browser/net/proxy_service_factory.h" 28 #include "chrome/browser/net/proxy_service_factory.h"
30 #include "chrome/browser/prefs/pref_service.h" 29 #include "chrome/browser/prefs/pref_service.h"
31 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
33 #include "content/browser/browser_thread.h" 32 #include "content/browser/browser_thread.h"
34 #include "content/browser/gpu/gpu_process_host.h" 33 #include "content/browser/gpu/gpu_process_host.h"
35 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" 34 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h"
36 #include "content/common/url_fetcher.h" 35 #include "content/common/url_fetcher.h"
37 #include "net/base/cert_verifier.h" 36 #include "net/base/cert_verifier.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // |local_state| is passed in explicitly in order to (1) reduce implicit 336 // |local_state| is passed in explicitly in order to (1) reduce implicit
338 // dependencies and (2) make IOThread more flexible for testing. 337 // dependencies and (2) make IOThread more flexible for testing.
339 IOThread::IOThread( 338 IOThread::IOThread(
340 PrefService* local_state, 339 PrefService* local_state,
341 ChromeNetLog* net_log, 340 ChromeNetLog* net_log,
342 ExtensionEventRouterForwarder* extension_event_router_forwarder) 341 ExtensionEventRouterForwarder* extension_event_router_forwarder)
343 : BrowserProcessSubThread(BrowserThread::IO), 342 : BrowserProcessSubThread(BrowserThread::IO),
344 net_log_(net_log), 343 net_log_(net_log),
345 extension_event_router_forwarder_(extension_event_router_forwarder), 344 extension_event_router_forwarder_(extension_event_router_forwarder),
346 globals_(NULL), 345 globals_(NULL),
347 speculative_interceptor_(NULL),
348 predictor_(NULL),
349 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 346 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
350 // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make 347 // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make
351 // sure that everything is initialized in the right order. 348 // sure that everything is initialized in the right order.
352 RegisterPrefs(local_state); 349 RegisterPrefs(local_state);
353 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); 350 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes);
354 negotiate_disable_cname_lookup_ = local_state->GetBoolean( 351 negotiate_disable_cname_lookup_ = local_state->GetBoolean(
355 prefs::kDisableAuthNegotiateCnameLookup); 352 prefs::kDisableAuthNegotiateCnameLookup);
356 negotiate_enable_port_ = local_state->GetBoolean( 353 negotiate_enable_port_ = local_state->GetBoolean(
357 prefs::kEnableAuthNegotiatePort); 354 prefs::kEnableAuthNegotiatePort);
358 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); 355 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist);
(...skipping 21 matching lines...) Expand all
380 377
381 IOThread::Globals* IOThread::globals() { 378 IOThread::Globals* IOThread::globals() {
382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
383 return globals_; 380 return globals_;
384 } 381 }
385 382
386 ChromeNetLog* IOThread::net_log() { 383 ChromeNetLog* IOThread::net_log() {
387 return net_log_; 384 return net_log_;
388 } 385 }
389 386
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
417 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { 387 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() {
418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
419 if (!system_url_request_context_getter_) { 389 if (!system_url_request_context_getter_) {
420 InitSystemRequestContext(); 390 InitSystemRequestContext();
421 } 391 }
422 return system_url_request_context_getter_; 392 return system_url_request_context_getter_;
423 } 393 }
424 394
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
434 void IOThread::Init() { 395 void IOThread::Init() {
435 // Though this thread is called the "IO" thread, it actually just routes 396 // Though this thread is called the "IO" thread, it actually just routes
436 // messages around; it shouldn't be allowed to perform any blocking disk I/O. 397 // messages around; it shouldn't be allowed to perform any blocking disk I/O.
437 base::ThreadRestrictions::SetIOAllowed(false); 398 base::ThreadRestrictions::SetIOAllowed(false);
438 399
439 BrowserProcessSubThread::Init(); 400 BrowserProcessSubThread::Init();
440 401
441 DCHECK_EQ(MessageLoop::TYPE_IO, message_loop()->type()); 402 DCHECK_EQ(MessageLoop::TYPE_IO, message_loop()->type());
442 403
443 #if defined(USE_NSS) 404 #if defined(USE_NSS)
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 BrowserChildProcessHost::TerminateAll(); 481 BrowserChildProcessHost::TerminateAll();
521 482
522 system_url_request_context_getter_ = NULL; 483 system_url_request_context_getter_ = NULL;
523 484
524 // Step 2: Release objects that the net::URLRequestContext could have been 485 // Step 2: Release objects that the net::URLRequestContext could have been
525 // pointing to. 486 // pointing to.
526 487
527 // This must be reset before the ChromeNetLog is destroyed. 488 // This must be reset before the ChromeNetLog is destroyed.
528 network_change_observer_.reset(); 489 network_change_observer_.reset();
529 490
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
545 system_proxy_config_service_.reset(); 491 system_proxy_config_service_.reset();
546 492
547 delete globals_; 493 delete globals_;
548 globals_ = NULL; 494 globals_ = NULL;
549 495
550 // net::URLRequest instances must NOT outlive the IO thread. 496 // net::URLRequest instances must NOT outlive the IO thread.
551 base::debug::LeakTracker<net::URLRequest>::CheckForLeaks(); 497 base::debug::LeakTracker<net::URLRequest>::CheckForLeaks();
552 498
553 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); 499 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks();
554 500
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 537
592 return net::HttpAuthHandlerRegistryFactory::Create( 538 return net::HttpAuthHandlerRegistryFactory::Create(
593 supported_schemes, 539 supported_schemes,
594 globals_->url_security_manager.get(), 540 globals_->url_security_manager.get(),
595 resolver, 541 resolver,
596 gssapi_library_name_, 542 gssapi_library_name_,
597 negotiate_disable_cname_lookup_, 543 negotiate_disable_cname_lookup_,
598 negotiate_enable_port_); 544 negotiate_enable_port_);
599 } 545 }
600 546
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
646 void IOThread::ClearHostCache() { 547 void IOThread::ClearHostCache() {
647 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 548 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
648 549
649 if (globals_->host_resolver->GetAsHostResolverImpl()) { 550 if (globals_->host_resolver->GetAsHostResolverImpl()) {
650 net::HostCache* host_cache = 551 net::HostCache* host_cache =
651 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); 552 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache();
652 if (host_cache) 553 if (host_cache)
653 host_cache->clear(); 554 host_cache->clear();
654 } 555 }
655 } 556 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 system_params.network_delegate = globals_->system_network_delegate.get(); 604 system_params.network_delegate = globals_->system_network_delegate.get();
704 system_params.net_log = net_log_; 605 system_params.net_log = net_log_;
705 globals_->system_http_transaction_factory.reset( 606 globals_->system_http_transaction_factory.reset(
706 new net::HttpNetworkLayer( 607 new net::HttpNetworkLayer(
707 new net::HttpNetworkSession(system_params))); 608 new net::HttpNetworkSession(system_params)));
708 globals_->system_ftp_transaction_factory.reset( 609 globals_->system_ftp_transaction_factory.reset(
709 new net::FtpNetworkLayer(globals_->host_resolver.get())); 610 new net::FtpNetworkLayer(globals_->host_resolver.get()));
710 globals_->system_request_context = 611 globals_->system_request_context =
711 ConstructSystemRequestContext(globals_, net_log_); 612 ConstructSystemRequestContext(globals_, net_log_);
712 } 613 }
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