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

Unified Diff: chrome/browser/prefs/pref_metrics_service.cc

Issue 24930003: Migrate startup URLs pref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prefs/pref_metrics_service.h ('k') | chrome/browser/prefs/session_startup_pref.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_metrics_service.cc
diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc
index 2ee5e1ae2b49ceb63710c778462df3e242ac14dd..bd268dfaf6054ad6b78be932ba0b3b1d48ee1fca 100644
--- a/chrome/browser/prefs/pref_metrics_service.cc
+++ b/chrome/browser/prefs/pref_metrics_service.cc
@@ -162,6 +162,10 @@ void PrefMetricsService::RecordLaunchPrefs() {
}
}
+ const ListValue* url_list = prefs_->GetList(
+ prefs::kURLsToRestoreOnStartupOld);
+ LogStartupURLsPrefChange("StartupURLsResetTime", url_list);
grt (UTC plus 2) 2013/09/27 13:24:45 to match when Log..() is called by the ChangeRegis
MAD 2013/09/27 14:54:20 I don't think I need that since this is not a sync
+
#if !defined(OS_ANDROID)
StartupTabs startup_tabs = PinnedTabCodec::ReadPinnedTabs(profile_);
UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.PinnedTabs",
@@ -197,6 +201,10 @@ void PrefMetricsService::RegisterSyncedPrefObservers() {
base::Bind(&PrefMetricsService::LogIntegerPrefChange,
base::Unretained(this),
kSessionStartupPrefValueMax));
+
+ AddPrefObserver(prefs::kURLsToRestoreOnStartupOld, "StartupURLsResetTime",
+ base::Bind(&PrefMetricsService::LogStartupURLsPrefChange,
+ base::Unretained(this)));
}
void PrefMetricsService::AddPrefObserver(
@@ -248,18 +256,27 @@ void PrefMetricsService::LogIntegerPrefChange(int boundary_value,
histogram->Add(integer_value);
}
-void PrefMetricsService::LogListPrefChange(
- const LogHistogramValueCallback& item_callback,
+void PrefMetricsService::LogStartupURLsPrefChange(
const std::string& histogram_name,
grt (UTC plus 2) 2013/09/27 13:24:45 why not use this on line 273 (it should be "Settin
MAD 2013/09/27 14:54:20 Because this is not a sync'able pref.
grt (UTC plus 2) 2013/09/27 15:50:21 This code is confusing as-is. There are two ways t
MAD 2013/09/27 17:35:39 OK, you convinced me, I'll work something up...
const Value* value) {
const ListValue* items = NULL;
- if (!value->GetAsList(&items))
+ if (!value->GetAsList(&items) || !items->GetSize())
return;
- for (size_t i = 0; i < items->GetSize(); ++i) {
- const Value *item_value = NULL;
- if (items->Get(i, &item_value))
- item_callback.Run(histogram_name, item_value);
+
+ // Empty migration time delta will identify initial migration.
grt (UTC plus 2) 2013/09/27 13:24:45 do you want to log initial migration?
MAD 2013/09/27 14:54:20 It is logged with a value of 0.0.
grt (UTC plus 2) 2013/09/27 15:50:21 If I understand the use of histograms here, there
MAD 2013/09/27 17:35:39 D'Ho! Of course... I didn't realize that because a
+ base::TimeDelta migration_time;
+ base::Time now(base::Time::Now());
+ if (prefs_->GetUserPrefValue(prefs::kRestoreStartupURLsMigrated)) {
+ migration_time = now - base::Time::FromDoubleT(
+ prefs_->GetDouble(prefs::kRestoreStartupURLsMigrated));
}
+ HISTOGRAM_CUSTOM_TIMES("Settings.StartupURLsResetTime",
+ migration_time,
+ base::TimeDelta::FromMinutes(1),
+ base::TimeDelta::FromDays(7),
+ 50);
+ prefs_->Set(prefs::kURLsToRestoreOnStartupOld, base::ListValue());
+ prefs_->SetDouble(prefs::kRestoreStartupURLsMigrated, now.ToDoubleT());
}
void PrefMetricsService::GetDeviceIdCallback(const std::string& device_id) {
« no previous file with comments | « chrome/browser/prefs/pref_metrics_service.h ('k') | chrome/browser/prefs/session_startup_pref.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698