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

Side by Side Diff: sync/engine/process_updates_util.cc

Issue 1273303002: Measuring data use of different ModelTypes in Sync Service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewServices
Patch Set: Changing the name of histogramTester. Created 5 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "sync/engine/process_updates_util.h" 5 #include "sync/engine/process_updates_util.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/metrics/sparse_histogram.h"
8 #include "sync/engine/syncer_proto_util.h" 9 #include "sync/engine/syncer_proto_util.h"
9 #include "sync/engine/syncer_types.h" 10 #include "sync/engine/syncer_types.h"
10 #include "sync/engine/syncer_util.h" 11 #include "sync/engine/syncer_util.h"
11 #include "sync/internal_api/public/sessions/update_counters.h" 12 #include "sync/internal_api/public/sessions/update_counters.h"
12 #include "sync/syncable/directory.h" 13 #include "sync/syncable/directory.h"
13 #include "sync/syncable/model_neutral_mutable_entry.h" 14 #include "sync/syncable/model_neutral_mutable_entry.h"
14 #include "sync/syncable/syncable_model_neutral_write_transaction.h" 15 #include "sync/syncable/syncable_model_neutral_write_transaction.h"
15 #include "sync/syncable/syncable_proto_util.h" 16 #include "sync/syncable/syncable_proto_util.h"
16 #include "sync/syncable/syncable_util.h" 17 #include "sync/syncable/syncable_util.h"
17 #include "sync/util/cryptographer.h" 18 #include "sync/util/cryptographer.h"
18 19
20 #define UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE(name, sample, value) \
21 do { \
22 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \
23 name, base::HistogramBase::kUmaTargetedHistogramFlag); \
24 histogram->AddCount(sample, value); \
25 } while (0)
26
19 namespace syncer { 27 namespace syncer {
20 28
21 using sessions::StatusController; 29 using sessions::StatusController;
22 30
23 using syncable::GET_BY_ID; 31 using syncable::GET_BY_ID;
24 32
25 namespace { 33 namespace {
26 34
27 // This function attempts to determine whether or not this update is genuinely 35 // This function attempts to determine whether or not this update is genuinely
28 // new, or if it is a reflection of one of our own commits. 36 // new, or if it is a reflection of one of our own commits.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 counters->num_reflected_updates_received++; 304 counters->num_reflected_updates_received++;
297 } 305 }
298 if ((*update_it)->deleted()) { 306 if ((*update_it)->deleted()) {
299 status->increment_num_tombstone_updates_downloaded_by(1); 307 status->increment_num_tombstone_updates_downloaded_by(1);
300 counters->num_tombstone_updates_received++; 308 counters->num_tombstone_updates_received++;
301 } 309 }
302 VerifyResult verify_result = VerifyUpdate(trans, **update_it, type); 310 VerifyResult verify_result = VerifyUpdate(trans, **update_it, type);
303 if (verify_result != VERIFY_SUCCESS && verify_result != VERIFY_UNDELETE) 311 if (verify_result != VERIFY_SUCCESS && verify_result != VERIFY_UNDELETE)
304 continue; 312 continue;
305 ProcessUpdate(**update_it, dir->GetCryptographer(trans), trans); 313 ProcessUpdate(**update_it, dir->GetCryptographer(trans), trans);
314 if ((*update_it)->ByteSize() > 0) {
315 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE("DataUse.Sync.Download.Bytes",
316 ModelTypeToHistogramInt(type),
317 (*update_it)->ByteSize());
318 }
319 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Download.Count",
320 ModelTypeToHistogramInt(type));
306 } 321 }
307 } 322 }
308 323
309 void ExpireEntriesByVersion(syncable::Directory* dir, 324 void ExpireEntriesByVersion(syncable::Directory* dir,
310 syncable::ModelNeutralWriteTransaction* trans, 325 syncable::ModelNeutralWriteTransaction* trans,
311 ModelType type, 326 ModelType type,
312 int64 version_watermark) { 327 int64 version_watermark) {
313 syncable::Directory::Metahandles handles; 328 syncable::Directory::Metahandles handles;
314 dir->GetMetaHandlesOfType(trans, type, &handles); 329 dir->GetMetaHandlesOfType(trans, type, &handles);
315 for (size_t i = 0; i < handles.size(); ++i) { 330 for (size_t i = 0; i < handles.size(); ++i) {
316 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE, 331 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE,
317 handles[i]); 332 handles[i]);
318 if (!entry.good() || !entry.GetId().ServerKnows() || 333 if (!entry.good() || !entry.GetId().ServerKnows() ||
319 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) || 334 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) ||
320 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() || 335 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() ||
321 entry.GetIsDel() || entry.GetServerIsDel() || 336 entry.GetIsDel() || entry.GetServerIsDel() ||
322 entry.GetBaseVersion() >= version_watermark) { 337 entry.GetBaseVersion() >= version_watermark) {
323 continue; 338 continue;
324 } 339 }
325 340
326 // Mark entry as unapplied update first to ensure journaling the deletion. 341 // Mark entry as unapplied update first to ensure journaling the deletion.
327 entry.PutIsUnappliedUpdate(true); 342 entry.PutIsUnappliedUpdate(true);
328 // Mark entry as deleted by server. 343 // Mark entry as deleted by server.
329 entry.PutServerIsDel(true); 344 entry.PutServerIsDel(true);
330 entry.PutServerVersion(version_watermark); 345 entry.PutServerVersion(version_watermark);
331 } 346 }
332 } 347 }
333 348
334 } // namespace syncer 349 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698