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

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

Issue 11637053: sync: Start moving away from PREV_ID and NEXT_ID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « sync/syncable/nigori_util.cc ('k') | no next file » | 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/base64.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // maintain linked-list invariants). In this case, NEXT_ID and PREV_ID 71 // maintain linked-list invariants). In this case, NEXT_ID and PREV_ID
72 // among the children will be valid after the loop, since we update all 72 // among the children will be valid after the loop, since we update all
73 // the children at once. 73 // the children at once.
74 child_entry.PutParentIdPropertyOnly(new_id); 74 child_entry.PutParentIdPropertyOnly(new_id);
75 } 75 }
76 } 76 }
77 // Update Id references on the previous and next nodes in the sibling 77 // Update Id references on the previous and next nodes in the sibling
78 // order. Do this by reinserting into the linked list; the first 78 // order. Do this by reinserting into the linked list; the first
79 // step in PutPredecessor is to Unlink from the existing order, which 79 // step in PutPredecessor is to Unlink from the existing order, which
80 // will overwrite the stale Id value from the adjacent nodes. 80 // will overwrite the stale Id value from the adjacent nodes.
81 if (entry->Get(PREV_ID) == entry->Get(NEXT_ID) && 81 if (entry->GetPredecessorId() == entry->GetSuccessorId() &&
82 entry->Get(PREV_ID) == old_id) { 82 entry->GetPredecessorId() == old_id) {
83 // We just need a shallow update to |entry|'s fields since it is already 83 // We just need a shallow update to |entry|'s fields since it is already
84 // self looped. 84 // self looped.
85 entry->Put(NEXT_ID, new_id); 85 entry->Put(NEXT_ID, new_id);
86 entry->Put(PREV_ID, new_id); 86 entry->Put(PREV_ID, new_id);
87 } else { 87 } else {
88 entry->PutPredecessor(entry->Get(PREV_ID)); 88 entry->PutPredecessor(entry->GetPredecessorId());
89 } 89 }
90 } 90 }
91 91
92 // Function to handle runtime failures on syncable code. Rather than crashing, 92 // Function to handle runtime failures on syncable code. Rather than crashing,
93 // if the |condition| is false the following will happen: 93 // if the |condition| is false the following will happen:
94 // 1. Sets unrecoverable error on transaction. 94 // 1. Sets unrecoverable error on transaction.
95 // 2. Returns false. 95 // 2. Returns false.
96 bool SyncAssert(bool condition, 96 bool SyncAssert(bool condition,
97 const tracked_objects::Location& location, 97 const tracked_objects::Location& location,
98 const char* msg, 98 const char* msg,
(...skipping 15 matching lines...) Expand all
114 serialized_type.AppendToString(&hash_input); 114 serialized_type.AppendToString(&hash_input);
115 hash_input.append(client_tag); 115 hash_input.append(client_tag);
116 116
117 std::string encode_output; 117 std::string encode_output;
118 CHECK(base::Base64Encode(base::SHA1HashString(hash_input), &encode_output)); 118 CHECK(base::Base64Encode(base::SHA1HashString(hash_input), &encode_output));
119 return encode_output; 119 return encode_output;
120 } 120 }
121 121
122 } // namespace syncable 122 } // namespace syncable
123 } // namespace syncer 123 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/nigori_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698