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

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

Issue 2827014: Implemented initial version of server-issued notification client. (Closed)
Patch Set: Added DEPS Created 10 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/notifier/invalidation_util.h"
6
7 #include <sstream>
8
9 namespace sync_notifier {
10
11 void RunAndDeleteClosure(invalidation::Closure* task) {
12 task->Run();
13 delete task;
14 }
15
16 // We need to write our own protobuf to string functions because we
17 // use LITE_RUNTIME, which doesn't support DebugString().
18
19 std::string ObjectIdToString(
20 const invalidation::ObjectId& object_id) {
21 std::stringstream ss;
22 ss << "{ ";
23 ss << "name: " << object_id.name().string_value() << ", ";
24 ss << "source: " << object_id.source();
25 ss << " }";
26 return ss.str();
27 }
28
29 std::string StatusToString(
30 const invalidation::Status& status) {
31 std::stringstream ss;
32 ss << "{ ";
33 ss << "code: " << status.code() << ", ";
34 ss << "description: " << status.description();
35 ss << " }";
36 return ss.str();
37 }
38
39 std::string InvalidationToString(
40 const invalidation::Invalidation& invalidation) {
41 std::stringstream ss;
42 ss << "{ ";
43 ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", ";
44 ss << "version: " << invalidation.version() << ", ";
45 ss << "components: { ";
46 const invalidation::ComponentStampLog& component_stamp_log =
47 invalidation.component_stamp_log();
48 for (int i = 0; i < component_stamp_log.stamps_size(); ++i) {
49 const invalidation::ComponentStamp& component_stamp =
50 component_stamp_log.stamps(i);
51 ss << "component: " << component_stamp.component() << ", ";
52 ss << "time: " << component_stamp.time() << ", ";
53 }
54 ss << " }";
55 ss << " }";
56 return ss.str();
57 }
58
59 std::string RegistrationUpdateToString(
60 const invalidation::RegistrationUpdate& update) {
61 std::stringstream ss;
62 ss << "{ ";
63 ss << "type: " << update.type() << ", ";
64 ss << "object_id: " << ObjectIdToString(update.object_id()) << ", ";
65 ss << "version: " << update.version() << ", ";
66 ss << "sequence_number: " << update.sequence_number();
67 ss << " }";
68 return ss.str();
69 }
70
71 std::string RegistrationUpdateResultToString(
72 const invalidation::RegistrationUpdateResult& update_result) {
73 std::stringstream ss;
74 ss << "{ ";
75 ss << "operation: "
76 << RegistrationUpdateToString(update_result.operation()) << ", ";
77 ss << "status: " << StatusToString(update_result.status());
78 ss << " }";
79 return ss.str();
80 }
81
82 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/invalidation_util.h ('k') | chrome/browser/sync/notifier/server_notifier_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698