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

Side by Side Diff: components/sync/core/processor_entity_tracker.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/internal_api/public/processor_entity_tracker.h" 5 #include "components/sync/core/processor_entity_tracker.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "sync/internal_api/public/non_blocking_sync_common.h" 12 #include "components/sync/base/time.h"
13 #include "sync/syncable/syncable_util.h" 13 #include "components/sync/core/non_blocking_sync_common.h"
14 #include "sync/util/time.h" 14 #include "components/sync/syncable/syncable_util.h"
15 15
16 namespace syncer_v2 { 16 namespace syncer_v2 {
17 17
18 namespace { 18 namespace {
19 19
20 void HashSpecifics(const sync_pb::EntitySpecifics& specifics, 20 void HashSpecifics(const sync_pb::EntitySpecifics& specifics,
21 std::string* hash) { 21 std::string* hash) {
22 DCHECK_GT(specifics.ByteSize(), 0); 22 DCHECK_GT(specifics.ByteSize(), 0);
23 base::Base64Encode(base::SHA1HashString(specifics.SerializeAsString()), hash); 23 base::Base64Encode(base::SHA1HashString(specifics.SerializeAsString()), hash);
24 } 24 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DCHECK(RequiresCommitData()); 75 DCHECK(RequiresCommitData());
76 commit_data_ = data_ptr; 76 commit_data_ = data_ptr;
77 DCHECK(HasCommitData()); 77 DCHECK(HasCommitData());
78 } 78 }
79 79
80 bool ProcessorEntityTracker::HasCommitData() const { 80 bool ProcessorEntityTracker::HasCommitData() const {
81 return !commit_data_->client_tag_hash.empty(); 81 return !commit_data_->client_tag_hash.empty();
82 } 82 }
83 83
84 bool ProcessorEntityTracker::MatchesData(const EntityData& data) const { 84 bool ProcessorEntityTracker::MatchesData(const EntityData& data) const {
85 return metadata_.is_deleted() ? data.is_deleted() : 85 return metadata_.is_deleted() ? data.is_deleted()
86 MatchesSpecificsHash(data.specifics); 86 : MatchesSpecificsHash(data.specifics);
87 } 87 }
88 88
89 bool ProcessorEntityTracker::MatchesBaseData(const EntityData& data) const { 89 bool ProcessorEntityTracker::MatchesBaseData(const EntityData& data) const {
90 DCHECK(IsUnsynced()); 90 DCHECK(IsUnsynced());
91 if (data.is_deleted() || metadata_.base_specifics_hash().empty()) { 91 if (data.is_deleted() || metadata_.base_specifics_hash().empty()) {
92 return false; 92 return false;
93 } 93 }
94 std::string hash; 94 std::string hash;
95 HashSpecifics(data.specifics, &hash); 95 HashSpecifics(data.specifics, &hash);
96 return hash == metadata_.base_specifics_hash(); 96 return hash == metadata_.base_specifics_hash();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 void ProcessorEntityTracker::UpdateSpecificsHash( 246 void ProcessorEntityTracker::UpdateSpecificsHash(
247 const sync_pb::EntitySpecifics& specifics) { 247 const sync_pb::EntitySpecifics& specifics) {
248 if (specifics.ByteSize() > 0) { 248 if (specifics.ByteSize() > 0) {
249 HashSpecifics(specifics, metadata_.mutable_specifics_hash()); 249 HashSpecifics(specifics, metadata_.mutable_specifics_hash());
250 } else { 250 } else {
251 metadata_.clear_specifics_hash(); 251 metadata_.clear_specifics_hash();
252 } 252 }
253 } 253 }
254 254
255 } // namespace syncer_v2 255 } // namespace syncer_v2
OLDNEW
« no previous file with comments | « components/sync/core/processor_entity_tracker.h ('k') | components/sync/core/processor_entity_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698