Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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_WITH_VALUE("DataUse.Sync.Download.Count", | |
|
sclittle
2015/08/10 23:39:39
Just use the regular UMA_HISTOGRAM_SPARSE_SLOWLY f
| |
| 320 ModelTypeToHistogramInt(type), | |
| 321 1); | |
| 306 } | 322 } |
| 307 } | 323 } |
| 308 | 324 |
| 309 void ExpireEntriesByVersion(syncable::Directory* dir, | 325 void ExpireEntriesByVersion(syncable::Directory* dir, |
| 310 syncable::ModelNeutralWriteTransaction* trans, | 326 syncable::ModelNeutralWriteTransaction* trans, |
| 311 ModelType type, | 327 ModelType type, |
| 312 int64 version_watermark) { | 328 int64 version_watermark) { |
| 313 syncable::Directory::Metahandles handles; | 329 syncable::Directory::Metahandles handles; |
| 314 dir->GetMetaHandlesOfType(trans, type, &handles); | 330 dir->GetMetaHandlesOfType(trans, type, &handles); |
| 315 for (size_t i = 0; i < handles.size(); ++i) { | 331 for (size_t i = 0; i < handles.size(); ++i) { |
| 316 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE, | 332 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE, |
| 317 handles[i]); | 333 handles[i]); |
| 318 if (!entry.good() || !entry.GetId().ServerKnows() || | 334 if (!entry.good() || !entry.GetId().ServerKnows() || |
| 319 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) || | 335 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) || |
| 320 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() || | 336 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() || |
| 321 entry.GetIsDel() || entry.GetServerIsDel() || | 337 entry.GetIsDel() || entry.GetServerIsDel() || |
| 322 entry.GetBaseVersion() >= version_watermark) { | 338 entry.GetBaseVersion() >= version_watermark) { |
| 323 continue; | 339 continue; |
| 324 } | 340 } |
| 325 | 341 |
| 326 // Mark entry as unapplied update first to ensure journaling the deletion. | 342 // Mark entry as unapplied update first to ensure journaling the deletion. |
| 327 entry.PutIsUnappliedUpdate(true); | 343 entry.PutIsUnappliedUpdate(true); |
| 328 // Mark entry as deleted by server. | 344 // Mark entry as deleted by server. |
| 329 entry.PutServerIsDel(true); | 345 entry.PutServerIsDel(true); |
| 330 entry.PutServerVersion(version_watermark); | 346 entry.PutServerVersion(version_watermark); |
| 331 } | 347 } |
| 332 } | 348 } |
| 333 | 349 |
| 334 } // namespace syncer | 350 } // namespace syncer |
| OLD | NEW |