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

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 182993003: Add the ability for DevTools to wrap network transactions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added optional QUIC setup in HttpCache constructor Created 6 years, 8 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
OLDNEW
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/profiles/profile_impl_io_data.h" 5 #include "chrome/browser/profiles/profile_impl_io_data.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 main_context->set_server_bound_cert_service(server_bound_cert_service); 452 main_context->set_server_bound_cert_service(server_bound_cert_service);
453 453
454 net::HttpCache::DefaultBackend* main_backend = 454 net::HttpCache::DefaultBackend* main_backend =
455 new net::HttpCache::DefaultBackend( 455 new net::HttpCache::DefaultBackend(
456 net::DISK_CACHE, 456 net::DISK_CACHE,
457 ChooseCacheBackendType(), 457 ChooseCacheBackendType(),
458 lazy_params_->cache_path, 458 lazy_params_->cache_path,
459 lazy_params_->cache_max_size, 459 lazy_params_->cache_max_size,
460 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) 460 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)
461 .get()); 461 .get());
462 net::HttpNetworkSession::Params network_session_params; 462 scoped_ptr<net::HttpCache> main_cache = CreateMainHttpFactory(
463 PopulateNetworkSessionParams(profile_params, &network_session_params); 463 profile_params, main_backend);
464 net::HttpCache* main_cache = new net::HttpCache(
465 network_session_params, main_backend);
466 main_cache->InitializeInfiniteCache(lazy_params_->infinite_cache_path); 464 main_cache->InitializeInfiniteCache(lazy_params_->infinite_cache_path);
467 465
468 #if defined(OS_ANDROID) || defined(OS_IOS) 466 #if defined(OS_ANDROID) || defined(OS_IOS)
469 DataReductionProxySettings::InitDataReductionProxySession( 467 DataReductionProxySettings::InitDataReductionProxySession(
470 main_cache->GetSession()); 468 main_cache->GetSession());
471 #endif 469 #endif
472 470
473 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { 471 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) {
474 main_cache->set_mode( 472 main_cache->set_mode(
475 chrome_browser_net::IsCookieRecordMode() ? 473 chrome_browser_net::IsCookieRecordMode() ?
476 net::HttpCache::RECORD : net::HttpCache::PLAYBACK); 474 net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
477 } 475 }
478 476
479 main_http_factory_.reset(main_cache); 477 main_http_factory_ = main_cache.PassAs<net::HttpTransactionFactory>();
mmenke 2014/03/31 18:10:20 Think "main_http_factory_.reset(main_cache.release
eustas 2014/04/18 12:33:19 Done.
480 main_context->set_http_transaction_factory(main_cache); 478 main_context->set_http_transaction_factory(main_http_factory_.get());
481 479
482 #if !defined(DISABLE_FTP_SUPPORT) 480 #if !defined(DISABLE_FTP_SUPPORT)
483 ftp_factory_.reset( 481 ftp_factory_.reset(
484 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); 482 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
485 #endif // !defined(DISABLE_FTP_SUPPORT) 483 #endif // !defined(DISABLE_FTP_SUPPORT)
486 484
487 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( 485 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
488 new net::URLRequestJobFactoryImpl()); 486 new net::URLRequestJobFactoryImpl());
489 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); 487 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers);
490 main_job_factory_ = SetUpJobFactoryDefaults( 488 main_job_factory_ = SetUpJobFactoryDefaults(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 app_backend = new net::HttpCache::DefaultBackend( 582 app_backend = new net::HttpCache::DefaultBackend(
585 net::DISK_CACHE, 583 net::DISK_CACHE,
586 ChooseCacheBackendType(), 584 ChooseCacheBackendType(),
587 cache_path, 585 cache_path,
588 app_cache_max_size_, 586 app_cache_max_size_,
589 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) 587 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)
590 .get()); 588 .get());
591 } 589 }
592 net::HttpNetworkSession* main_network_session = 590 net::HttpNetworkSession* main_network_session =
593 main_http_factory_->GetSession(); 591 main_http_factory_->GetSession();
594 net::HttpCache* app_http_cache = 592 scoped_ptr<net::HttpCache> app_http_cache =
595 new net::HttpCache(main_network_session, app_backend); 593 CreateHttpFactory(main_network_session, app_backend);
596 594
597 scoped_refptr<net::CookieStore> cookie_store = NULL; 595 scoped_refptr<net::CookieStore> cookie_store = NULL;
598 if (partition_descriptor.in_memory) { 596 if (partition_descriptor.in_memory) {
599 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); 597 cookie_store = content::CreateCookieStore(content::CookieStoreConfig());
600 } else if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { 598 } else if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) {
601 // Don't use existing cookies and use an in-memory store. 599 // Don't use existing cookies and use an in-memory store.
602 // TODO(creis): We should have a cookie delegate for notifying the cookie 600 // TODO(creis): We should have a cookie delegate for notifying the cookie
603 // extensions API, but we need to update it to understand isolated apps 601 // extensions API, but we need to update it to understand isolated apps
604 // first. 602 // first.
605 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); 603 cookie_store = content::CreateCookieStore(content::CookieStoreConfig());
(...skipping 14 matching lines...) Expand all
620 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, 618 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
621 NULL, NULL); 619 NULL, NULL);
622 cookie_config.crypto_delegate = 620 cookie_config.crypto_delegate =
623 chrome_browser_net::GetCookieCryptoDelegate(); 621 chrome_browser_net::GetCookieCryptoDelegate();
624 cookie_store = content::CreateCookieStore(cookie_config); 622 cookie_store = content::CreateCookieStore(cookie_config);
625 } 623 }
626 624
627 // Transfer ownership of the cookies and cache to AppRequestContext. 625 // Transfer ownership of the cookies and cache to AppRequestContext.
628 context->SetCookieStore(cookie_store.get()); 626 context->SetCookieStore(cookie_store.get());
629 context->SetHttpTransactionFactory( 627 context->SetHttpTransactionFactory(
630 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); 628 scoped_ptr<net::HttpTransactionFactory>(
629 app_http_cache.PassAs<net::HttpTransactionFactory>()));
631 630
632 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( 631 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
633 new net::URLRequestJobFactoryImpl()); 632 new net::URLRequestJobFactoryImpl());
634 InstallProtocolHandlers(job_factory.get(), protocol_handlers); 633 InstallProtocolHandlers(job_factory.get(), protocol_handlers);
635 scoped_ptr<net::URLRequestJobFactory> top_job_factory( 634 scoped_ptr<net::URLRequestJobFactory> top_job_factory(
636 SetUpJobFactoryDefaults(job_factory.Pass(), 635 SetUpJobFactoryDefaults(job_factory.Pass(),
637 protocol_interceptors.Pass(), 636 protocol_interceptors.Pass(),
638 protocol_handler_interceptor.Pass(), 637 protocol_handler_interceptor.Pass(),
639 network_delegate(), 638 network_delegate(),
640 ftp_factory_.get())); 639 ftp_factory_.get()));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 net::HttpCache::BackendFactory* media_backend = 672 net::HttpCache::BackendFactory* media_backend =
674 new net::HttpCache::DefaultBackend( 673 new net::HttpCache::DefaultBackend(
675 net::MEDIA_CACHE, 674 net::MEDIA_CACHE,
676 ChooseCacheBackendType(), 675 ChooseCacheBackendType(),
677 cache_path, 676 cache_path,
678 cache_max_size, 677 cache_max_size,
679 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) 678 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)
680 .get()); 679 .get());
681 net::HttpNetworkSession* main_network_session = 680 net::HttpNetworkSession* main_network_session =
682 main_http_factory_->GetSession(); 681 main_http_factory_->GetSession();
683 scoped_ptr<net::HttpTransactionFactory> media_http_cache( 682 scoped_ptr<net::HttpCache> media_http_cache =
684 new net::HttpCache(main_network_session, media_backend)); 683 CreateHttpFactory(main_network_session, media_backend);
685 684
686 // Transfer ownership of the cache to MediaRequestContext. 685 // Transfer ownership of the cache to MediaRequestContext.
687 context->SetHttpTransactionFactory(media_http_cache.Pass()); 686 context->SetHttpTransactionFactory(
687 media_http_cache.PassAs<net::HttpTransactionFactory>());
688 688
689 // Note that we do not create a new URLRequestJobFactory because 689 // Note that we do not create a new URLRequestJobFactory because
690 // the media context should behave exactly like its parent context 690 // the media context should behave exactly like its parent context
691 // in all respects except for cache behavior on media subresources. 691 // in all respects except for cache behavior on media subresources.
692 // The CopyFrom() step above means that our media context will use 692 // The CopyFrom() step above means that our media context will use
693 // the same URLRequestJobFactory instance that our parent context does. 693 // the same URLRequestJobFactory instance that our parent context does.
694 694
695 return context; 695 return context;
696 } 696 }
697 697
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 const base::Closure& completion) { 735 const base::Closure& completion) {
736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
737 DCHECK(initialized()); 737 DCHECK(initialized());
738 738
739 DCHECK(transport_security_state()); 739 DCHECK(transport_security_state());
740 // Completes synchronously. 740 // Completes synchronously.
741 transport_security_state()->DeleteAllDynamicDataSince(time); 741 transport_security_state()->DeleteAllDynamicDataSince(time);
742 DCHECK(http_server_properties_manager_); 742 DCHECK(http_server_properties_manager_);
743 http_server_properties_manager_->Clear(completion); 743 http_server_properties_manager_->Clear(completion);
744 } 744 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698