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