| 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 | 8 |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 DLOG(WARNING) << "Failed to parse is_unknown_version flag"; | 66 DLOG(WARNING) << "Failed to parse is_unknown_version flag"; |
| 67 return scoped_ptr<Invalidation>(); | 67 return scoped_ptr<Invalidation>(); |
| 68 } | 68 } |
| 69 if (is_unknown_version) { | 69 if (is_unknown_version) { |
| 70 return scoped_ptr<Invalidation>(new Invalidation( | 70 return scoped_ptr<Invalidation>(new Invalidation( |
| 71 id, | 71 id, |
| 72 true, | 72 true, |
| 73 kInvalidVersion, | 73 kInvalidVersion, |
| 74 std::string(), | 74 std::string(), |
| 75 AckHandle::CreateUnique())); | 75 AckHandle::CreateUnique())); |
| 76 } else { | |
| 77 int64 version; | |
| 78 std::string version_as_string; | |
| 79 if (!value.GetString(kVersionKey, &version_as_string) | |
| 80 || !base::StringToInt64(version_as_string, &version)) { | |
| 81 DLOG(WARNING) << "Failed to parse version"; | |
| 82 return scoped_ptr<Invalidation>(); | |
| 83 } | |
| 84 std::string payload; | |
| 85 if (!value.GetString(kPayloadKey, &payload)) { | |
| 86 DLOG(WARNING) << "Failed to parse payload"; | |
| 87 return scoped_ptr<Invalidation>(); | |
| 88 } | |
| 89 return scoped_ptr<Invalidation>(new Invalidation( | |
| 90 id, | |
| 91 false, | |
| 92 version, | |
| 93 payload, | |
| 94 AckHandle::CreateUnique())); | |
| 95 } | 76 } |
| 77 int64 version = 0; |
| 78 std::string version_as_string; |
| 79 if (!value.GetString(kVersionKey, &version_as_string) |
| 80 || !base::StringToInt64(version_as_string, &version)) { |
| 81 DLOG(WARNING) << "Failed to parse version"; |
| 82 return scoped_ptr<Invalidation>(); |
| 83 } |
| 84 std::string payload; |
| 85 if (!value.GetString(kPayloadKey, &payload)) { |
| 86 DLOG(WARNING) << "Failed to parse payload"; |
| 87 return scoped_ptr<Invalidation>(); |
| 88 } |
| 89 return scoped_ptr<Invalidation>(new Invalidation( |
| 90 id, |
| 91 false, |
| 92 version, |
| 93 payload, |
| 94 AckHandle::CreateUnique())); |
| 96 } | 95 } |
| 97 | 96 |
| 98 Invalidation::~Invalidation() {} | 97 Invalidation::~Invalidation() {} |
| 99 | 98 |
| 100 invalidation::ObjectId Invalidation::object_id() const { | 99 invalidation::ObjectId Invalidation::object_id() const { |
| 101 return id_; | 100 return id_; |
| 102 } | 101 } |
| 103 | 102 |
| 104 bool Invalidation::is_unknown_version() const { | 103 bool Invalidation::is_unknown_version() const { |
| 105 return is_unknown_version_; | 104 return is_unknown_version_; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 int64 version, | 178 int64 version, |
| 180 const std::string& payload, | 179 const std::string& payload, |
| 181 AckHandle ack_handle) | 180 AckHandle ack_handle) |
| 182 : id_(id), | 181 : id_(id), |
| 183 is_unknown_version_(is_unknown_version), | 182 is_unknown_version_(is_unknown_version), |
| 184 version_(version), | 183 version_(version), |
| 185 payload_(payload), | 184 payload_(payload), |
| 186 ack_handle_(ack_handle) {} | 185 ack_handle_(ack_handle) {} |
| 187 | 186 |
| 188 } // namespace syncer | 187 } // namespace syncer |
| OLD | NEW |