OLD | NEW |
1 // Copyright (c) 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/internal_api/public/base/invalidation.h" | 5 #include "sync/internal_api/public/base/invalidation.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 | 11 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 bool AckHandle::IsValid() const { | 56 bool AckHandle::IsValid() const { |
57 return !state_.empty(); | 57 return !state_.empty(); |
58 } | 58 } |
59 | 59 |
60 AckHandle::AckHandle(const std::string& state, base::Time timestamp) | 60 AckHandle::AckHandle(const std::string& state, base::Time timestamp) |
61 : state_(state), timestamp_(timestamp) { | 61 : state_(state), timestamp_(timestamp) { |
62 } | 62 } |
63 | 63 |
| 64 AckHandle::~AckHandle() { |
| 65 } |
| 66 |
64 Invalidation::Invalidation() | 67 Invalidation::Invalidation() |
65 : ack_handle(AckHandle::InvalidAckHandle()) { | 68 : ack_handle(AckHandle::InvalidAckHandle()) { |
66 } | 69 } |
67 | 70 |
| 71 Invalidation::~Invalidation() { |
| 72 } |
| 73 |
68 bool Invalidation::Equals(const Invalidation& other) const { | 74 bool Invalidation::Equals(const Invalidation& other) const { |
69 return (payload == other.payload) && ack_handle.Equals(other.ack_handle); | 75 return (payload == other.payload) && ack_handle.Equals(other.ack_handle); |
70 } | 76 } |
71 | 77 |
72 scoped_ptr<base::DictionaryValue> Invalidation::ToValue() const { | 78 scoped_ptr<base::DictionaryValue> Invalidation::ToValue() const { |
73 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 79 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
74 value->SetString("payload", payload); | 80 value->SetString("payload", payload); |
75 value->Set("ackHandle", ack_handle.ToValue().release()); | 81 value->Set("ackHandle", ack_handle.ToValue().release()); |
76 return value.Pass(); | 82 return value.Pass(); |
77 } | 83 } |
78 | 84 |
79 bool Invalidation::ResetFromValue(const base::DictionaryValue& value) { | 85 bool Invalidation::ResetFromValue(const base::DictionaryValue& value) { |
80 const DictionaryValue* ack_handle_value = NULL; | 86 const DictionaryValue* ack_handle_value = NULL; |
81 return | 87 return |
82 value.GetString("payload", &payload) && | 88 value.GetString("payload", &payload) && |
83 value.GetDictionary("ackHandle", &ack_handle_value) && | 89 value.GetDictionary("ackHandle", &ack_handle_value) && |
84 ack_handle.ResetFromValue(*ack_handle_value); | 90 ack_handle.ResetFromValue(*ack_handle_value); |
85 } | 91 } |
86 | 92 |
87 } // namespace syncer | 93 } // namespace syncer |
OLD | NEW |