Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: sync/engine/process_updates_util.cc

Issue 1545553003: Switch to standard integer types in sync/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/engine/process_updates_util.h ('k') | sync/engine/sync_scheduler_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h>
8 #include <stdint.h>
9
7 #include <string> 10 #include <string>
8 11
9 #include "base/location.h" 12 #include "base/location.h"
10 #include "base/metrics/sparse_histogram.h" 13 #include "base/metrics/sparse_histogram.h"
11 #include "sync/engine/syncer_proto_util.h" 14 #include "sync/engine/syncer_proto_util.h"
12 #include "sync/engine/syncer_types.h" 15 #include "sync/engine/syncer_types.h"
13 #include "sync/engine/syncer_util.h" 16 #include "sync/engine/syncer_util.h"
14 #include "sync/internal_api/public/sessions/update_counters.h" 17 #include "sync/internal_api/public/sessions/update_counters.h"
15 #include "sync/syncable/directory.h" 18 #include "sync/syncable/directory.h"
16 #include "sync/syncable/model_neutral_mutable_entry.h" 19 #include "sync/syncable/model_neutral_mutable_entry.h"
(...skipping 27 matching lines...) Expand all
44 // updates its local ID. 47 // updates its local ID.
45 // - When two attempts to create an item with identical UNIQUE_CLIENT_TAG values 48 // - When two attempts to create an item with identical UNIQUE_CLIENT_TAG values
46 // collide at the server. I have seen this in testing. When it happens, the 49 // collide at the server. I have seen this in testing. When it happens, the
47 // test server will send one of the clients a response to upate its local ID so 50 // test server will send one of the clients a response to upate its local ID so
48 // that both clients will refer to the item using the same ID going forward. In 51 // that both clients will refer to the item using the same ID going forward. In
49 // this case, we're right to assume that the update is not a reflection. 52 // this case, we're right to assume that the update is not a reflection.
50 // 53 //
51 // For more information, see FindLocalIdToUpdate(). 54 // For more information, see FindLocalIdToUpdate().
52 bool UpdateContainsNewVersion(syncable::BaseTransaction *trans, 55 bool UpdateContainsNewVersion(syncable::BaseTransaction *trans,
53 const sync_pb::SyncEntity &update) { 56 const sync_pb::SyncEntity &update) {
54 int64 existing_version = -1; // The server always sends positive versions. 57 int64_t existing_version = -1; // The server always sends positive versions.
55 syncable::Entry existing_entry(trans, GET_BY_ID, 58 syncable::Entry existing_entry(trans, GET_BY_ID,
56 SyncableIdFromProto(update.id_string())); 59 SyncableIdFromProto(update.id_string()));
57 if (existing_entry.good()) 60 if (existing_entry.good())
58 existing_version = existing_entry.GetBaseVersion(); 61 existing_version = existing_entry.GetBaseVersion();
59 62
60 if (!existing_entry.good() && update.deleted()) { 63 if (!existing_entry.good() && update.deleted()) {
61 // There are several possible explanations for this. The most common cases 64 // There are several possible explanations for this. The most common cases
62 // will be first time sync and the redelivery of deletions we've already 65 // will be first time sync and the redelivery of deletions we've already
63 // synced, accepted, and purged from our database. In either case, the 66 // synced, accepted, and purged from our database. In either case, the
64 // update is useless to us. Let's count them all as "not new", even though 67 // update is useless to us. Let's count them all as "not new", even though
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 (*update_it)->ByteSize()); 315 (*update_it)->ByteSize());
313 } 316 }
314 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Download.Count", 317 UMA_HISTOGRAM_SPARSE_SLOWLY("DataUse.Sync.Download.Count",
315 ModelTypeToHistogramInt(type)); 318 ModelTypeToHistogramInt(type));
316 } 319 }
317 } 320 }
318 321
319 void ExpireEntriesByVersion(syncable::Directory* dir, 322 void ExpireEntriesByVersion(syncable::Directory* dir,
320 syncable::ModelNeutralWriteTransaction* trans, 323 syncable::ModelNeutralWriteTransaction* trans,
321 ModelType type, 324 ModelType type,
322 int64 version_watermark) { 325 int64_t version_watermark) {
323 syncable::Directory::Metahandles handles; 326 syncable::Directory::Metahandles handles;
324 dir->GetMetaHandlesOfType(trans, type, &handles); 327 dir->GetMetaHandlesOfType(trans, type, &handles);
325 for (size_t i = 0; i < handles.size(); ++i) { 328 for (size_t i = 0; i < handles.size(); ++i) {
326 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE, 329 syncable::ModelNeutralMutableEntry entry(trans, syncable::GET_BY_HANDLE,
327 handles[i]); 330 handles[i]);
328 if (!entry.good() || !entry.GetId().ServerKnows() || 331 if (!entry.good() || !entry.GetId().ServerKnows() ||
329 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) || 332 entry.GetUniqueServerTag() == ModelTypeToRootTag(type) ||
330 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() || 333 entry.GetIsUnappliedUpdate() || entry.GetIsUnsynced() ||
331 entry.GetIsDel() || entry.GetServerIsDel() || 334 entry.GetIsDel() || entry.GetServerIsDel() ||
332 entry.GetBaseVersion() >= version_watermark) { 335 entry.GetBaseVersion() >= version_watermark) {
333 continue; 336 continue;
334 } 337 }
335 338
336 // Mark entry as unapplied update first to ensure journaling the deletion. 339 // Mark entry as unapplied update first to ensure journaling the deletion.
337 entry.PutIsUnappliedUpdate(true); 340 entry.PutIsUnappliedUpdate(true);
338 // Mark entry as deleted by server. 341 // Mark entry as deleted by server.
339 entry.PutServerIsDel(true); 342 entry.PutServerIsDel(true);
340 entry.PutServerVersion(version_watermark); 343 entry.PutServerVersion(version_watermark);
341 } 344 }
342 } 345 }
343 346
344 } // namespace syncer 347 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/process_updates_util.h ('k') | sync/engine/sync_scheduler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698