summaryrefslogtreecommitdiffstats
path: root/jingle/notifier/base
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-07 22:28:23 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-07 22:28:23 +0000
commit4cbf13c20a9e18538515e2a83c2fbfd01659eaad (patch)
tree8a663789a02817f284f4848fca2ecf42faf5f3a7 /jingle/notifier/base
parent90eaf71823e9e5480f7e542421cccbba969044c7 (diff)
downloadchromium_src-4cbf13c20a9e18538515e2a83c2fbfd01659eaad.zip
chromium_src-4cbf13c20a9e18538515e2a83c2fbfd01659eaad.tar.gz
chromium_src-4cbf13c20a9e18538515e2a83c2fbfd01659eaad.tar.bz2
Adding the sync-notification-host command line parameter to the integration tests.
The sync integration tests currently access the network to communicate with the notification server. We need to move to a model where all server accesses are stubbed out by local servers. This is the first step towards implementing a local notification server. BUG=53933,53931 TEST=sync_integration_tests Review URL: http://codereview.chromium.org/3326007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle/notifier/base')
-rw-r--r--jingle/notifier/base/notification_method.cc52
-rw-r--r--jingle/notifier/base/notification_method.h68
-rw-r--r--jingle/notifier/base/notifier_options.h47
3 files changed, 167 insertions, 0 deletions
diff --git a/jingle/notifier/base/notification_method.cc b/jingle/notifier/base/notification_method.cc
new file mode 100644
index 0000000..08feb4a
--- /dev/null
+++ b/jingle/notifier/base/notification_method.cc
@@ -0,0 +1,52 @@
+// 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 "jingle/notifier/base/notification_method.h"
+
+#include "base/logging.h"
+
+namespace notifier {
+
+const NotificationMethod kDefaultNotificationMethod = NOTIFICATION_SERVER;
+
+std::string NotificationMethodToString(
+ NotificationMethod notification_method) {
+ switch (notification_method) {
+ case NOTIFICATION_LEGACY:
+ return "NOTIFICATION_LEGACY";
+ break;
+ case NOTIFICATION_TRANSITIONAL:
+ return "NOTIFICATION_TRANSITIONAL";
+ break;
+ case NOTIFICATION_NEW:
+ return "NOTIFICATION_NEW";
+ break;
+ case NOTIFICATION_SERVER:
+ return "NOTIFICATION_SERVER";
+ break;
+ default:
+ LOG(WARNING) << "Unknown value for notification method: "
+ << notification_method;
+ break;
+ }
+ return "<unknown notification method>";
+}
+
+NotificationMethod StringToNotificationMethod(const std::string& str) {
+ if (str == "legacy") {
+ return NOTIFICATION_LEGACY;
+ } else if (str == "transitional") {
+ return NOTIFICATION_TRANSITIONAL;
+ } else if (str == "new") {
+ return NOTIFICATION_NEW;
+ } else if (str == "server") {
+ return NOTIFICATION_SERVER;
+ }
+ LOG(WARNING) << "Unknown notification method \"" << str
+ << "\"; using method "
+ << NotificationMethodToString(kDefaultNotificationMethod);
+ return kDefaultNotificationMethod;
+}
+
+} // namespace notifier
diff --git a/jingle/notifier/base/notification_method.h b/jingle/notifier/base/notification_method.h
new file mode 100644
index 0000000..aedc11d
--- /dev/null
+++ b/jingle/notifier/base/notification_method.h
@@ -0,0 +1,68 @@
+// 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.
+
+#ifndef JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_
+#define JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_
+#pragma once
+
+#include <string>
+
+namespace notifier {
+
+// This is the matrix for the interaction between clients with
+// different notification methods (except for NOTIFICATION_SERVER):
+//
+// Listen
+// L T N
+// +-------+
+// L | E E E |
+// Send T | Y Y Y |
+// N | E Y Y |
+// +-------+
+//
+// 'Y' means a client listening with the column notification method
+// will receive notifications from a client sending with the row
+// notification method. 'E' means means that the notification will be
+// an empty one, which may be dropped by the server in the future.
+//
+// As for NOTIFICATION_SERVER, server-issued notifications will also
+// simulate a peer-issued notification, so that any client with
+// NOTIFICATION_TRANSITIONAL or NOTIFICATION_NEW will be able to
+// receive those, too. This support will be removed once everyone is
+// on NOTIFICATION_SERVER.
+
+enum NotificationMethod {
+ // Old, broken notification method. Works only if notification
+ // servers don't drop empty notifications.
+ NOTIFICATION_LEGACY,
+ // Compatible with new notifications. Also compatible with legacy
+ // notifications if the notification servers don't drop empty
+ // notifications.
+ NOTIFICATION_TRANSITIONAL,
+ // New notification method. Compatible only with transitional
+ // notifications.
+ //
+ // NOTE: "New" is kind of a misnomer, as it refers only to
+ // peer-issued notifications; the plan is to migrate everyone to
+ // using NOTIFICATION_SERVER.
+ NOTIFICATION_NEW,
+
+ // Server-issued notifications. Compatible only with transitional
+ // notifications.
+ NOTIFICATION_SERVER,
+};
+
+extern const NotificationMethod kDefaultNotificationMethod;
+
+std::string NotificationMethodToString(
+ NotificationMethod notification_method);
+
+// If the given string is not one of "legacy", "transitional", "new",
+// or "server", returns kDefaultNotificationMethod.
+NotificationMethod StringToNotificationMethod(const std::string& str);
+
+} // namespace notifier
+
+#endif // JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_
+
diff --git a/jingle/notifier/base/notifier_options.h b/jingle/notifier/base/notifier_options.h
new file mode 100644
index 0000000..32374cf
--- /dev/null
+++ b/jingle/notifier/base/notifier_options.h
@@ -0,0 +1,47 @@
+// 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.
+
+#ifndef JINGLE_NOTIFIER_BASE_NOTIFIER_OPTIONS_H_
+#define JINGLE_NOTIFIER_BASE_NOTIFIER_OPTIONS_H_
+
+#include "jingle/notifier/base/notification_method.h"
+#include "net/base/host_port_pair.h"
+
+namespace notifier {
+
+struct NotifierOptions {
+ NotifierOptions()
+ : use_chrome_async_socket(true),
+ try_ssltcp_first(false),
+ notification_method(kDefaultNotificationMethod) {}
+
+ NotifierOptions(const bool use_chrome_async_socket,
+ const bool try_ssltcp_first,
+ const net::HostPortPair& xmpp_host_port,
+ NotificationMethod notification_method)
+ : use_chrome_async_socket(use_chrome_async_socket),
+ try_ssltcp_first(try_ssltcp_first),
+ xmpp_host_port(xmpp_host_port),
+ notification_method(notification_method) {}
+
+ // Indicates whether to use the chrome-socket-based buzz::AsyncSocket
+ // implementation for notifications.
+ bool use_chrome_async_socket;
+
+ // Indicates that the SSLTCP port (443) is to be tried before the the XMPP
+ // port (5222) during login.
+ bool try_ssltcp_first;
+
+ // Contains a custom URL and port for the notification server, if one is to
+ // be used. Empty otherwise.
+ net::HostPortPair xmpp_host_port;
+
+ // Indicates the method used by sync clients while sending and listening to
+ // notifications.
+ NotificationMethod notification_method;
+};
+
+} // namespace notifier
+
+#endif // JINGLE_NOTIFIER_BASE_NOTIFIER_OPTIONS_H_