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

Unified Diff: chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc

Issue 1530763004: Add Statistics for SupervisedUserSettingService during merging and syncing data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 4 years, 11 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 | « no previous file | chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc
diff --git a/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc b/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc
index 60ec741691a6160e6fb02412b393bfb035aeac18..d63b824340ca396cbb0c90de51f3afb1a56d1d38 100644
--- a/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc
+++ b/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc
@@ -198,6 +198,21 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing(
sync_processor_ = std::move(sync_processor);
error_handler_ = std::move(error_handler);
+ int num_added = 0;
+ int num_modified = 0;
+ int num_before_association = 0;
+ std::map<std::string, std::set<std::string> > pref_seen_keys;
+ const DictionaryValue* pref_dict =
+ prefs_->GetDictionary(prefs::kSupervisedUserSharedSettings);
+ for (DictionaryValue::Iterator it(*pref_dict); !it.IsAtEnd(); it.Advance()) {
+ const DictionaryValue* dict = NULL;
Bernhard Bauer 2016/01/07 10:04:29 Use nullptr instead of NULL.
Deepak 2016/01/07 10:40:07 Done.
+ bool success = it.value().GetAsDictionary(&dict);
+ DCHECK(success);
+ num_before_association += dict->size();
+ for (DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); jt.Advance())
+ pref_seen_keys[it.key()].insert(jt.key());
+ }
+
// We keep a map from MU ID to the set of keys that we have seen in the
// initial sync data.
std::map<std::string, std::set<std::string> > seen_keys;
Bernhard Bauer 2016/01/07 10:04:29 Rename this to |sync_seen_keys| to distinguish it
Deepak 2016/01/07 10:40:07 Done.
@@ -224,6 +239,11 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing(
kAcknowledged, supervised_user_shared_setting.acknowledged());
callbacks_.Notify(su_id, key);
+ if (pref_seen_keys.find(su_id) == pref_seen_keys.end())
+ num_added++;
+ else
+ num_modified++;
+
seen_keys[su_id].insert(key);
}
@@ -259,7 +279,10 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing(
sync_processor_->ProcessSyncChanges(FROM_HERE, change_list));
}
- // TODO(bauerb): Statistics?
+ result.set_num_items_added(num_added);
+ result.set_num_items_modified(num_modified);
+ result.set_num_items_before_association(num_before_association);
+ result.set_num_items_after_association(num_before_association + num_added);
Bernhard Bauer 2016/01/07 10:04:29 Let's not do this, please. If we have a bug in the
Deepak 2016/01/07 10:40:07 I got your point. Thanks
return result;
}
« no previous file with comments | « no previous file | chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698