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

Side by Side Diff: blimp/helium/version_vector.cc

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/syncable_unittest.cc ('k') | blimp/net/BUILD.gn » ('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 #include "blimp/helium/version_vector.h" 5 #include "blimp/helium/version_vector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace blimp { 11 namespace blimp {
12 namespace helium { 12 namespace helium {
13 13
14 VersionVector::VersionVector() {} 14 VersionVector::VersionVector() {}
15 15
16 VersionVector::VersionVector(Revision local_revision, Revision remote_revision) 16 VersionVector::VersionVector(Revision local_revision, Revision remote_revision)
17 : local_revision_(local_revision), remote_revision_(remote_revision) {} 17 : local_revision_(local_revision), remote_revision_(remote_revision) {}
18 18
19 VersionVector::Comparison VersionVector::CompareTo( 19 VersionVector::Comparison VersionVector::CompareTo(
20 const VersionVector& other) const { 20 const VersionVector& other) const {
21 DCHECK(local_revision_ >= other.local_revision()); 21 DCHECK_GE(local_revision_, other.local_revision());
22 22
23 if (local_revision_ == other.local_revision()) { 23 if (local_revision_ == other.local_revision()) {
24 if (remote_revision_ == other.remote_revision()) { 24 if (remote_revision_ == other.remote_revision()) {
25 return VersionVector::Comparison::EqualTo; 25 return VersionVector::Comparison::EqualTo;
26 } else if (remote_revision_ < other.remote_revision()) { 26 } else if (remote_revision_ < other.remote_revision()) {
27 return VersionVector::Comparison::LessThan; 27 return VersionVector::Comparison::LessThan;
28 } else { 28 } else {
29 return VersionVector::Comparison::GreaterThan; 29 return VersionVector::Comparison::GreaterThan;
30 } 30 }
31 } else { 31 } else {
(...skipping 30 matching lines...) Expand all
62 result.set_remote_revision(remote_revision_); 62 result.set_remote_revision(remote_revision_);
63 return result; 63 return result;
64 } 64 }
65 65
66 VersionVector VersionVector::Invert() const { 66 VersionVector VersionVector::Invert() const {
67 return VersionVector(remote_revision_, local_revision_); 67 return VersionVector(remote_revision_, local_revision_);
68 } 68 }
69 69
70 } // namespace helium 70 } // namespace helium
71 } // namespace blimp 71 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/helium/syncable_unittest.cc ('k') | blimp/net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698