diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-07 22:43:05 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-07 22:43:05 +0000 |
commit | a1c62688a8dc650f9a564e9cd86d9f26ec890d8d (patch) | |
tree | 929798881f3d450fd7d4f0c689949500e64442d7 /jingle | |
parent | 4cbf13c20a9e18538515e2a83c2fbfd01659eaad (diff) | |
download | chromium_src-a1c62688a8dc650f9a564e9cd86d9f26ec890d8d.zip chromium_src-a1c62688a8dc650f9a564e9cd86d9f26ec890d8d.tar.gz chromium_src-a1c62688a8dc650f9a564e9cd86d9f26ec890d8d.tar.bz2 |
Revert 58768 - 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
TBR=rsimha@chromium.org
Review URL: http://codereview.chromium.org/3318016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r-- | jingle/jingle.gyp | 3 | ||||
-rw-r--r-- | jingle/notifier/base/notification_method.cc | 52 | ||||
-rw-r--r-- | jingle/notifier/base/notification_method.h | 68 | ||||
-rw-r--r-- | jingle/notifier/base/notifier_options.h | 47 | ||||
-rw-r--r-- | jingle/notifier/listener/mediator_thread_impl.cc | 47 | ||||
-rw-r--r-- | jingle/notifier/listener/mediator_thread_impl.h | 6 | ||||
-rw-r--r-- | jingle/notifier/listener/talk_mediator_unittest.cc | 8 |
7 files changed, 27 insertions, 204 deletions
diff --git a/jingle/jingle.gyp b/jingle/jingle.gyp index 2f01fff..dd76e04 100644 --- a/jingle/jingle.gyp +++ b/jingle/jingle.gyp @@ -22,9 +22,6 @@ 'notifier/base/ssl_adapter.cc', 'notifier/base/fake_ssl_client_socket.cc', 'notifier/base/fake_ssl_client_socket.h', - 'notifier/base/notification_method.h', - 'notifier/base/notification_method.cc', - 'notifier/base/notifier_options.h', 'notifier/base/static_assert.h', 'notifier/base/task_pump.cc', 'notifier/base/task_pump.h', diff --git a/jingle/notifier/base/notification_method.cc b/jingle/notifier/base/notification_method.cc deleted file mode 100644 index 08feb4a..0000000 --- a/jingle/notifier/base/notification_method.cc +++ /dev/null @@ -1,52 +0,0 @@ -// 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 deleted file mode 100644 index aedc11d..0000000 --- a/jingle/notifier/base/notification_method.h +++ /dev/null @@ -1,68 +0,0 @@ -// 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 deleted file mode 100644 index 32374cf..0000000 --- a/jingle/notifier/base/notifier_options.h +++ /dev/null @@ -1,47 +0,0 @@ -// 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_ diff --git a/jingle/notifier/listener/mediator_thread_impl.cc b/jingle/notifier/listener/mediator_thread_impl.cc index 02d48fb1..63e404e 100644 --- a/jingle/notifier/listener/mediator_thread_impl.cc +++ b/jingle/notifier/listener/mediator_thread_impl.cc @@ -26,10 +26,12 @@ DISABLE_RUNNABLE_METHOD_REFCOUNT(notifier::MediatorThreadImpl); namespace notifier { -MediatorThreadImpl::MediatorThreadImpl(const NotifierOptions& notifier_options) +MediatorThreadImpl::MediatorThreadImpl(bool use_chrome_async_socket, + bool try_ssltcp_first) : delegate_(NULL), parent_message_loop_(MessageLoop::current()), - notifier_options_(notifier_options), + use_chrome_async_socket_(use_chrome_async_socket), + try_ssltcp_first_(try_ssltcp_first), worker_thread_("MediatorThread worker thread") { DCHECK(parent_message_loop_); } @@ -51,7 +53,7 @@ void MediatorThreadImpl::Start() { // TODO(akalin): Make this function return a bool and remove this // CHECK(). CHECK(worker_thread_.StartWithOptions(options)); - if (!notifier_options_.use_chrome_async_socket) { + if (!use_chrome_async_socket_) { worker_message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &MediatorThreadImpl::StartLibjingleThread)); @@ -60,7 +62,7 @@ void MediatorThreadImpl::Start() { void MediatorThreadImpl::StartLibjingleThread() { DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.use_chrome_async_socket); + DCHECK(!use_chrome_async_socket_); socket_server_.reset(new talk_base::PhysicalSocketServer()); libjingle_thread_.reset(new talk_base::Thread()); talk_base::ThreadManager::SetCurrent(libjingle_thread_.get()); @@ -71,7 +73,7 @@ void MediatorThreadImpl::StartLibjingleThread() { void MediatorThreadImpl::StopLibjingleThread() { DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.use_chrome_async_socket); + DCHECK(!use_chrome_async_socket_); talk_base::ThreadManager::SetCurrent(NULL); libjingle_thread_.reset(); socket_server_.reset(); @@ -79,7 +81,7 @@ void MediatorThreadImpl::StopLibjingleThread() { void MediatorThreadImpl::PumpLibjingleLoop() { DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.use_chrome_async_socket); + DCHECK(!use_chrome_async_socket_); // Pump the libjingle message loop 100ms at a time. if (!libjingle_thread_.get()) { // StopLibjingleThread() was called. @@ -103,7 +105,7 @@ void MediatorThreadImpl::Logout() { worker_message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &MediatorThreadImpl::DoDisconnect)); - if (!notifier_options_.use_chrome_async_socket) { + if (!use_chrome_async_socket_) { worker_message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &MediatorThreadImpl::StopLibjingleThread)); @@ -180,24 +182,15 @@ void MediatorThreadImpl::DoLogin( pump_.reset(new notifier::TaskPump()); notifier::ServerInformation server_list[2]; - int server_list_count = 0; - - // Override the default servers with a test notification server if one was - // provided. - if(!notifier_options_.xmpp_host_port.host().empty()) { - server_list[0].server = notifier_options_.xmpp_host_port; - server_list[0].special_port_magic = false; - server_list_count = 1; - } else { - // The default servers know how to serve over port 443 (that's the magic). - server_list[0].server = net::HostPortPair("talk.google.com", - notifier::kDefaultXmppPort); - server_list[0].special_port_magic = true; - server_list[1].server = net::HostPortPair("talkx.l.google.com", - notifier::kDefaultXmppPort); - server_list[1].special_port_magic = true; - server_list_count = 2; - } + int server_list_count = 2; + + // The default servers know how to serve over port 443 (that's the magic). + server_list[0].server = net::HostPortPair("talk.google.com", + notifier::kDefaultXmppPort); + server_list[0].special_port_magic = true; + server_list[1].server = net::HostPortPair("talkx.l.google.com", + notifier::kDefaultXmppPort); + server_list[1].special_port_magic = true; // Autodetect proxy is on by default. notifier::ConnectionOptions options; @@ -205,7 +198,7 @@ void MediatorThreadImpl::DoLogin( // Language is not used in the stanza so we default to |en|. std::string lang = "en"; login_.reset(new notifier::Login(pump_.get(), - notifier_options_.use_chrome_async_socket, + use_chrome_async_socket_, settings, options, lang, @@ -214,7 +207,7 @@ void MediatorThreadImpl::DoLogin( server_list_count, // talk_base::FirewallManager* is NULL. NULL, - notifier_options_.try_ssltcp_first, + try_ssltcp_first_, // Both the proxy and a non-proxy route // will be attempted. false)); diff --git a/jingle/notifier/listener/mediator_thread_impl.h b/jingle/notifier/listener/mediator_thread_impl.h index 755731e..39eca59 100644 --- a/jingle/notifier/listener/mediator_thread_impl.h +++ b/jingle/notifier/listener/mediator_thread_impl.h @@ -27,7 +27,6 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/thread.h" -#include "jingle/notifier/base/notifier_options.h" #include "jingle/notifier/communicator/login.h" #include "jingle/notifier/communicator/login_connection_state.h" #include "jingle/notifier/communicator/login_failure.h" @@ -60,7 +59,7 @@ class MediatorThreadImpl : public MediatorThread, public sigslot::has_slots<> { public: - explicit MediatorThreadImpl(const NotifierOptions& notifier_options); + MediatorThreadImpl(bool use_chrome_async_socket, bool try_ssltcp_first); virtual ~MediatorThreadImpl(); virtual void SetDelegate(Delegate* delegate); @@ -125,7 +124,8 @@ class MediatorThreadImpl void OnSubscriptionStateChangeOnParentThread( bool success); - const NotifierOptions notifier_options_; + const bool use_chrome_async_socket_; + const bool try_ssltcp_first_; base::Thread worker_thread_; scoped_refptr<net::HostResolver> host_resolver_; diff --git a/jingle/notifier/listener/talk_mediator_unittest.cc b/jingle/notifier/listener/talk_mediator_unittest.cc index 36bc94b..a138052 100644 --- a/jingle/notifier/listener/talk_mediator_unittest.cc +++ b/jingle/notifier/listener/talk_mediator_unittest.cc @@ -6,7 +6,6 @@ #include "base/basictypes.h" #include "base/message_loop.h" -#include "jingle/notifier/base/notifier_options.h" #include "jingle/notifier/listener/mediator_thread_mock.h" #include "jingle/notifier/listener/mediator_thread_impl.h" #include "jingle/notifier/listener/talk_mediator_impl.h" @@ -39,13 +38,14 @@ class TalkMediatorImplTest : public testing::Test { virtual ~TalkMediatorImplTest() {} TalkMediatorImpl* NewTalkMediator() { - const notifier::NotifierOptions kNotifierOptions; + const bool kUseChromeAsyncSocket = false; + const bool kTrySslTcpFirst = false; const bool kInitializeSsl = true; const bool kConnectImmediately = false; const bool kInvalidateXmppAuthToken = false; return new TalkMediatorImpl( - new MediatorThreadImpl(kNotifierOptions), kInitializeSsl, - kConnectImmediately, kInvalidateXmppAuthToken); + new MediatorThreadImpl(kUseChromeAsyncSocket, kTrySslTcpFirst), + kInitializeSsl, kConnectImmediately, kInvalidateXmppAuthToken); } TalkMediatorImpl* NewMockedTalkMediator( |