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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc

Issue 888713002: DataReductionProxyStatisticsPrefs should support WeakPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop_proxy.h"
8 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 12 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
12 #include "chrome/browser/prefs/proxy_prefs.h" 13 #include "chrome/browser/prefs/proxy_prefs.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h" 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h"
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h" 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 58 }
58 59
59 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { 60 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() {
60 } 61 }
61 62
62 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( 63 void DataReductionProxyChromeSettings::InitDataReductionProxySettings(
63 data_reduction_proxy::DataReductionProxyIOData* io_data, 64 data_reduction_proxy::DataReductionProxyIOData* io_data,
64 PrefService* profile_prefs, 65 PrefService* profile_prefs,
65 PrefService* local_state_prefs, 66 PrefService* local_state_prefs,
66 net::URLRequestContextGetter* request_context) { 67 net::URLRequestContextGetter* request_context) {
68 #if defined(OS_ANDROID) || defined(OS_IOS)
69 // On mobile we write data reduction proxy prefs directly to the pref service.
70 // On desktop we store data reduction proxy prefs in memory, writing to disk
71 // every 60 minutes and on termination. Shutdown hooks must be added for
72 // Android and iOS in order for non-zero delays to be supported.
73 // (http://crbug.com/408264)
74 base::TimeDelta commit_delay = base::TimeDelta();
75 #else
76 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60);
77 #endif
78 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>
79 statistics_prefs(
80 new data_reduction_proxy::DataReductionProxyStatisticsPrefs(
81 profile_prefs, base::MessageLoopProxy::current(), commit_delay));
67 SetProxyConfigurator(io_data->configurator()); 82 SetProxyConfigurator(io_data->configurator());
68 DataReductionProxySettings::InitDataReductionProxySettings( 83 DataReductionProxySettings::InitDataReductionProxySettings(
69 profile_prefs, 84 profile_prefs,
85 statistics_prefs.Pass(),
70 request_context, 86 request_context,
71 io_data->net_log(), 87 io_data->net_log(),
72 io_data->event_store()); 88 io_data->event_store());
73 DataReductionProxySettings::SetOnDataReductionEnabledCallback( 89 DataReductionProxySettings::SetOnDataReductionEnabledCallback(
74 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, 90 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial,
75 base::Unretained(this))); 91 base::Unretained(this)));
76 SetDataReductionProxyAlternativeEnabled( 92 SetDataReductionProxyAlternativeEnabled(
77 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); 93 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial());
78 // TODO(bengr): Remove after M46. See http://crbug.com/445599. 94 // TODO(bengr): Remove after M46. See http://crbug.com/445599.
79 MigrateDataReductionProxyOffProxyPrefs(profile_prefs); 95 MigrateDataReductionProxyOffProxyPrefs(profile_prefs);
96 io_data->SetDataReductionProxyStatisticsPrefs(
97 DataReductionProxySettings::statistics_prefs()->GetWeakPtr());
bengr 2015/02/04 23:39:10 Add a comment to the declaration of InitDRPSetting
megjablon 2015/02/06 23:40:41 Done.
80 } 98 }
81 99
82 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( 100 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial(
83 bool data_reduction_proxy_enabled) { 101 bool data_reduction_proxy_enabled) {
84 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( 102 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
85 "DataReductionProxyEnabled", 103 "DataReductionProxyEnabled",
86 data_reduction_proxy_enabled ? "true" : "false"); 104 data_reduction_proxy_enabled ? "true" : "false");
87 } 105 }
88 106
89 // static 107 // static
(...skipping 15 matching lines...) Expand all
105 #elif defined(OS_OPENBSD) 123 #elif defined(OS_OPENBSD)
106 return Client::CHROME_OPENBSD; 124 return Client::CHROME_OPENBSD;
107 #elif defined(OS_SOLARIS) 125 #elif defined(OS_SOLARIS)
108 return Client::CHROME_SOLARIS; 126 return Client::CHROME_SOLARIS;
109 #elif defined(OS_QNX) 127 #elif defined(OS_QNX)
110 return Client::CHROME_QNX; 128 return Client::CHROME_QNX;
111 #else 129 #else
112 return Client::UNKNOWN; 130 return Client::UNKNOWN;
113 #endif 131 #endif
114 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698