Chromium Code Reviews| 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; |
| } |