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

Side by Side Diff: sync/notifier/invalidation_util.cc

Issue 23754021: Invalidation trickles mega-patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months 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
« no previous file with comments | « sync/notifier/invalidation_util.h ('k') | sync/notifier/invalidator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/notifier/invalidation_util.h" 5 #include "sync/notifier/invalidation_util.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "google/cacheinvalidation/include/types.h" 13 #include "google/cacheinvalidation/include/types.h"
14 #include "google/cacheinvalidation/types.pb.h" 14 #include "google/cacheinvalidation/types.pb.h"
15 15
16 namespace invalidation { 16 namespace invalidation {
17 void PrintTo(const invalidation::ObjectId& id, std::ostream* os) { 17 void PrintTo(const invalidation::ObjectId& id, std::ostream* os) {
18 *os << syncer::ObjectIdToString(id); 18 *os << syncer::ObjectIdToString(id);
19 } 19 }
20 } // namespace invalidation 20 } // namespace invalidation
21 21
22 namespace syncer { 22 namespace syncer {
23 23
24 bool ObjectIdLessThan::operator()(const invalidation::ObjectId& lhs, 24 bool ObjectIdLessThan::operator()(const invalidation::ObjectId& lhs,
25 const invalidation::ObjectId& rhs) const { 25 const invalidation::ObjectId& rhs) const {
26 return (lhs.source() < rhs.source()) || 26 return (lhs.source() < rhs.source()) ||
27 (lhs.source() == rhs.source() && lhs.name() < rhs.name()); 27 (lhs.source() == rhs.source() && lhs.name() < rhs.name());
28 } 28 }
29 29
30 bool InvalidationVersionLessThan::operator()(
31 const syncer::Invalidation& a,
32 const syncer::Invalidation& b) const {
33 DCHECK(a.GetObjectId() == b.GetObjectId())
34 << "a: " << ObjectIdToString(a.GetObjectId()) << ", "
35 << "b: " << ObjectIdToString(a.GetObjectId());
36
37 if (a.IsUnknownVersion() && !b.IsUnknownVersion())
38 return true;
39
40 if (!a.IsUnknownVersion() && b.IsUnknownVersion())
41 return false;
42
43 if (a.IsUnknownVersion() && b.IsUnknownVersion())
44 return false;
45
46 return a.GetVersion() < b.GetVersion();
47 }
48
30 bool RealModelTypeToObjectId(ModelType model_type, 49 bool RealModelTypeToObjectId(ModelType model_type,
31 invalidation::ObjectId* object_id) { 50 invalidation::ObjectId* object_id) {
32 std::string notification_type; 51 std::string notification_type;
33 if (!RealModelTypeToNotificationType(model_type, &notification_type)) { 52 if (!RealModelTypeToNotificationType(model_type, &notification_type)) {
34 return false; 53 return false;
35 } 54 }
36 object_id->Init(ipc::invalidation::ObjectSource::CHROME_SYNC, 55 object_id->Init(ipc::invalidation::ObjectSource::CHROME_SYNC,
37 notification_type); 56 notification_type);
38 return true; 57 return true;
39 } 58 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const invalidation::Invalidation& invalidation) { 121 const invalidation::Invalidation& invalidation) {
103 std::stringstream ss; 122 std::stringstream ss;
104 ss << "{ "; 123 ss << "{ ";
105 ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", "; 124 ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", ";
106 ss << "version: " << invalidation.version(); 125 ss << "version: " << invalidation.version();
107 ss << " }"; 126 ss << " }";
108 return ss.str(); 127 return ss.str();
109 } 128 }
110 129
111 } // namespace syncer 130 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/invalidation_util.h ('k') | sync/notifier/invalidator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698