| 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" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "sync/notifier/ack_handler.h" |
| 14 #include "sync/notifier/dropped_invalidation_tracker.h" |
| 13 #include "sync/notifier/invalidation_util.h" | 15 #include "sync/notifier/invalidation_util.h" |
| 14 | 16 |
| 15 namespace syncer { | 17 namespace syncer { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 const char kObjectIdKey[] = "objectId"; | 20 const char kObjectIdKey[] = "objectId"; |
| 19 const char kIsUnknownVersionKey[] = "isUnknownVersion"; | 21 const char kIsUnknownVersionKey[] = "isUnknownVersion"; |
| 20 const char kVersionKey[] = "version"; | 22 const char kVersionKey[] = "version"; |
| 21 const char kPayloadKey[] = "payload"; | 23 const char kPayloadKey[] = "payload"; |
| 22 const int64 kInvalidVersion = -1; | 24 const int64 kInvalidVersion = -1; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 116 } |
| 115 | 117 |
| 116 void Invalidation::set_ack_handler(syncer::WeakHandle<AckHandler> handler) { | 118 void Invalidation::set_ack_handler(syncer::WeakHandle<AckHandler> handler) { |
| 117 ack_handler_ = handler; | 119 ack_handler_ = handler; |
| 118 } | 120 } |
| 119 | 121 |
| 120 bool Invalidation::SupportsAcknowledgement() const { | 122 bool Invalidation::SupportsAcknowledgement() const { |
| 121 return ack_handler_.IsInitialized(); | 123 return ack_handler_.IsInitialized(); |
| 122 } | 124 } |
| 123 | 125 |
| 124 // void Invalidation::Acknowledge() const { | 126 void Invalidation::Acknowledge() const { |
| 125 // if (SupportsAcknowledgement()) { | 127 if (SupportsAcknowledgement()) { |
| 126 // ack_handler_.Call(FROM_HERE, | 128 ack_handler_.Call(FROM_HERE, |
| 127 // &AckHandler::Acknowledge, | 129 &AckHandler::Acknowledge, |
| 128 // id_, | 130 id_, |
| 129 // ack_handle_); | 131 ack_handle_); |
| 130 // } | 132 } |
| 131 // } | 133 } |
| 132 | 134 |
| 133 // void Invalidation::Drop(DroppedInvalidationTracker* tracker) const { | 135 void Invalidation::Drop(DroppedInvalidationTracker* tracker) const { |
| 134 // DCHECK(tracker->object_id() == object_id()); | 136 DCHECK(tracker->object_id() == object_id()); |
| 135 // tracker->Drop(ack_handler_, ack_handle_); | 137 tracker->RecordDropEvent(ack_handler_, ack_handle_); |
| 136 // } | 138 ack_handler_.Call(FROM_HERE, |
| 139 &AckHandler::Drop, |
| 140 id_, |
| 141 ack_handle_); |
| 142 } |
| 137 | 143 |
| 138 bool Invalidation::Equals(const Invalidation& other) const { | 144 bool Invalidation::Equals(const Invalidation& other) const { |
| 139 return id_ == other.id_ | 145 return id_ == other.id_ |
| 140 && is_unknown_version_ == other.is_unknown_version_ | 146 && is_unknown_version_ == other.is_unknown_version_ |
| 141 && version_ == other.version_ | 147 && version_ == other.version_ |
| 142 && payload_ == other.payload_; | 148 && payload_ == other.payload_; |
| 143 } | 149 } |
| 144 | 150 |
| 145 scoped_ptr<base::DictionaryValue> Invalidation::ToValue() const { | 151 scoped_ptr<base::DictionaryValue> Invalidation::ToValue() const { |
| 146 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 152 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 169 int64 version, | 175 int64 version, |
| 170 const std::string& payload, | 176 const std::string& payload, |
| 171 AckHandle ack_handle) | 177 AckHandle ack_handle) |
| 172 : id_(id), | 178 : id_(id), |
| 173 is_unknown_version_(is_unknown_version), | 179 is_unknown_version_(is_unknown_version), |
| 174 version_(version), | 180 version_(version), |
| 175 payload_(payload), | 181 payload_(payload), |
| 176 ack_handle_(ack_handle) {} | 182 ack_handle_(ack_handle) {} |
| 177 | 183 |
| 178 } // namespace syncer | 184 } // namespace syncer |
| OLD | NEW |