summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/notifier/invalidation_util.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-23 01:13:56 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-23 01:13:56 +0000
commit8516471942ded5ca17efd0681f1ae12ac86f3617 (patch)
tree2c2cfb3d1891c638dff5b62d3c68e916814237a7 /chrome/browser/sync/notifier/invalidation_util.cc
parent11fb5e5771fb2d148e6c8d7245f28642a749a722 (diff)
downloadchromium_src-8516471942ded5ca17efd0681f1ae12ac86f3617.zip
chromium_src-8516471942ded5ca17efd0681f1ae12ac86f3617.tar.gz
chromium_src-8516471942ded5ca17efd0681f1ae12ac86f3617.tar.bz2
Implemented initial version of server-issued notification client.
Added NOTIFICATION_SERVER notification method (use --sync-notification-method=server to turn on). BUG=34647 TEST=manually Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=50479 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=50550 Review URL: http://codereview.chromium.org/2827014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/notifier/invalidation_util.cc')
-rw-r--r--chrome/browser/sync/notifier/invalidation_util.cc82
1 files changed, 82 insertions, 0 deletions
diff --git a/chrome/browser/sync/notifier/invalidation_util.cc b/chrome/browser/sync/notifier/invalidation_util.cc
new file mode 100644
index 0000000..2683fae
--- /dev/null
+++ b/chrome/browser/sync/notifier/invalidation_util.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/notifier/invalidation_util.h"
+
+#include <sstream>
+
+namespace sync_notifier {
+
+void RunAndDeleteClosure(invalidation::Closure* task) {
+ task->Run();
+ delete task;
+}
+
+// We need to write our own protobuf to string functions because we
+// use LITE_RUNTIME, which doesn't support DebugString().
+
+std::string ObjectIdToString(
+ const invalidation::ObjectId& object_id) {
+ std::stringstream ss;
+ ss << "{ ";
+ ss << "name: " << object_id.name().string_value() << ", ";
+ ss << "source: " << object_id.source();
+ ss << " }";
+ return ss.str();
+}
+
+std::string StatusToString(
+ const invalidation::Status& status) {
+ std::stringstream ss;
+ ss << "{ ";
+ ss << "code: " << status.code() << ", ";
+ ss << "description: " << status.description();
+ ss << " }";
+ return ss.str();
+}
+
+std::string InvalidationToString(
+ const invalidation::Invalidation& invalidation) {
+ std::stringstream ss;
+ ss << "{ ";
+ ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", ";
+ ss << "version: " << invalidation.version() << ", ";
+ ss << "components: { ";
+ const invalidation::ComponentStampLog& component_stamp_log =
+ invalidation.component_stamp_log();
+ for (int i = 0; i < component_stamp_log.stamps_size(); ++i) {
+ const invalidation::ComponentStamp& component_stamp =
+ component_stamp_log.stamps(i);
+ ss << "component: " << component_stamp.component() << ", ";
+ ss << "time: " << component_stamp.time() << ", ";
+ }
+ ss << " }";
+ ss << " }";
+ return ss.str();
+}
+
+std::string RegistrationUpdateToString(
+ const invalidation::RegistrationUpdate& update) {
+ std::stringstream ss;
+ ss << "{ ";
+ ss << "type: " << update.type() << ", ";
+ ss << "object_id: " << ObjectIdToString(update.object_id()) << ", ";
+ ss << "version: " << update.version() << ", ";
+ ss << "sequence_number: " << update.sequence_number();
+ ss << " }";
+ return ss.str();
+}
+
+std::string RegistrationUpdateResultToString(
+ const invalidation::RegistrationUpdateResult& update_result) {
+ std::stringstream ss;
+ ss << "{ ";
+ ss << "operation: "
+ << RegistrationUpdateToString(update_result.operation()) << ", ";
+ ss << "status: " << StatusToString(update_result.status());
+ ss << " }";
+ return ss.str();
+}
+
+} // namespace sync_notifier