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

Side by Side Diff: components/sync/syncable/syncable_util.cc

Issue 2502253003: [Sync] Move GenerateSyncableHash to base. (Closed)
Patch Set: Keep full syncable/ DEP. Created 4 years, 1 month 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/syncable/syncable_util.h" 5 #include "components/sync/syncable/syncable_util.h"
6 6
7 #include "base/base64.h"
8 #include "base/location.h" 7 #include "base/location.h"
9 #include "base/logging.h" 8 #include "base/logging.h"
10 #include "base/sha1.h"
11 #include "components/sync/syncable/directory.h" 9 #include "components/sync/syncable/directory.h"
12 #include "components/sync/syncable/entry.h" 10 #include "components/sync/syncable/entry.h"
13 #include "components/sync/syncable/mutable_entry.h" 11 #include "components/sync/syncable/mutable_entry.h"
14 #include "components/sync/syncable/syncable_id.h" 12 #include "components/sync/syncable/syncable_id.h"
15 #include "components/sync/syncable/syncable_write_transaction.h" 13 #include "components/sync/syncable/syncable_write_transaction.h"
16 14
17 namespace syncer { 15 namespace syncer {
18 namespace syncable { 16 namespace syncable {
19 17
20 // Returns the number of unsynced entries. 18 // Returns the number of unsynced entries.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const tracked_objects::Location& location, 83 const tracked_objects::Location& location,
86 const char* msg, 84 const char* msg,
87 BaseTransaction* trans) { 85 BaseTransaction* trans) {
88 if (!condition) { 86 if (!condition) {
89 trans->OnUnrecoverableError(location, msg); 87 trans->OnUnrecoverableError(location, msg);
90 return false; 88 return false;
91 } 89 }
92 return true; 90 return true;
93 } 91 }
94 92
95 std::string GenerateSyncableHash(ModelType model_type,
96 const std::string& client_tag) {
97 // Blank PB with just the field in it has termination symbol,
98 // handy for delimiter.
99 sync_pb::EntitySpecifics serialized_type;
100 AddDefaultFieldValue(model_type, &serialized_type);
101 std::string hash_input;
102 serialized_type.AppendToString(&hash_input);
103 hash_input.append(client_tag);
104
105 std::string encode_output;
106 base::Base64Encode(base::SHA1HashString(hash_input), &encode_output);
107 return encode_output;
108 }
109
110 std::string GenerateSyncableBookmarkHash(
111 const std::string& originator_cache_guid,
112 const std::string& originator_client_item_id) {
113 return syncable::GenerateSyncableHash(
114 BOOKMARKS, originator_cache_guid + originator_client_item_id);
115 }
116
117 } // namespace syncable 93 } // namespace syncable
118 } // namespace syncer 94 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/syncable_util.h ('k') | components/sync/syncable/syncable_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698