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..1e2c690aa7328ac59a480973922b6c113b043178 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 |
| @@ -201,6 +201,14 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing( |
| // 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; |
| + SyncMergeResult result(SUPERVISED_USER_SHARED_SETTINGS); |
| + int num_added = 0; |
| + int num_modified = 0; |
| + |
| + DictionaryPrefUpdate update_prefs(prefs_, |
|
Bernhard Bauer
2016/01/06 16:41:50
If you don't need to modify anything, you can just
Deepak
2016/01/07 09:52:31
Done.
|
| + prefs::kSupervisedUserSharedSettings); |
| + base::DictionaryValue* pref_dict = update_prefs.Get(); |
| + result.set_num_items_before_association(pref_dict->size()); |
|
Bernhard Bauer
2016/01/06 16:41:50
Can you put this into a local variable like |num_a
Deepak
2016/01/07 09:52:31
Done.
|
| // Iterate over all initial sync data, and update it locally. This means that |
| // the value from the server always wins over a local value. |
| @@ -224,6 +232,10 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing( |
| kAcknowledged, supervised_user_shared_setting.acknowledged()); |
| callbacks_.Notify(su_id, key); |
| + if (seen_keys.find(su_id) == seen_keys.end()) |
| + num_added++; |
| + else |
| + num_modified++; |
| seen_keys[su_id].insert(key); |
| } |
| @@ -252,14 +264,16 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing( |
| } |
| } |
| - SyncMergeResult result(SUPERVISED_USER_SHARED_SETTINGS); |
| // Process all the accumulated changes. |
| if (change_list.size() > 0) { |
| result.set_error( |
| 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_deleted(0); |
|
Bernhard Bauer
2016/01/06 16:41:50
It's fine not to set this value (0 is the default
Deepak
2016/01/07 09:52:31
Done.
|
| + result.set_num_items_after_association(pref_dict->size()); |
| return result; |
| } |