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

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

Issue 734263003: Move data reduction proxy logic out of chrome and android webview network delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding inits to DRPNetworkDelegate Created 6 years 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
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 19 matching lines...) Expand all
30 #include "chrome/browser/net/quota_policy_channel_id_store.h" 30 #include "chrome/browser/net/quota_policy_channel_id_store.h"
31 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator. h" 31 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator. h"
32 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 32 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
33 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/common/chrome_constants.h" 34 #include "chrome/common/chrome_constants.h"
35 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
37 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
38 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h" 38 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h"
39 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte rceptor.h" 39 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte rceptor.h"
40 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h"
40 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prot ocol.h" 41 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prot ocol.h"
41 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h" 42 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h"
42 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usag e_stats.h" 43 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usag e_stats.h"
43 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 44 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
44 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h" 45 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h"
45 #include "components/domain_reliability/monitor.h" 46 #include "components/domain_reliability/monitor.h"
46 #include "content/public/browser/browser_thread.h" 47 #include "content/public/browser/browser_thread.h"
47 #include "content/public/browser/cookie_store_factory.h" 48 #include "content/public/browser/cookie_store_factory.h"
48 #include "content/public/browser/notification_service.h" 49 #include "content/public/browser/notification_service.h"
49 #include "content/public/browser/resource_context.h" 50 #include "content/public/browser/resource_context.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 ProfileImplIOData::LazyParams::~LazyParams() {} 408 ProfileImplIOData::LazyParams::~LazyParams() {}
408 409
409 ProfileImplIOData::ProfileImplIOData() 410 ProfileImplIOData::ProfileImplIOData()
410 : ProfileIOData(Profile::REGULAR_PROFILE), 411 : ProfileIOData(Profile::REGULAR_PROFILE),
411 http_server_properties_manager_(NULL), 412 http_server_properties_manager_(NULL),
412 app_cache_max_size_(0), 413 app_cache_max_size_(0),
413 app_media_cache_max_size_(0) { 414 app_media_cache_max_size_(0) {
414 } 415 }
415 416
416 ProfileImplIOData::~ProfileImplIOData() { 417 ProfileImplIOData::~ProfileImplIOData() {
417 if (initialized())
418 network_delegate()->set_domain_reliability_monitor(NULL);
419
420 DestroyResourceContext(); 418 DestroyResourceContext();
421 419
422 if (media_request_context_) 420 if (media_request_context_)
423 media_request_context_->AssertNoURLRequests(); 421 media_request_context_->AssertNoURLRequests();
424 } 422 }
425 423
426 void ProfileImplIOData::InitializeInternal( 424 void ProfileImplIOData::InitializeInternal(
425 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate,
mmenke 2014/12/03 18:50:38 This passing ownership back and forth seems weird:
megjablon 2014/12/04 01:23:46 I'm not sure I understand. Can you explain? If we
427 ProfileParams* profile_params, 426 ProfileParams* profile_params,
428 content::ProtocolHandlerMap* protocol_handlers, 427 content::ProtocolHandlerMap* protocol_handlers,
429 content::URLRequestInterceptorScopedVector request_interceptors) const { 428 content::URLRequestInterceptorScopedVector request_interceptors) const {
430 net::URLRequestContext* main_context = main_request_context(); 429 net::URLRequestContext* main_context = main_request_context();
431 430
432 IOThread* const io_thread = profile_params->io_thread; 431 IOThread* const io_thread = profile_params->io_thread;
433 IOThread::Globals* const io_thread_globals = io_thread->globals(); 432 IOThread::Globals* const io_thread_globals = io_thread->globals();
434 433
434 ChromeNetworkDelegate* chrome_network_delegate_ptr =
435 chrome_network_delegate.get();
436 Profile* profile = reinterpret_cast<Profile*>(profile_params->profile);
437
435 set_data_reduction_proxy_auth_request_handler( 438 set_data_reduction_proxy_auth_request_handler(
436 scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler> 439 scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler>
437 (new data_reduction_proxy::DataReductionProxyAuthRequestHandler( 440 (new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
438 DataReductionProxyChromeSettings::GetClient(), 441 DataReductionProxyChromeSettings::GetClient(),
439 data_reduction_proxy_params(), 442 data_reduction_proxy_params(),
440 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)))); 443 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))));
441 set_data_reduction_proxy_usage_stats( 444 set_data_reduction_proxy_usage_stats(
442 scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats> 445 scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats>
443 (new data_reduction_proxy::DataReductionProxyUsageStats( 446 (new data_reduction_proxy::DataReductionProxyUsageStats(
444 data_reduction_proxy_params(), 447 data_reduction_proxy_params(),
445 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI) 448 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)
446 .get()))); 449 .get())));
447 data_reduction_proxy_usage_stats()->set_unavailable_callback( 450 data_reduction_proxy_usage_stats()->set_unavailable_callback(
448 data_reduction_proxy_unavailable_callback()); 451 data_reduction_proxy_unavailable_callback());
452 scoped_ptr<data_reduction_proxy::DataReductionProxyNetworkDelegate>
453 data_reduction_proxy_network_delegate(
454 new data_reduction_proxy::DataReductionProxyNetworkDelegate(
455 chrome_network_delegate.Pass(),
456 data_reduction_proxy_params(),
457 data_reduction_proxy_auth_request_handler(),
458 base::Bind(
459 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIOThread,
460 base::Unretained(data_reduction_proxy_chrome_configurator()))));
461 data_reduction_proxy_network_delegate->InitProxyConfigOverrides(
462 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
463 data_reduction_proxy_network_delegate->InitStatisticsPrefs(
464 profile->GetPrefs(),
mmenke 2014/12/03 18:50:38 BUG: We're on the IO thread. it's not safe to de
megjablon 2014/12/04 01:23:46 Done.
465 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
466 data_reduction_proxy_statistics_prefs());
467 data_reduction_proxy_network_delegate->InitStatisticsUMA(
468 &data_reduction_proxy_enabled_,
469 data_reduction_proxy_usage_stats());
470 set_network_delegate(data_reduction_proxy_network_delegate.Pass());
449 471
450 network_delegate()->set_data_reduction_proxy_enabled_pref( 472 chrome_network_delegate_ptr->set_predictor(predictor_.get());
mmenke 2014/12/03 18:50:38 Can this just be moved to where chrome_network_del
megjablon 2014/12/04 01:23:46 Done.
451 &data_reduction_proxy_enabled_);
452 network_delegate()->set_data_reduction_proxy_params(
453 data_reduction_proxy_params());
454 network_delegate()->set_data_reduction_proxy_usage_stats(
455 data_reduction_proxy_usage_stats());
456 network_delegate()->set_data_reduction_proxy_auth_request_handler(
457 data_reduction_proxy_auth_request_handler());
458 network_delegate()->set_data_reduction_proxy_statistics_prefs(
459 data_reduction_proxy_statistics_prefs());
460 network_delegate()->set_on_resolve_proxy_handler(
461 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
462 network_delegate()->set_proxy_config_getter(
463 base::Bind(
464 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIOThread,
465 base::Unretained(data_reduction_proxy_chrome_configurator())));
466 network_delegate()->set_predictor(predictor_.get());
467 473
468 // Initialize context members. 474 // Initialize context members.
469 475
470 ApplyProfileParamsToContext(main_context); 476 ApplyProfileParamsToContext(main_context);
471 477
472 if (http_server_properties_manager_) 478 if (http_server_properties_manager_)
473 http_server_properties_manager_->InitializeOnNetworkThread(); 479 http_server_properties_manager_->InitializeOnNetworkThread();
474 480
475 main_context->set_transport_security_state(transport_security_state()); 481 main_context->set_transport_security_state(transport_security_state());
476 482
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 StoragePartitionDescriptor details(profile_path_, false); 610 StoragePartitionDescriptor details(profile_path_, false);
605 media_request_context_.reset(InitializeMediaRequestContext(main_context, 611 media_request_context_.reset(InitializeMediaRequestContext(main_context,
606 details)); 612 details));
607 613
608 if (domain_reliability_monitor_) { 614 if (domain_reliability_monitor_) {
609 domain_reliability::DomainReliabilityMonitor* monitor = 615 domain_reliability::DomainReliabilityMonitor* monitor =
610 domain_reliability_monitor_.get(); 616 domain_reliability_monitor_.get();
611 monitor->InitURLRequestContext(main_context); 617 monitor->InitURLRequestContext(main_context);
612 monitor->AddBakedInConfigs(); 618 monitor->AddBakedInConfigs();
613 monitor->SetDiscardUploads(!GetMetricsEnabledStateOnIOThread()); 619 monitor->SetDiscardUploads(!GetMetricsEnabledStateOnIOThread());
614 network_delegate()->set_domain_reliability_monitor(monitor); 620 chrome_network_delegate_ptr->set_domain_reliability_monitor(monitor);
mmenke 2014/12/03 18:50:38 Again, think it's simpler if we can just move this
megjablon 2014/12/04 01:23:46 Done.
615 } 621 }
616 622
617 lazy_params_.reset(); 623 lazy_params_.reset();
618 } 624 }
619 625
620 void ProfileImplIOData:: 626 void ProfileImplIOData::
621 InitializeExtensionsRequestContext(ProfileParams* profile_params) const { 627 InitializeExtensionsRequestContext(ProfileParams* profile_params) const {
622 net::URLRequestContext* extensions_context = extensions_request_context(); 628 net::URLRequestContext* extensions_context = extensions_request_context();
623 IOThread* const io_thread = profile_params->io_thread; 629 IOThread* const io_thread = profile_params->io_thread;
624 IOThread::Globals* const io_thread_globals = io_thread->globals(); 630 IOThread::Globals* const io_thread_globals = io_thread->globals();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 transport_security_state()->DeleteAllDynamicDataSince(time); 857 transport_security_state()->DeleteAllDynamicDataSince(time);
852 DCHECK(http_server_properties_manager_); 858 DCHECK(http_server_properties_manager_);
853 http_server_properties_manager_->Clear(completion); 859 http_server_properties_manager_->Clear(completion);
854 } 860 }
855 861
856 bool ProfileImplIOData::IsDataReductionProxyEnabled() const { 862 bool ProfileImplIOData::IsDataReductionProxyEnabled() const {
857 return data_reduction_proxy_enabled_.GetValue() || 863 return data_reduction_proxy_enabled_.GetValue() ||
858 CommandLine::ForCurrentProcess()->HasSwitch( 864 CommandLine::ForCurrentProcess()->HasSwitch(
859 data_reduction_proxy::switches::kEnableDataReductionProxy); 865 data_reduction_proxy::switches::kEnableDataReductionProxy);
860 } 866 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698