| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/notifier/invalidation_util.h" | 5 #include "chrome/browser/sync/notifier/invalidation_util.h" |
| 6 #include "google/cacheinvalidation/v2/types.h" | 6 #include "google/cacheinvalidation/v2/types.h" |
| 7 | 7 |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 namespace sync_notifier { | 10 namespace sync_notifier { |
| 11 | 11 |
| 12 void RunAndDeleteClosure(invalidation::Closure* task) { | 12 void RunAndDeleteClosure(invalidation::Closure* task) { |
| 13 task->Run(); | 13 task->Run(); |
| 14 delete task; | 14 delete task; |
| 15 } | 15 } |
| 16 | 16 |
| 17 bool RealModelTypeToObjectId(syncable::ModelType model_type, | 17 bool RealModelTypeToObjectId(syncable::ModelType model_type, |
| 18 invalidation::ObjectId* object_id) { | 18 invalidation::ObjectId* object_id) { |
| 19 std::string notification_type; | 19 std::string notification_type; |
| 20 if (!syncable::RealModelTypeToNotificationType( | 20 if (!syncable::RealModelTypeToint( |
| 21 model_type, ¬ification_type)) { | 21 model_type, ¬ification_type)) { |
| 22 return false; | 22 return false; |
| 23 } | 23 } |
| 24 object_id->Init(ipc::invalidation::ObjectSource::CHROME_SYNC, | 24 object_id->Init(ipc::invalidation::ObjectSource::CHROME_SYNC, |
| 25 notification_type); | 25 notification_type); |
| 26 return true; | 26 return true; |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id, | 29 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id, |
| 30 syncable::ModelType* model_type) { | 30 syncable::ModelType* model_type) { |
| 31 return | 31 return |
| 32 syncable::NotificationTypeToRealModelType( | 32 syncable::intToRealModelType( |
| 33 object_id.name(), model_type); | 33 object_id.name(), model_type); |
| 34 } | 34 } |
| 35 | 35 |
| 36 std::string ObjectIdToString( | 36 std::string ObjectIdToString( |
| 37 const invalidation::ObjectId& object_id) { | 37 const invalidation::ObjectId& object_id) { |
| 38 std::stringstream ss; | 38 std::stringstream ss; |
| 39 ss << "{ "; | 39 ss << "{ "; |
| 40 ss << "name: " << object_id.name() << ", "; | 40 ss << "name: " << object_id.name() << ", "; |
| 41 ss << "source: " << object_id.source(); | 41 ss << "source: " << object_id.source(); |
| 42 ss << " }"; | 42 ss << " }"; |
| 43 return ss.str(); | 43 return ss.str(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 std::string InvalidationToString( | 46 std::string InvalidationToString( |
| 47 const invalidation::Invalidation& invalidation) { | 47 const invalidation::Invalidation& invalidation) { |
| 48 std::stringstream ss; | 48 std::stringstream ss; |
| 49 ss << "{ "; | 49 ss << "{ "; |
| 50 ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", "; | 50 ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", "; |
| 51 ss << "version: " << invalidation.version(); | 51 ss << "version: " << invalidation.version(); |
| 52 ss << " }"; | 52 ss << " }"; |
| 53 return ss.str(); | 53 return ss.str(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace sync_notifier | 56 } // namespace sync_notifier |
| OLD | NEW |