Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(720)

Side by Side Diff: sync/internal_api/public/base/invalidation.cc

Issue 56113003: Implement new invalidations ack tracking system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 const std::string& Invalidation::payload() const { 105 const std::string& Invalidation::payload() const {
106 DCHECK(!is_unknown_version_); 106 DCHECK(!is_unknown_version_);
107 return payload_; 107 return payload_;
108 } 108 }
109 109
110 const AckHandle& Invalidation::ack_handle() const { 110 const AckHandle& Invalidation::ack_handle() const {
111 return ack_handle_; 111 return ack_handle_;
112 } 112 }
113 113
114 void Invalidation::set_ack_handle(const AckHandle& ack_handle) {
115 ack_handle_ = ack_handle;
116 }
117
118 void Invalidation::set_ack_handler(syncer::WeakHandle<AckHandler> handler) { 114 void Invalidation::set_ack_handler(syncer::WeakHandle<AckHandler> handler) {
119 ack_handler_ = handler; 115 ack_handler_ = handler;
tim (not reviewing) 2013/11/20 18:27:04 At the very least, this shouldn't ever change from
rlarocque 2013/11/21 20:09:27 Done.
120 } 116 }
121 117
122 bool Invalidation::SupportsAcknowledgement() const { 118 bool Invalidation::SupportsAcknowledgement() const {
123 return ack_handler_.IsInitialized(); 119 return ack_handler_.IsInitialized();
124 } 120 }
125 121
126 void Invalidation::Acknowledge() const { 122 void Invalidation::Acknowledge() const {
127 if (SupportsAcknowledgement()) { 123 if (SupportsAcknowledgement()) {
128 ack_handler_.Call(FROM_HERE, 124 ack_handler_.Call(FROM_HERE,
129 &AckHandler::Acknowledge, 125 &AckHandler::Acknowledge,
130 id_, 126 id_,
131 ack_handle_); 127 ack_handle_);
132 } 128 }
133 } 129 }
134 130
135 void Invalidation::Drop(DroppedInvalidationTracker* tracker) const { 131 void Invalidation::Drop(DroppedInvalidationTracker* tracker) const {
136 DCHECK(tracker->object_id() == object_id()); 132 DCHECK(tracker->object_id() == object_id());
137 tracker->RecordDropEvent(ack_handler_, ack_handle_); 133 tracker->RecordDropEvent(ack_handler_, ack_handle_);
138 ack_handler_.Call(FROM_HERE, 134 if (SupportsAcknowledgement()) {
139 &AckHandler::Drop, 135 ack_handler_.Call(FROM_HERE,
140 id_, 136 &AckHandler::Drop,
141 ack_handle_); 137 id_,
138 ack_handle_);
139 }
142 } 140 }
143 141
144 bool Invalidation::Equals(const Invalidation& other) const { 142 bool Invalidation::Equals(const Invalidation& other) const {
145 return id_ == other.id_ 143 return id_ == other.id_
146 && is_unknown_version_ == other.is_unknown_version_ 144 && is_unknown_version_ == other.is_unknown_version_
147 && version_ == other.version_ 145 && version_ == other.version_
148 && payload_ == other.payload_; 146 && payload_ == other.payload_;
149 } 147 }
150 148
151 scoped_ptr<base::DictionaryValue> Invalidation::ToValue() const { 149 scoped_ptr<base::DictionaryValue> Invalidation::ToValue() const {
(...skipping 23 matching lines...) Expand all
175 int64 version, 173 int64 version,
176 const std::string& payload, 174 const std::string& payload,
177 AckHandle ack_handle) 175 AckHandle ack_handle)
178 : id_(id), 176 : id_(id),
179 is_unknown_version_(is_unknown_version), 177 is_unknown_version_(is_unknown_version),
180 version_(version), 178 version_(version),
181 payload_(payload), 179 payload_(payload),
182 ack_handle_(ack_handle) {} 180 ack_handle_(ack_handle) {}
183 181
184 } // namespace syncer 182 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698