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

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

Issue 11571092: sync: Move unique_client_tag hashing code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo some changes and move a test to syncable_util_unittest Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « sync/syncable/syncable_util.h ('k') | sync/syncable/syncable_util_unittest.cc » ('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 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 "sync/syncable/syncable_util.h" 5 #include "sync/syncable/syncable_util.h"
6 6
7 #include "base/base64.h"
7 #include "base/location.h" 8 #include "base/location.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sha1.h"
9 #include "sync/syncable/directory.h" 11 #include "sync/syncable/directory.h"
10 #include "sync/syncable/entry.h" 12 #include "sync/syncable/entry.h"
11 #include "sync/syncable/mutable_entry.h" 13 #include "sync/syncable/mutable_entry.h"
12 #include "sync/syncable/syncable_id.h" 14 #include "sync/syncable/syncable_id.h"
13 #include "sync/syncable/syncable_write_transaction.h" 15 #include "sync/syncable/syncable_write_transaction.h"
14 16
15 namespace syncer { 17 namespace syncer {
16 namespace syncable { 18 namespace syncable {
17 19
18 // Returns the number of unsynced entries. 20 // Returns the number of unsynced entries.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const tracked_objects::Location& location, 97 const tracked_objects::Location& location,
96 const char* msg, 98 const char* msg,
97 BaseTransaction* trans) { 99 BaseTransaction* trans) {
98 if (!condition) { 100 if (!condition) {
99 trans->OnUnrecoverableError(location, msg); 101 trans->OnUnrecoverableError(location, msg);
100 return false; 102 return false;
101 } 103 }
102 return true; 104 return true;
103 } 105 }
104 106
107 std::string GenerateSyncableHash(
108 ModelType model_type, const std::string& client_tag) {
109 // Blank PB with just the field in it has termination symbol,
110 // handy for delimiter.
111 sync_pb::EntitySpecifics serialized_type;
112 AddDefaultFieldValue(model_type, &serialized_type);
113 std::string hash_input;
114 serialized_type.AppendToString(&hash_input);
115 hash_input.append(client_tag);
116
117 std::string encode_output;
118 CHECK(base::Base64Encode(base::SHA1HashString(hash_input), &encode_output));
119 return encode_output;
120 }
121
105 } // namespace syncable 122 } // namespace syncable
106 } // namespace syncer 123 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/syncable_util.h ('k') | sync/syncable/syncable_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698