| OLD | NEW |
| 1 // Copyright 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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 AckHandle AckHandle::InvalidAckHandle() { | 27 AckHandle AckHandle::InvalidAckHandle() { |
| 28 return AckHandle(std::string(), base::Time()); | 28 return AckHandle(std::string(), base::Time()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 bool AckHandle::Equals(const AckHandle& other) const { | 31 bool AckHandle::Equals(const AckHandle& other) const { |
| 32 return state_ == other.state_ && timestamp_ == other.timestamp_; | 32 return state_ == other.state_ && timestamp_ == other.timestamp_; |
| 33 } | 33 } |
| 34 | 34 |
| 35 scoped_ptr<base::DictionaryValue> AckHandle::ToValue() const { | 35 scoped_ptr<base::DictionaryValue> AckHandle::ToValue() const { |
| 36 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 36 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 37 value->SetString("state", state_); | 37 value->SetString("state", state_); |
| 38 value->SetString("timestamp", | 38 value->SetString("timestamp", |
| 39 base::Int64ToString(timestamp_.ToInternalValue())); | 39 base::Int64ToString(timestamp_.ToInternalValue())); |
| 40 return value.Pass(); | 40 return value.Pass(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool AckHandle::ResetFromValue(const base::DictionaryValue& value) { | 43 bool AckHandle::ResetFromValue(const base::DictionaryValue& value) { |
| 44 if (!value.GetString("state", &state_)) | 44 if (!value.GetString("state", &state_)) |
| 45 return false; | 45 return false; |
| 46 std::string timestamp_as_string; | 46 std::string timestamp_as_string; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 Invalidation::~Invalidation() { | 71 Invalidation::~Invalidation() { |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool Invalidation::Equals(const Invalidation& other) const { | 74 bool Invalidation::Equals(const Invalidation& other) const { |
| 75 return (payload == other.payload) && ack_handle.Equals(other.ack_handle); | 75 return (payload == other.payload) && ack_handle.Equals(other.ack_handle); |
| 76 } | 76 } |
| 77 | 77 |
| 78 scoped_ptr<base::DictionaryValue> Invalidation::ToValue() const { | 78 scoped_ptr<base::DictionaryValue> Invalidation::ToValue() const { |
| 79 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 79 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 80 value->SetString("payload", payload); | 80 value->SetString("payload", payload); |
| 81 value->Set("ackHandle", ack_handle.ToValue().release()); | 81 value->Set("ackHandle", ack_handle.ToValue().release()); |
| 82 return value.Pass(); | 82 return value.Pass(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool Invalidation::ResetFromValue(const base::DictionaryValue& value) { | 85 bool Invalidation::ResetFromValue(const base::DictionaryValue& value) { |
| 86 const DictionaryValue* ack_handle_value = NULL; | 86 const base::DictionaryValue* ack_handle_value = NULL; |
| 87 return | 87 return |
| 88 value.GetString("payload", &payload) && | 88 value.GetString("payload", &payload) && |
| 89 value.GetDictionary("ackHandle", &ack_handle_value) && | 89 value.GetDictionary("ackHandle", &ack_handle_value) && |
| 90 ack_handle.ResetFromValue(*ack_handle_value); | 90 ack_handle.ResetFromValue(*ack_handle_value); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace syncer | 93 } // namespace syncer |
| OLD | NEW |