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

Side by Side 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: Added before and after association statistic. 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 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/supervised_user/legacy/supervised_user_shared_settings_ service.h" 5 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 callbacks_.Notify(su_id, key); 225 callbacks_.Notify(su_id, key);
226 226
227 seen_keys[su_id].insert(key); 227 seen_keys[su_id].insert(key);
228 } 228 }
229 229
230 // Iterate over all settings that we have locally, which includes settings 230 // Iterate over all settings that we have locally, which includes settings
231 // that were just synced down. We filter those out using |seen_keys|. 231 // that were just synced down. We filter those out using |seen_keys|.
232 SyncChangeList change_list; 232 SyncChangeList change_list;
233 const DictionaryValue* all_settings = 233 const DictionaryValue* all_settings =
234 prefs_->GetDictionary(prefs::kSupervisedUserSharedSettings); 234 prefs_->GetDictionary(prefs::kSupervisedUserSharedSettings);
235 int num_association = 0;
235 for (DictionaryValue::Iterator it(*all_settings); !it.IsAtEnd(); 236 for (DictionaryValue::Iterator it(*all_settings); !it.IsAtEnd();
236 it.Advance()) { 237 it.Advance()) {
237 const DictionaryValue* dict = NULL; 238 const DictionaryValue* dict = NULL;
238 bool success = it.value().GetAsDictionary(&dict); 239 bool success = it.value().GetAsDictionary(&dict);
239 DCHECK(success); 240 DCHECK(success);
240 241
242 num_association += dict->size();
241 const std::set<std::string>& seen = seen_keys[it.key()]; 243 const std::set<std::string>& seen = seen_keys[it.key()];
242 for (DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); jt.Advance()) { 244 for (DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); jt.Advance()) {
243 // We only need to upload settings that we haven't seen in the initial 245 // We only need to upload settings that we haven't seen in the initial
244 // sync data (which means they were added locally). 246 // sync data (which means they were added locally).
245 if (seen.count(jt.key()) > 0) 247 if (seen.count(jt.key()) > 0)
246 continue; 248 continue;
247 249
248 SyncData data = CreateSyncDataForValue(it.key(), jt.key(), jt.value()); 250 SyncData data = CreateSyncDataForValue(it.key(), jt.key(), jt.value());
249 DCHECK(data.IsValid()); 251 DCHECK(data.IsValid());
250 change_list.push_back( 252 change_list.push_back(
251 SyncChange(FROM_HERE, SyncChange::ACTION_ADD, data)); 253 SyncChange(FROM_HERE, SyncChange::ACTION_ADD, data));
252 } 254 }
253 } 255 }
254 256
255 SyncMergeResult result(SUPERVISED_USER_SHARED_SETTINGS); 257 SyncMergeResult result(SUPERVISED_USER_SHARED_SETTINGS);
256 // Process all the accumulated changes. 258 // Process all the accumulated changes.
257 if (change_list.size() > 0) { 259 if (change_list.size() > 0) {
258 result.set_error( 260 result.set_error(
259 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list)); 261 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list));
260 } 262 }
261 263
262 // TODO(bauerb): Statistics? 264 result.set_num_items_added(change_list.size());
Bernhard Bauer 2016/01/05 09:37:30 Wait, is this right? IIUC, num_items_added is the
Deepak 2016/01/05 13:29:19 Done.
265 result.set_num_items_before_association(num_association - change_list.size());
266 result.set_num_items_after_association(num_association);
263 return result; 267 return result;
264 } 268 }
265 269
266 void SupervisedUserSharedSettingsService::StopSyncing(syncer::ModelType type) { 270 void SupervisedUserSharedSettingsService::StopSyncing(syncer::ModelType type) {
267 DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, type); 271 DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, type);
268 sync_processor_.reset(); 272 sync_processor_.reset();
269 error_handler_.reset(); 273 error_handler_.reset();
270 } 274 }
271 275
272 syncer::SyncDataList SupervisedUserSharedSettingsService::GetAllSyncData( 276 syncer::SyncDataList SupervisedUserSharedSettingsService::GetAllSyncData(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 NOTREACHED(); 341 NOTREACHED();
338 break; 342 break;
339 } 343 }
340 } 344 }
341 callbacks_.Notify(su_id, key); 345 callbacks_.Notify(su_id, key);
342 } 346 }
343 347
344 SyncError error; 348 SyncError error;
345 return error; 349 return error;
346 } 350 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698