| 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" |
| 19 #include "sync/util/data_type_histogram.h" |
| 18 | 20 |
| 19 namespace syncer { | 21 namespace syncer { |
| 20 | 22 |
| 21 using sessions::StatusController; | 23 using sessions::StatusController; |
| 22 | 24 |
| 23 using syncable::GET_BY_ID; | 25 using syncable::GET_BY_ID; |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 // This function attempts to determine whether or not this update is genuinely | 29 // This function attempts to determine whether or not this update is genuinely |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 counters->num_reflected_updates_received++; | 298 counters->num_reflected_updates_received++; |
| 297 } | 299 } |
| 298 if ((*update_it)->deleted()) { | 300 if ((*update_it)->deleted()) { |
| 299 status->increment_num_tombstone_updates_downloaded_by(1); | 301 status->increment_num_tombstone_updates_downloaded_by(1); |
| 300 counters->num_tombstone_updates_received++; | 302 counters->num_tombstone_updates_received++; |
| 301 } | 303 } |
| 302 VerifyResult verify_result = VerifyUpdate(trans, **update_it, type); | 304 VerifyResult verify_result = VerifyUpdate(trans, **update_it, type); |
| 303 if (verify_result != VERIFY_SUCCESS && verify_result != VERIFY_UNDELETE) | 305 if (verify_result != VERIFY_SUCCESS && verify_result != VERIFY_UNDELETE) |
| 304 continue; | 306 continue; |
| 305 ProcessUpdate(**update_it, dir->GetCryptographer(trans), trans); | 307 ProcessUpdate(**update_it, dir->GetCryptographer(trans), trans); |
| 308 if ((*update_it)->ByteSize() > 0) { |
| 309 SyncRecordDatatypeBin("DataUse.Sync.Download.Bytes", |
| 310 ModelTypeToHistogramInt(type), |
| 311 (*update_it)->ByteSize()); |
| 312 } |
| 313 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Download.Count", |
| 314 ModelTypeToHistogramInt(type)); |
| 306 } | 315 } |
| 307 } | 316 } |
| 308 | 317 |
| 309 void ExpireEntriesByVersion(syncable::Directory* dir, | 318 void ExpireEntriesByVersion(syncable::Directory* dir, |
| 310 syncable::ModelNeutralWriteTransaction* trans, | 319 syncable::ModelNeutralWriteTransaction* trans, |
| 311 ModelType type, | 320 ModelType type, |
| 312 int64 version_watermark) { | 321 int64 version_watermark) { |
| 313 syncable::Directory::Metahandles handles; | 322 syncable::Directory::Metahandles handles; |
| 314 dir->GetMetaHandlesOfType(trans, type, &handles); | 323 dir->GetMetaHandlesOfType(trans, type, &handles); |
| 315 for (size_t i = 0; i < handles.size(); ++i) { | 324 for (size_t i = 0; i < handles.size(); ++i) { |
| 316 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE, | 325 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE, |
| 317 handles[i]); | 326 handles[i]); |
| 318 if (!entry.good() || !entry.GetId().ServerKnows() || | 327 if (!entry.good() || !entry.GetId().ServerKnows() || |
| 319 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) || | 328 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) || |
| 320 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() || | 329 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() || |
| 321 entry.GetIsDel() || entry.GetServerIsDel() || | 330 entry.GetIsDel() || entry.GetServerIsDel() || |
| 322 entry.GetBaseVersion() >= version_watermark) { | 331 entry.GetBaseVersion() >= version_watermark) { |
| 323 continue; | 332 continue; |
| 324 } | 333 } |
| 325 | 334 |
| 326 // Mark entry as unapplied update first to ensure journaling the deletion. | 335 // Mark entry as unapplied update first to ensure journaling the deletion. |
| 327 entry.PutIsUnappliedUpdate(true); | 336 entry.PutIsUnappliedUpdate(true); |
| 328 // Mark entry as deleted by server. | 337 // Mark entry as deleted by server. |
| 329 entry.PutServerIsDel(true); | 338 entry.PutServerIsDel(true); |
| 330 entry.PutServerVersion(version_watermark); | 339 entry.PutServerVersion(version_watermark); |
| 331 } | 340 } |
| 332 } | 341 } |
| 333 | 342 |
| 334 } // namespace syncer | 343 } // namespace syncer |
| OLD | NEW |