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

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

Issue 473723002: Update data reduction proxy statistics prefs less often on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tooManyWritesPatch
Patch Set: Fixing nits Created 6 years, 3 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
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.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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 #include "chrome/browser/chromeos/locale_change_guard.h" 112 #include "chrome/browser/chromeos/locale_change_guard.h"
113 #include "chrome/browser/chromeos/preferences.h" 113 #include "chrome/browser/chromeos/preferences.h"
114 #include "chrome/browser/chromeos/profiles/profile_helper.h" 114 #include "chrome/browser/chromeos/profiles/profile_helper.h"
115 #include "components/user_manager/user_manager.h" 115 #include "components/user_manager/user_manager.h"
116 #endif 116 #endif
117 117
118 #if defined(SPDY_PROXY_AUTH_ORIGIN) 118 #if defined(SPDY_PROXY_AUTH_ORIGIN)
119 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 119 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
120 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" 120 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
121 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" 121 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h"
122 #include "components/data_reduction_proxy/browser/data_reduction_proxy_statistic s_prefs.h"
122 #endif 123 #endif
123 124
124 #if defined(ENABLE_CONFIGURATION_POLICY) 125 #if defined(ENABLE_CONFIGURATION_POLICY)
125 #include "chrome/browser/policy/schema_registry_service.h" 126 #include "chrome/browser/policy/schema_registry_service.h"
126 #include "chrome/browser/policy/schema_registry_service_factory.h" 127 #include "chrome/browser/policy/schema_registry_service_factory.h"
127 #include "components/policy/core/browser/browser_policy_connector.h" 128 #include "components/policy/core/browser/browser_policy_connector.h"
128 #if defined(OS_CHROMEOS) 129 #if defined(OS_CHROMEOS)
129 #include "chrome/browser/chromeos/login/login_utils.h" 130 #include "chrome/browser/chromeos/login/login_utils.h"
130 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" 131 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
131 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" 132 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 startup_pref_type == SessionStartupPref::LAST) { 655 startup_pref_type == SessionStartupPref::LAST) {
655 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; 656 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES;
656 } 657 }
657 658
658 InitHostZoomMap(); 659 InitHostZoomMap();
659 660
660 base::Callback<void(bool)> data_reduction_proxy_unavailable; 661 base::Callback<void(bool)> data_reduction_proxy_unavailable;
661 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> 662 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
662 data_reduction_proxy_params; 663 data_reduction_proxy_params;
663 scoped_ptr<DataReductionProxyChromeConfigurator> chrome_configurator; 664 scoped_ptr<DataReductionProxyChromeConfigurator> chrome_configurator;
665 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>
666 data_reduction_proxy_statistics_prefs;
664 #if defined(SPDY_PROXY_AUTH_ORIGIN) 667 #if defined(SPDY_PROXY_AUTH_ORIGIN)
665 DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings = 668 DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings =
666 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this); 669 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this);
667 data_reduction_proxy_params = 670 data_reduction_proxy_params =
668 data_reduction_proxy_chrome_settings->params()->Clone(); 671 data_reduction_proxy_chrome_settings->params()->Clone();
669 data_reduction_proxy_unavailable = 672 data_reduction_proxy_unavailable =
670 base::Bind( 673 base::Bind(
671 &data_reduction_proxy::DataReductionProxySettings::SetUnreachable, 674 &data_reduction_proxy::DataReductionProxySettings::SetUnreachable,
672 base::Unretained(data_reduction_proxy_chrome_settings)); 675 base::Unretained(data_reduction_proxy_chrome_settings));
673 // The configurator is used by DataReductionProxyChromeSettings and 676 // The configurator is used by DataReductionProxyChromeSettings and
674 // ProfileIOData. Ownership is passed to the latter via ProfileIOData::Handle, 677 // ProfileIOData. Ownership is passed to the latter via ProfileIOData::Handle,
675 // which is only destroyed after BrowserContextKeyedServices, 678 // which is only destroyed after BrowserContextKeyedServices,
676 // including DataReductionProxyChromeSettings. 679 // including DataReductionProxyChromeSettings.
677 chrome_configurator.reset( 680 chrome_configurator.reset(
678 new DataReductionProxyChromeConfigurator( 681 new DataReductionProxyChromeConfigurator(
679 prefs_.get(), 682 prefs_.get(),
680 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); 683 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
681 // Retain a raw pointer to use for initialization of data reduction proxy 684 // Retain a raw pointer to use for initialization of data reduction proxy
682 // settings after ownership is passed. 685 // settings after ownership is passed.
683 DataReductionProxyChromeConfigurator* 686 DataReductionProxyChromeConfigurator*
684 data_reduction_proxy_chrome_configurator = chrome_configurator.get(); 687 data_reduction_proxy_chrome_configurator = chrome_configurator.get();
688 #if defined(OS_ANDROID) || defined(OS_IOS)
689 // On mobile we write data reduction proxy prefs directly to the pref service.
690 // On desktop we store data reduction proxy prefs in memory, writing to disk
691 // every 60 minutes and on termination. Shutdown hooks must be added for
692 // Android and iOS in order for non-zero delays to be supported.
693 // (http://crbug.com/408264)
694 base::TimeDelta commit_delay = base::TimeDelta();
695 #else
696 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60);
685 #endif 697 #endif
698 data_reduction_proxy_statistics_prefs =
699 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(
700 new data_reduction_proxy::DataReductionProxyStatisticsPrefs(
701 g_browser_process->local_state(),
702 base::MessageLoopProxy::current(),
703 commit_delay));
704 data_reduction_proxy_chrome_settings->SetDataReductionProxyStatisticsPrefs(
705 data_reduction_proxy_statistics_prefs.get());
706 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
686 707
687 // Make sure we initialize the ProfileIOData after everything else has been 708 // Make sure we initialize the ProfileIOData after everything else has been
688 // initialized that we might be reading from the IO thread. 709 // initialized that we might be reading from the IO thread.
689 710
690 io_data_.Init(cookie_path, channel_id_path, cache_path, 711 io_data_.Init(cookie_path, channel_id_path, cache_path,
691 cache_max_size, media_cache_path, media_cache_max_size, 712 cache_max_size, media_cache_path, media_cache_max_size,
692 extensions_cookie_path, GetPath(), infinite_cache_path, 713 extensions_cookie_path, GetPath(), infinite_cache_path,
693 predictor_, session_cookie_mode, GetSpecialStoragePolicy(), 714 predictor_, session_cookie_mode, GetSpecialStoragePolicy(),
694 CreateDomainReliabilityMonitor(local_state), 715 CreateDomainReliabilityMonitor(local_state),
695 data_reduction_proxy_unavailable, 716 data_reduction_proxy_unavailable,
696 chrome_configurator.Pass(), 717 chrome_configurator.Pass(),
697 data_reduction_proxy_params.Pass()); 718 data_reduction_proxy_params.Pass(),
719 data_reduction_proxy_statistics_prefs.Pass());
698 720
699 #if defined(SPDY_PROXY_AUTH_ORIGIN) 721 #if defined(SPDY_PROXY_AUTH_ORIGIN)
700 data_reduction_proxy_chrome_settings->InitDataReductionProxySettings( 722 data_reduction_proxy_chrome_settings->InitDataReductionProxySettings(
701 data_reduction_proxy_chrome_configurator, 723 data_reduction_proxy_chrome_configurator,
702 prefs_.get(), 724 prefs_.get(),
703 g_browser_process->local_state(), 725 g_browser_process->local_state(),
704 GetRequestContext()); 726 GetRequestContext());
705 #endif 727 #endif
706 728
707 #if defined(ENABLE_PLUGINS) 729 #if defined(ENABLE_PLUGINS)
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> 1474 domain_reliability::DomainReliabilityServiceFactory::GetInstance()->
1453 GetForBrowserContext(this); 1475 GetForBrowserContext(this);
1454 if (!service) 1476 if (!service)
1455 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); 1477 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>();
1456 1478
1457 return service->CreateMonitor( 1479 return service->CreateMonitor(
1458 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), 1480 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
1459 local_state, 1481 local_state,
1460 prefs::kMetricsReportingEnabled); 1482 prefs::kMetricsReportingEnabled);
1461 } 1483 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698