OLD | NEW |
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 Loading... |
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 |
OLD | NEW |