| 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 "components/sync/engine_impl/process_updates_util.h" | 5 #include "components/sync/engine_impl/process_updates_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
| 14 #include "components/sync/base/cryptographer.h" | 14 #include "components/sync/base/cryptographer.h" |
| 15 #include "components/sync/base/data_type_histogram.h" | 15 #include "components/sync/base/data_type_histogram.h" |
| 16 #include "components/sync/engine/cycle/update_counters.h" |
| 16 #include "components/sync/engine_impl/syncer_proto_util.h" | 17 #include "components/sync/engine_impl/syncer_proto_util.h" |
| 17 #include "components/sync/engine_impl/syncer_types.h" | 18 #include "components/sync/engine_impl/syncer_types.h" |
| 18 #include "components/sync/engine_impl/syncer_util.h" | 19 #include "components/sync/engine_impl/syncer_util.h" |
| 19 #include "components/sync/sessions/update_counters.h" | |
| 20 #include "components/sync/syncable/directory.h" | 20 #include "components/sync/syncable/directory.h" |
| 21 #include "components/sync/syncable/model_neutral_mutable_entry.h" | 21 #include "components/sync/syncable/model_neutral_mutable_entry.h" |
| 22 #include "components/sync/syncable/syncable_model_neutral_write_transaction.h" | 22 #include "components/sync/syncable/syncable_model_neutral_write_transaction.h" |
| 23 #include "components/sync/syncable/syncable_proto_util.h" | 23 #include "components/sync/syncable/syncable_proto_util.h" |
| 24 #include "components/sync/syncable/syncable_util.h" | 24 #include "components/sync/syncable/syncable_util.h" |
| 25 | 25 |
| 26 namespace syncer { | 26 namespace syncer { |
| 27 | 27 |
| 28 using sessions::StatusController; | |
| 29 | |
| 30 using syncable::GET_BY_ID; | 28 using syncable::GET_BY_ID; |
| 31 | 29 |
| 32 namespace { | 30 namespace { |
| 33 | 31 |
| 34 // This function attempts to determine whether or not this update is genuinely | 32 // This function attempts to determine whether or not this update is genuinely |
| 35 // new, or if it is a reflection of one of our own commits. | 33 // new, or if it is a reflection of one of our own commits. |
| 36 // | 34 // |
| 37 // There is a known inaccuracy in its implementation. If this update ends up | 35 // There is a known inaccuracy in its implementation. If this update ends up |
| 38 // being applied to a local item with a different ID, we will count the change | 36 // being applied to a local item with a different ID, we will count the change |
| 39 // as being a non-reflection update. Fortunately, the server usually updates | 37 // as being a non-reflection update. Fortunately, the server usually updates |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 273 |
| 276 return; | 274 return; |
| 277 } | 275 } |
| 278 | 276 |
| 279 } // namespace | 277 } // namespace |
| 280 | 278 |
| 281 void ProcessDownloadedUpdates(syncable::Directory* dir, | 279 void ProcessDownloadedUpdates(syncable::Directory* dir, |
| 282 syncable::ModelNeutralWriteTransaction* trans, | 280 syncable::ModelNeutralWriteTransaction* trans, |
| 283 ModelType type, | 281 ModelType type, |
| 284 const SyncEntityList& applicable_updates, | 282 const SyncEntityList& applicable_updates, |
| 285 sessions::StatusController* status, | 283 StatusController* status, |
| 286 UpdateCounters* counters) { | 284 UpdateCounters* counters) { |
| 287 for (SyncEntityList::const_iterator update_it = applicable_updates.begin(); | 285 for (SyncEntityList::const_iterator update_it = applicable_updates.begin(); |
| 288 update_it != applicable_updates.end(); ++update_it) { | 286 update_it != applicable_updates.end(); ++update_it) { |
| 289 DCHECK_EQ(type, GetModelType(**update_it)); | 287 DCHECK_EQ(type, GetModelType(**update_it)); |
| 290 if (!UpdateContainsNewVersion(trans, **update_it)) { | 288 if (!UpdateContainsNewVersion(trans, **update_it)) { |
| 291 status->increment_num_reflected_updates_downloaded_by(1); | 289 status->increment_num_reflected_updates_downloaded_by(1); |
| 292 counters->num_reflected_updates_received++; | 290 counters->num_reflected_updates_received++; |
| 293 } | 291 } |
| 294 if ((*update_it)->deleted()) { | 292 if ((*update_it)->deleted()) { |
| 295 status->increment_num_tombstone_updates_downloaded_by(1); | 293 status->increment_num_tombstone_updates_downloaded_by(1); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 326 |
| 329 // Mark entry as unapplied update first to ensure journaling the deletion. | 327 // Mark entry as unapplied update first to ensure journaling the deletion. |
| 330 entry.PutIsUnappliedUpdate(true); | 328 entry.PutIsUnappliedUpdate(true); |
| 331 // Mark entry as deleted by server. | 329 // Mark entry as deleted by server. |
| 332 entry.PutServerIsDel(true); | 330 entry.PutServerIsDel(true); |
| 333 entry.PutServerVersion(version_watermark); | 331 entry.PutServerVersion(version_watermark); |
| 334 } | 332 } |
| 335 } | 333 } |
| 336 | 334 |
| 337 } // namespace syncer | 335 } // namespace syncer |
| OLD | NEW |