Chromium Code Reviews| 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/net/helium/vector_clock.h" | 5 #include "blimp/net/helium/vector_clock.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 VectorClock VectorClock::MergeWith(const VectorClock& other) const { | 47 VectorClock VectorClock::MergeWith(const VectorClock& other) const { |
| 48 VectorClock result(std::max(local_revision_, other.local_revision()), | 48 VectorClock result(std::max(local_revision_, other.local_revision()), |
| 49 std::max(remote_revision_, other.remote_revision())); | 49 std::max(remote_revision_, other.remote_revision())); |
| 50 return result; | 50 return result; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void VectorClock::IncrementLocal() { | 53 void VectorClock::IncrementLocal() { |
| 54 local_revision_++; | 54 local_revision_++; |
| 55 } | 55 } |
| 56 | 56 |
| 57 proto::VectorClockMessage VectorClock::ToProto() const { | |
| 58 proto::VectorClockMessage result; | |
| 59 result.set_local_revision(local_revision_); | |
| 60 result.set_remote_revision(remote_revision_); | |
| 61 return result; | |
| 62 } | |
| 63 | |
| 64 VectorClock VectorClock::Invert() const { | |
| 65 VectorClock result; | |
|
steimel
2016/10/06 17:44:33
Would it make more sense to use the other construc
scf
2016/10/06 19:47:17
good catch
| |
| 66 result.set_local_revision(remote_revision_); | |
| 67 result.set_remote_revision(local_revision_); | |
| 68 return result; | |
| 69 } | |
| 70 | |
| 57 } // namespace blimp | 71 } // namespace blimp |
| OLD | NEW |