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

Side by Side Diff: blimp/helium/lww_register.h

Issue 2402153002: Add CompoundSyncable class for synchronizing containers of Syncables. (Closed)
Patch Set: make literal unsigned Created 4 years, 2 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 | « blimp/helium/helium_test.h ('k') | blimp/helium/lww_register_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef BLIMP_HELIUM_LWW_REGISTER_H_ 5 #ifndef BLIMP_HELIUM_LWW_REGISTER_H_
6 #define BLIMP_HELIUM_LWW_REGISTER_H_ 6 #define BLIMP_HELIUM_LWW_REGISTER_H_
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "blimp/helium/blimp_helium_export.h" 9 #include "blimp/helium/blimp_helium_export.h"
10 #include "blimp/helium/coded_value_serializer.h" 10 #include "blimp/helium/coded_value_serializer.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 CodedValueSerializer::Serialize(last_modified_, output_stream); 79 CodedValueSerializer::Serialize(last_modified_, output_stream);
80 CodedValueSerializer::Serialize(value_, output_stream); 80 CodedValueSerializer::Serialize(value_, output_stream);
81 } 81 }
82 82
83 template <class RegisterType> 83 template <class RegisterType>
84 Result LwwRegister<RegisterType>::ApplyChangeset( 84 Result LwwRegister<RegisterType>::ApplyChangeset(
85 Revision to, 85 Revision to,
86 google::protobuf::io::CodedInputStream* input_stream) { 86 google::protobuf::io::CodedInputStream* input_stream) {
87 VersionVector remote; 87 VersionVector remote;
88 if (!CodedValueSerializer::Deserialize(input_stream, &remote)) { 88 if (!CodedValueSerializer::Deserialize(input_stream, &remote)) {
89 return Result::ERR_INTERNAL_ERROR; 89 return Result::ERR_PROTOCOL_ERROR;
90 } 90 }
91 remote = remote.Invert(); 91 remote = remote.Invert();
92 VersionVector::Comparison cmp = last_modified_.CompareTo(remote); 92 VersionVector::Comparison cmp = last_modified_.CompareTo(remote);
93
94 RegisterType input_value;
95 if (!CodedValueSerializer::Deserialize(input_stream, &input_value)) {
96 return Result::ERR_PROTOCOL_ERROR;
97 }
93 if (cmp == VersionVector::Comparison::LessThan || 98 if (cmp == VersionVector::Comparison::LessThan ||
94 (cmp == VersionVector::Comparison::Conflict && !locally_owned_)) { 99 (cmp == VersionVector::Comparison::Conflict && !locally_owned_)) {
95 if (!CodedValueSerializer::Deserialize(input_stream, &value_)) { 100 value_ = input_value;
96 return Result::ERR_INTERNAL_ERROR;
97 }
98 value_set_ = true; 101 value_set_ = true;
99 } 102 }
103
100 last_modified_ = last_modified_.MergeWith(remote); 104 last_modified_ = last_modified_.MergeWith(remote);
101 return Result::SUCCESS; 105 return Result::SUCCESS;
102 } 106 }
103 107
104 template <class RegisterType> 108 template <class RegisterType>
105 void LwwRegister<RegisterType>::ReleaseBefore(Revision checkpoint) { 109 void LwwRegister<RegisterType>::ReleaseBefore(Revision checkpoint) {
106 // no-op 110 // no-op
107 } 111 }
108 112
109 } // namespace helium 113 } // namespace helium
110 } // namespace blimp 114 } // namespace blimp
111 115
112 #endif // BLIMP_HELIUM_LWW_REGISTER_H_ 116 #endif // BLIMP_HELIUM_LWW_REGISTER_H_
OLDNEW
« no previous file with comments | « blimp/helium/helium_test.h ('k') | blimp/helium/lww_register_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698