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) | |
|
bengr
2015/08/07 17:13:37
Add curly braces.
amohammadkhan
2015/08/07 18:52:30
Done.
| |
| 315 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE("DataUse.Sync.Download.Bytes", | |
| 316 type, (*update_it)->ByteSize()); | |
| 317 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE("DataUse.Sync.Download.Count", type, | |
| 318 1); | |
| 306 } | 319 } |
| 307 } | 320 } |
| 308 | 321 |
| 309 void ExpireEntriesByVersion(syncable::Directory* dir, | 322 void ExpireEntriesByVersion(syncable::Directory* dir, |
| 310 syncable::ModelNeutralWriteTransaction* trans, | 323 syncable::ModelNeutralWriteTransaction* trans, |
| 311 ModelType type, | 324 ModelType type, |
| 312 int64 version_watermark) { | 325 int64 version_watermark) { |
| 313 syncable::Directory::Metahandles handles; | 326 syncable::Directory::Metahandles handles; |
| 314 dir->GetMetaHandlesOfType(trans, type, &handles); | 327 dir->GetMetaHandlesOfType(trans, type, &handles); |
| 315 for (size_t i = 0; i < handles.size(); ++i) { | 328 for (size_t i = 0; i < handles.size(); ++i) { |
| 316 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE, | 329 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE, |
| 317 handles[i]); | 330 handles[i]); |
| 318 if (!entry.good() || !entry.GetId().ServerKnows() || | 331 if (!entry.good() || !entry.GetId().ServerKnows() || |
| 319 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) || | 332 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) || |
| 320 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() || | 333 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() || |
| 321 entry.GetIsDel() || entry.GetServerIsDel() || | 334 entry.GetIsDel() || entry.GetServerIsDel() || |
| 322 entry.GetBaseVersion() >= version_watermark) { | 335 entry.GetBaseVersion() >= version_watermark) { |
| 323 continue; | 336 continue; |
| 324 } | 337 } |
| 325 | 338 |
| 326 // Mark entry as unapplied update first to ensure journaling the deletion. | 339 // Mark entry as unapplied update first to ensure journaling the deletion. |
| 327 entry.PutIsUnappliedUpdate(true); | 340 entry.PutIsUnappliedUpdate(true); |
| 328 // Mark entry as deleted by server. | 341 // Mark entry as deleted by server. |
| 329 entry.PutServerIsDel(true); | 342 entry.PutServerIsDel(true); |
| 330 entry.PutServerVersion(version_watermark); | 343 entry.PutServerVersion(version_watermark); |
| 331 } | 344 } |
| 332 } | 345 } |
| 333 | 346 |
| 334 } // namespace syncer | 347 } // namespace syncer |
| OLD | NEW |