roll skia to 4057
[chromium-blink-merge.git] / sync / notifier / invalidation_util.cc
blob126e56f5622de0a9d1e7f03309c7fa752dca481e
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
3 // found in the LICENSE file.
5 #include "sync/notifier/invalidation_util.h"
7 #include <sstream>
9 #include "google/cacheinvalidation/include/types.h"
10 #include "google/cacheinvalidation/v2/types.pb.h"
12 namespace sync_notifier {
14 void RunAndDeleteClosure(invalidation::Closure* task) {
15 task->Run();
16 delete task;
19 bool RealModelTypeToObjectId(syncable::ModelType model_type,
20 invalidation::ObjectId* object_id) {
21 std::string notification_type;
22 if (!syncable::RealModelTypeToNotificationType(
23 model_type, &notification_type)) {
24 return false;
26 object_id->Init(ipc::invalidation::ObjectSource::CHROME_SYNC,
27 notification_type);
28 return true;
31 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id,
32 syncable::ModelType* model_type) {
33 return
34 syncable::NotificationTypeToRealModelType(
35 object_id.name(), model_type);
38 std::string ObjectIdToString(
39 const invalidation::ObjectId& object_id) {
40 std::stringstream ss;
41 ss << "{ ";
42 ss << "name: " << object_id.name() << ", ";
43 ss << "source: " << object_id.source();
44 ss << " }";
45 return ss.str();
48 std::string InvalidationToString(
49 const invalidation::Invalidation& invalidation) {
50 std::stringstream ss;
51 ss << "{ ";
52 ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", ";
53 ss << "version: " << invalidation.version();
54 ss << " }";
55 return ss.str();
58 } // namespace sync_notifier