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

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

Issue 2861034: Decomped registration logic into its own class. (Closed)
Patch Set: synced to head Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 6
7 #include <sstream> 7 #include <sstream>
8 8
9 namespace sync_notifier { 9 namespace sync_notifier {
10 10
11 void RunAndDeleteClosure(invalidation::Closure* task) { 11 void RunAndDeleteClosure(invalidation::Closure* task) {
12 task->Run(); 12 task->Run();
13 delete task; 13 delete task;
14 } 14 }
15 15
16 // We need to write our own protobuf to string functions because we 16 bool RealModelTypeToObjectId(syncable::ModelType model_type,
17 // use LITE_RUNTIME, which doesn't support DebugString(). 17 invalidation::ObjectId* object_id) {
18 std::string notification_type;
19 if (!syncable::RealModelTypeToNotificationType(
20 model_type, &notification_type)) {
21 return false;
22 }
23 object_id->mutable_name()->set_string_value(notification_type);
24 object_id->set_source(invalidation::ObjectId::CHROME_SYNC);
25 return true;
26 }
27
28 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id,
29 syncable::ModelType* model_type) {
30 return
31 syncable::NotificationTypeToRealModelType(
32 object_id.name().string_value(), model_type);
33 }
18 34
19 std::string ObjectIdToString( 35 std::string ObjectIdToString(
20 const invalidation::ObjectId& object_id) { 36 const invalidation::ObjectId& object_id) {
21 std::stringstream ss; 37 std::stringstream ss;
22 ss << "{ "; 38 ss << "{ ";
23 ss << "name: " << object_id.name().string_value() << ", "; 39 ss << "name: " << object_id.name().string_value() << ", ";
24 ss << "source: " << object_id.source(); 40 ss << "source: " << object_id.source();
25 ss << " }"; 41 ss << " }";
26 return ss.str(); 42 return ss.str();
27 } 43 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 std::stringstream ss; 89 std::stringstream ss;
74 ss << "{ "; 90 ss << "{ ";
75 ss << "operation: " 91 ss << "operation: "
76 << RegistrationUpdateToString(update_result.operation()) << ", "; 92 << RegistrationUpdateToString(update_result.operation()) << ", ";
77 ss << "status: " << StatusToString(update_result.status()); 93 ss << "status: " << StatusToString(update_result.status());
78 ss << " }"; 94 ss << " }";
79 return ss.str(); 95 return ss.str();
80 } 96 }
81 97
82 } // namespace sync_notifier 98 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/invalidation_util.h ('k') | chrome/browser/sync/notifier/registration_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698