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

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

Issue 10702074: Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor cleanup Created 8 years, 5 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
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 <sstream> 7 #include <sstream>
8 8
9 #include "google/cacheinvalidation/include/types.h" 9 #include "google/cacheinvalidation/include/types.h"
10 #include "google/cacheinvalidation/v2/types.pb.h" 10 #include "google/cacheinvalidation/v2/types.pb.h"
(...skipping 18 matching lines...) Expand all
29 return true; 29 return true;
30 } 30 }
31 31
32 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id, 32 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id,
33 syncer::ModelType* model_type) { 33 syncer::ModelType* model_type) {
34 return 34 return
35 syncer::NotificationTypeToRealModelType( 35 syncer::NotificationTypeToRealModelType(
36 object_id.name(), model_type); 36 object_id.name(), model_type);
37 } 37 }
38 38
39 ObjectIdSet ModelTypeSetToObjectIdSet(const ModelTypeSet& model_types) {
40 ObjectIdSet ids;
41 for (ModelTypeSet::Iterator iter = model_types.First(); iter.Good();
42 iter.Inc()) {
43 invalidation::ObjectId model_type_as_id;
44 if (!RealModelTypeToObjectId(iter.Get(), &model_type_as_id)) {
45 DLOG(WARNING) << "Invalid model type " << iter.Get();
46 continue;
47 }
48 ids.insert(model_type_as_id);
49 }
50 return ids;
51 }
52
53 ModelTypeSet ObjectIdSetToModelTypeSet(const ObjectIdSet& ids) {
54 ModelTypeSet model_types;
55 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
56 ModelType model_type;
57 if (!ObjectIdToRealModelType(*it, &model_type)) {
58 DLOG(WARNING) << "Invalid object ID " << ObjectIdToString(*it);
59 continue;
60 }
61 model_types.Put(model_type);
62 }
63 return model_types;
64 }
65
39 std::string ObjectIdToString( 66 std::string ObjectIdToString(
40 const invalidation::ObjectId& object_id) { 67 const invalidation::ObjectId& object_id) {
41 std::stringstream ss; 68 std::stringstream ss;
42 ss << "{ "; 69 ss << "{ ";
43 ss << "name: " << object_id.name() << ", "; 70 ss << "name: " << object_id.name() << ", ";
44 ss << "source: " << object_id.source(); 71 ss << "source: " << object_id.source();
45 ss << " }"; 72 ss << " }";
46 return ss.str(); 73 return ss.str();
47 } 74 }
48 75
49 std::string InvalidationToString( 76 std::string InvalidationToString(
50 const invalidation::Invalidation& invalidation) { 77 const invalidation::Invalidation& invalidation) {
51 std::stringstream ss; 78 std::stringstream ss;
52 ss << "{ "; 79 ss << "{ ";
53 ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", "; 80 ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", ";
54 ss << "version: " << invalidation.version(); 81 ss << "version: " << invalidation.version();
55 ss << " }"; 82 ss << " }";
56 return ss.str(); 83 return ss.str();
57 } 84 }
58 85
59 } // namespace syncer 86 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698