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/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 #include "chrome/browser/domain_reliability/service_factory.h" | 37 #include "chrome/browser/domain_reliability/service_factory.h" |
38 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 38 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
39 #include "chrome/browser/download/download_service.h" | 39 #include "chrome/browser/download/download_service.h" |
40 #include "chrome/browser/download/download_service_factory.h" | 40 #include "chrome/browser/download/download_service_factory.h" |
41 #include "chrome/browser/history/top_sites.h" | 41 #include "chrome/browser/history/top_sites.h" |
42 #include "chrome/browser/net/chrome_net_log.h" | 42 #include "chrome/browser/net/chrome_net_log.h" |
43 #include "chrome/browser/net/net_pref_observer.h" | 43 #include "chrome/browser/net/net_pref_observer.h" |
44 #include "chrome/browser/net/predictor.h" | 44 #include "chrome/browser/net/predictor.h" |
45 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 45 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
46 #include "chrome/browser/net/proxy_service_factory.h" | 46 #include "chrome/browser/net/proxy_service_factory.h" |
47 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h" | |
47 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 48 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
48 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" | 49 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" |
49 #include "chrome/browser/net/ssl_config_service_manager.h" | 50 #include "chrome/browser/net/ssl_config_service_manager.h" |
50 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 51 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
51 #include "chrome/browser/plugins/plugin_prefs.h" | 52 #include "chrome/browser/plugins/plugin_prefs.h" |
52 #include "chrome/browser/policy/profile_policy_connector.h" | 53 #include "chrome/browser/policy/profile_policy_connector.h" |
53 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 54 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
54 #include "chrome/browser/prefs/browser_prefs.h" | 55 #include "chrome/browser/prefs/browser_prefs.h" |
55 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 56 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
56 #include "chrome/browser/prefs/pref_service_syncable.h" | 57 #include "chrome/browser/prefs/pref_service_syncable.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
77 #include "chrome/common/chrome_constants.h" | 78 #include "chrome/common/chrome_constants.h" |
78 #include "chrome/common/chrome_paths_internal.h" | 79 #include "chrome/common/chrome_paths_internal.h" |
79 #include "chrome/common/chrome_switches.h" | 80 #include "chrome/common/chrome_switches.h" |
80 #include "chrome/common/chrome_version_info.h" | 81 #include "chrome/common/chrome_version_info.h" |
81 #include "chrome/common/pref_names.h" | 82 #include "chrome/common/pref_names.h" |
82 #include "chrome/common/url_constants.h" | 83 #include "chrome/common/url_constants.h" |
83 #include "chrome/grit/chromium_strings.h" | 84 #include "chrome/grit/chromium_strings.h" |
84 #include "components/bookmarks/browser/bookmark_model.h" | 85 #include "components/bookmarks/browser/bookmark_model.h" |
85 #include "components/content_settings/core/browser/host_content_settings_map.h" | 86 #include "components/content_settings/core/browser/host_content_settings_map.h" |
86 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h" | 87 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h" |
88 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" | |
87 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" | 89 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" |
88 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" | 90 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" |
89 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h" | 91 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h" |
90 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | 92 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" |
91 #include "components/domain_reliability/monitor.h" | 93 #include "components/domain_reliability/monitor.h" |
92 #include "components/domain_reliability/service.h" | 94 #include "components/domain_reliability/service.h" |
93 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 95 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
94 #include "components/metrics/metrics_service.h" | 96 #include "components/metrics/metrics_service.h" |
95 #include "components/pref_registry/pref_registry_syncable.h" | 97 #include "components/pref_registry/pref_registry_syncable.h" |
96 #include "components/signin/core/browser/signin_manager.h" | 98 #include "components/signin/core/browser/signin_manager.h" |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 #endif | 637 #endif |
636 content::CookieStoreConfig::SessionCookieMode session_cookie_mode = | 638 content::CookieStoreConfig::SessionCookieMode session_cookie_mode = |
637 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES; | 639 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES; |
638 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || | 640 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || |
639 startup_pref_type == SessionStartupPref::LAST) { | 641 startup_pref_type == SessionStartupPref::LAST) { |
640 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; | 642 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; |
641 } | 643 } |
642 | 644 |
643 ChromeNetLog* const net_log = g_browser_process->io_thread()->net_log(); | 645 ChromeNetLog* const net_log = g_browser_process->io_thread()->net_log(); |
644 | 646 |
645 base::Callback<void(bool)> data_reduction_proxy_unavailable; | 647 // Retain a raw pointer to use for initialization of data reduction proxy |
646 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> | 648 // settings after ownership is passed. |
647 data_reduction_proxy_params; | 649 data_reduction_proxy::DataReductionProxyConfigurator* |
648 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> configurator; | 650 data_reduction_proxy_configurator = nullptr; |
649 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs> | 651 |
650 data_reduction_proxy_statistics_prefs; | 652 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
651 scoped_ptr<data_reduction_proxy::DataReductionProxyEventStore> event_store; | 653 data_reduction_proxy_io_data = |
652 DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings = | 654 CreateDataReductionProxyChromeIOData( |
653 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this); | 655 net_log, this, prefs_.get(), |
654 data_reduction_proxy_params = | 656 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
655 data_reduction_proxy_chrome_settings->params()->Clone(); | 657 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
656 data_reduction_proxy_unavailable = | 658 &data_reduction_proxy_configurator).Pass(); |
mmenke
2015/01/16 19:03:20
Does any of this stuff need to be done in profile_
bengr
2015/01/17 00:20:47
I think the answer is yes, for now, because InitDa
mmenke
2015/01/17 00:29:54
Right, I was thinking we could move that, too.
bengr
2015/01/21 23:28:02
Done.
| |
657 base::Bind( | 659 |
658 &data_reduction_proxy::DataReductionProxySettings::SetUnreachable, | |
659 base::Unretained(data_reduction_proxy_chrome_settings)); | |
660 // The event_store is used by DataReductionProxyChromeSettings, configurator, | |
661 // and ProfileIOData. Ownership is passed to the latter via | |
662 // ProfileIOData::Handle, which is only destroyed after | |
663 // BrowserContextKeyedServices, including DataReductionProxyChromeSettings | |
664 event_store.reset( | |
665 new data_reduction_proxy::DataReductionProxyEventStore( | |
666 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); | |
667 // The configurator is used by DataReductionProxyChromeSettings and | |
668 // ProfileIOData. Ownership is passed to the latter via ProfileIOData::Handle, | |
669 // which is only destroyed after BrowserContextKeyedServices, | |
670 // including DataReductionProxyChromeSettings. | |
671 configurator.reset( | |
672 new data_reduction_proxy::DataReductionProxyConfigurator( | |
673 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | |
674 net_log, | |
675 event_store.get())); | |
676 // Retain a raw pointer to use for initialization of data reduction proxy | 660 // Retain a raw pointer to use for initialization of data reduction proxy |
677 // settings after ownership is passed | 661 // settings after ownership is passed |
678 data_reduction_proxy::DataReductionProxyEventStore* | 662 data_reduction_proxy::DataReductionProxyEventStore* |
679 data_reduction_proxy_event_store = event_store.get(); | 663 data_reduction_proxy_event_store = |
680 // Retain a raw pointer to use for initialization of data reduction proxy | 664 data_reduction_proxy_io_data->event_store(); |
681 // settings after ownership is passed. | |
682 data_reduction_proxy::DataReductionProxyConfigurator* | |
683 data_reduction_proxy_configurator = configurator.get(); | |
684 #if defined(OS_ANDROID) || defined(OS_IOS) | |
685 // On mobile we write data reduction proxy prefs directly to the pref service. | |
686 // On desktop we store data reduction proxy prefs in memory, writing to disk | |
687 // every 60 minutes and on termination. Shutdown hooks must be added for | |
688 // Android and iOS in order for non-zero delays to be supported. | |
689 // (http://crbug.com/408264) | |
690 base::TimeDelta commit_delay = base::TimeDelta(); | |
691 #else | |
692 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | |
693 #endif | |
694 // TODO(bengr): Remove this in M-43. | |
695 data_reduction_proxy::MigrateStatisticsPrefs(g_browser_process->local_state(), | |
696 prefs_.get()); | |
697 data_reduction_proxy_statistics_prefs = | |
698 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>( | |
699 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( | |
700 prefs_.get(), | |
701 base::MessageLoopProxy::current(), | |
702 commit_delay)); | |
703 data_reduction_proxy_chrome_settings->SetDataReductionProxyStatisticsPrefs( | |
704 data_reduction_proxy_statistics_prefs.get()); | |
705 | 665 |
706 // Make sure we initialize the ProfileIOData after everything else has been | 666 // Make sure we initialize the ProfileIOData after everything else has been |
707 // initialized that we might be reading from the IO thread. | 667 // initialized that we might be reading from the IO thread. |
708 | 668 |
709 io_data_.Init(cookie_path, channel_id_path, cache_path, | 669 io_data_.Init(cookie_path, channel_id_path, cache_path, |
710 cache_max_size, media_cache_path, media_cache_max_size, | 670 cache_max_size, media_cache_path, media_cache_max_size, |
711 extensions_cookie_path, GetPath(), infinite_cache_path, | 671 extensions_cookie_path, GetPath(), infinite_cache_path, |
712 predictor_, session_cookie_mode, GetSpecialStoragePolicy(), | 672 predictor_, session_cookie_mode, GetSpecialStoragePolicy(), |
713 CreateDomainReliabilityMonitor(local_state), | 673 CreateDomainReliabilityMonitor(local_state), |
714 data_reduction_proxy_unavailable, | 674 data_reduction_proxy_io_data.Pass()); |
715 configurator.Pass(), | 675 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this)-> |
mmenke
2015/01/16 19:03:20
Cant this call be moved before io_data_.Init? I a
bengr
2015/01/17 00:20:47
Ack that this is kinda weird and not ideal. Unfort
| |
716 data_reduction_proxy_params.Pass(), | 676 InitDataReductionProxySettings( |
717 data_reduction_proxy_statistics_prefs.Pass(), | 677 data_reduction_proxy_configurator, prefs_.get(), |
718 event_store.Pass()); | 678 g_browser_process->local_state(), GetRequestContext(), net_log, |
mmenke
2015/01/16 19:03:20
Question: Not for this CL, but for the future...D
bengr
2015/01/17 00:20:47
See above reply. Even better is that we'd remove t
| |
719 data_reduction_proxy_chrome_settings->InitDataReductionProxySettings( | 679 data_reduction_proxy_event_store); |
720 data_reduction_proxy_configurator, | |
721 prefs_.get(), | |
722 g_browser_process->local_state(), | |
723 GetRequestContext(), | |
724 net_log, | |
725 data_reduction_proxy_event_store); | |
726 | 680 |
727 #if defined(ENABLE_PLUGINS) | 681 #if defined(ENABLE_PLUGINS) |
728 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 682 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
729 PluginPrefs::GetForProfile(this).get(), | 683 PluginPrefs::GetForProfile(this).get(), |
730 io_data_.GetResourceContextNoInit()); | 684 io_data_.GetResourceContextNoInit()); |
731 #endif | 685 #endif |
732 | 686 |
733 // Delay README creation to not impact startup performance. | 687 // Delay README creation to not impact startup performance. |
734 BrowserThread::PostDelayedTask( | 688 BrowserThread::PostDelayedTask( |
735 BrowserThread::FILE, FROM_HERE, | 689 BrowserThread::FILE, FROM_HERE, |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1419 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { | 1373 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { |
1420 domain_reliability::DomainReliabilityService* service = | 1374 domain_reliability::DomainReliabilityService* service = |
1421 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1375 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
1422 GetForBrowserContext(this); | 1376 GetForBrowserContext(this); |
1423 if (!service) | 1377 if (!service) |
1424 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1378 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
1425 | 1379 |
1426 return service->CreateMonitor( | 1380 return service->CreateMonitor( |
1427 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1381 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
1428 } | 1382 } |
OLD | NEW |