diff options
26 files changed, 73 insertions, 533 deletions
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index 2cf676e..c352dce 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -278,12 +278,6 @@ void ProfileSyncService::InitSettings() { << " for test sync notification server."; } - notifier_options_.use_chrome_async_socket = - !command_line.HasSwitch(switches::kSyncDisableChromeAsyncSocket); - if (notifier_options_.use_chrome_async_socket) { - LOG(INFO) << "Using ChromeAsyncSocket"; - } - notifier_options_.try_ssltcp_first = command_line.HasSwitch(switches::kSyncUseSslTcp); if (notifier_options_.try_ssltcp_first) { diff --git a/chrome/browser/sync/tools/sync_listen_notifications.cc b/chrome/browser/sync/tools/sync_listen_notifications.cc index 0a7751d..5fdc9f9 100644 --- a/chrome/browser/sync/tools/sync_listen_notifications.cc +++ b/chrome/browser/sync/tools/sync_listen_notifications.cc @@ -21,7 +21,6 @@ #include "jingle/notifier/base/notification_method.h" #include "jingle/notifier/base/task_pump.h" #include "jingle/notifier/base/xmpp_client_socket_factory.h" -#include "jingle/notifier/communicator/xmpp_socket_adapter.h" #include "jingle/notifier/listener/listen_task.h" #include "jingle/notifier/listener/notification_constants.h" #include "jingle/notifier/listener/subscribe_task.h" @@ -30,9 +29,6 @@ #include "talk/base/cryptstring.h" #include "talk/base/logging.h" #include "talk/base/sigslot.h" -#include "talk/base/physicalsocketserver.h" -#include "talk/base/ssladapter.h" -#include "talk/base/thread.h" #include "talk/xmpp/jid.h" #include "talk/xmpp/xmppclient.h" #include "talk/xmpp/xmppclientsettings.h" @@ -45,14 +41,6 @@ namespace { -void PumpAuxiliaryLoops() { - talk_base::Thread* current_thread = - talk_base::ThreadManager::CurrentThread(); - current_thread->ProcessMessages(100); - MessageLoop::current()->PostTask( - FROM_HERE, NewRunnableFunction(&PumpAuxiliaryLoops)); -} - // Main class that listens for and handles messages from the XMPP // client. class XmppNotificationClient : public sigslot::has_slots<> { @@ -84,8 +72,7 @@ class XmppNotificationClient : public sigslot::has_slots<> { } // Connect with the given XMPP settings and run until disconnected. - void Run(const buzz::XmppClientSettings& xmpp_client_settings, - bool use_chrome_async_socket) { + void Run(const buzz::XmppClientSettings& xmpp_client_settings) { CHECK(!xmpp_client_); xmpp_client_settings_ = xmpp_client_settings; xmpp_client_ = new buzz::XmppClient(&task_pump_); @@ -101,15 +88,11 @@ class XmppNotificationClient : public sigslot::has_slots<> { bool use_fake_ssl_client_socket = (xmpp_client_settings.protocol() == cricket::PROTO_SSLTCP); buzz::AsyncSocket* buzz_async_socket = - use_chrome_async_socket ? - static_cast<buzz::AsyncSocket*>( - new notifier::ChromeAsyncSocket( - new notifier::XmppClientSocketFactory( - net::ClientSocketFactory::GetDefaultFactory(), - use_fake_ssl_client_socket), - ssl_config, 4096, 64 * 1024, NULL)) : - static_cast<buzz::AsyncSocket*>( - new notifier::XmppSocketAdapter(xmpp_client_settings_, false)); + new notifier::ChromeAsyncSocket( + new notifier::XmppClientSocketFactory( + net::ClientSocketFactory::GetDefaultFactory(), + use_fake_ssl_client_socket), + ssl_config, 4096, 64 * 1024, NULL); CHECK(buzz_async_socket); // Transfers ownership of buzz_async_socket. buzz::XmppReturnStatus connect_status = @@ -117,10 +100,6 @@ class XmppNotificationClient : public sigslot::has_slots<> { buzz_async_socket, NULL); CHECK_EQ(connect_status, buzz::XMPP_RETURN_OK); xmpp_client_->Start(); - if (!use_chrome_async_socket) { - MessageLoop::current()->PostTask( - FROM_HERE, NewRunnableFunction(&PumpAuxiliaryLoops)); - } MessageLoop::current()->Run(); DCHECK(!xmpp_client_); } @@ -343,11 +322,6 @@ int main(int argc, char* argv[]) { } xmpp_client_settings.set_server(addr); - // Set up message loops and socket servers. - talk_base::PhysicalSocketServer physical_socket_server; - talk_base::InitializeSSL(); - talk_base::Thread main_thread(&physical_socket_server); - talk_base::ThreadManager::SetCurrent(&main_thread); MessageLoopForIO message_loop; // Connect and listen. @@ -361,11 +335,8 @@ int main(int argc, char* argv[]) { } // TODO(akalin): Revert the move of all switches in this file into // chrome_switches.h. - bool use_chrome_async_socket = - command_line.HasSwitch("use-chrome-async-socket"); XmppNotificationClient xmpp_notification_client(delegate); - xmpp_notification_client.Run(xmpp_client_settings, - use_chrome_async_socket); + xmpp_notification_client.Run(xmpp_client_settings); return 0; } diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 4962663..9d38d74 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -988,11 +988,6 @@ const char kStartMaximized[] = "start-maximized"; // Control Sync XMPP client settings. const char kSyncAllowPlain[] = "allow-plain"; -// Disable the Chrome-socket-based buzz::AsyncSocket implementation -// for sync notifications, instead using libjingle sockets. -const char kSyncDisableChromeAsyncSocket[] = - "sync-disable-chrome-async-socket"; - // Control Sync XMPP client settings. const char kSyncDisableTls[] = "disable-tls"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index dca0d15..bcaacfe 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -279,7 +279,6 @@ extern const char kSimpleDataSource[]; extern const char kSingleProcess[]; extern const char kStartMaximized[]; extern const char kSyncAllowPlain[]; -extern const char kSyncDisableChromeAsyncSocket[]; extern const char kSyncDisableTls[]; extern const char kSyncEmail[]; extern const char kSyncerThreadTimedStop[]; diff --git a/jingle/jingle.gyp b/jingle/jingle.gyp index 2f01fff..79ee350 100644 --- a/jingle/jingle.gyp +++ b/jingle/jingle.gyp @@ -17,15 +17,11 @@ 'sources': [ 'notifier/base/chrome_async_socket.cc', 'notifier/base/chrome_async_socket.h', - 'notifier/base/signal_thread_task.h', - 'notifier/base/ssl_adapter.h', - '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', 'notifier/base/xmpp_client_socket_factory.cc', @@ -44,16 +40,10 @@ 'notifier/communicator/login_failure.h', 'notifier/communicator/login_settings.cc', 'notifier/communicator/login_settings.h', - 'notifier/communicator/product_info.cc', - 'notifier/communicator/product_info.h', 'notifier/communicator/single_login_attempt.cc', 'notifier/communicator/single_login_attempt.h', - 'notifier/communicator/ssl_socket_adapter.cc', - 'notifier/communicator/ssl_socket_adapter.h', 'notifier/communicator/xmpp_connection_generator.cc', 'notifier/communicator/xmpp_connection_generator.h', - 'notifier/communicator/xmpp_socket_adapter.cc', - 'notifier/communicator/xmpp_socket_adapter.h', 'notifier/listener/listen_task.cc', 'notifier/listener/listen_task.h', 'notifier/listener/mediator_thread.h', @@ -77,7 +67,6 @@ 'defines' : [ '_CRT_SECURE_NO_WARNINGS', '_USE_32BIT_TIME_T', - 'kXmppProductName="chromium-sync"', ], 'dependencies': [ '../base/base.gyp:base', diff --git a/jingle/notifier/base/notifier_options.h b/jingle/notifier/base/notifier_options.h index 32374cf..289b7d8 100644 --- a/jingle/notifier/base/notifier_options.h +++ b/jingle/notifier/base/notifier_options.h @@ -12,23 +12,16 @@ namespace notifier { struct NotifierOptions { NotifierOptions() - : use_chrome_async_socket(true), - try_ssltcp_first(false), + : try_ssltcp_first(false), notification_method(kDefaultNotificationMethod) {} - NotifierOptions(const bool use_chrome_async_socket, - const bool try_ssltcp_first, + NotifierOptions(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), + : 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; diff --git a/jingle/notifier/base/signal_thread_task.h b/jingle/notifier/base/signal_thread_task.h deleted file mode 100644 index 8a6ff27..0000000 --- a/jingle/notifier/base/signal_thread_task.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2009 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_SIGNAL_THREAD_TASK_H_ -#define JINGLE_NOTIFIER_BASE_SIGNAL_THREAD_TASK_H_ - -#include "base/logging.h" -#include "talk/base/common.h" -#include "talk/base/signalthread.h" -#include "talk/base/sigslot.h" -#include "talk/base/task.h" - -namespace notifier { - -template<class T> -class SignalThreadTask : public talk_base::Task, - public sigslot::has_slots<> { - public: - // Takes ownership of signal_thread. - SignalThreadTask(talk_base::Task* task_parent, T** signal_thread) - : talk_base::Task(task_parent), - signal_thread_(NULL), - finished_(false) { - SetSignalThread(signal_thread); - } - - virtual ~SignalThreadTask() { - ClearSignalThread(); - } - - virtual void Stop() { - Task::Stop(); - ClearSignalThread(); - } - - virtual int ProcessStart() { - DCHECK_EQ(GetState(), talk_base::Task::STATE_START); - signal_thread_->SignalWorkDone.connect( - this, - &SignalThreadTask<T>::OnWorkDone); - signal_thread_->Start(); - return talk_base::Task::STATE_RESPONSE; - } - - int ProcessResponse() { - if (!finished_) { - return talk_base::Task::STATE_BLOCKED; - } - SignalWorkDone(signal_thread_); - ClearSignalThread(); - return talk_base::Task::STATE_DONE; - } - - sigslot::signal1<T*> SignalWorkDone; - - private: - // Takes ownership of signal_thread. - void SetSignalThread(T** signal_thread) { - DCHECK(!signal_thread_); - DCHECK(signal_thread); - DCHECK(*signal_thread); - // No one should be listening to the signal thread for work done. - // They should be using this class instead. Unfortunately, we - // can't verify this. - - signal_thread_ = *signal_thread; - - // Helps callers not to use signal thread after this point since this class - // has taken ownership (and avoid the error of doing - // signal_thread->Start()). - *signal_thread = NULL; - } - - void OnWorkDone(talk_base::SignalThread* signal_thread) { - DCHECK_EQ(signal_thread, signal_thread_); - finished_ = true; - Wake(); - } - - void ClearSignalThread() { - if (signal_thread_) { - // Don't wait on the thread destruction, or we may deadlock. - signal_thread_->Destroy(false); - signal_thread_ = NULL; - } - } - - T* signal_thread_; - bool finished_; - DISALLOW_COPY_AND_ASSIGN(SignalThreadTask); -}; - -} // namespace notifier - -#endif // JINGLE_NOTIFIER_BASE_SIGNAL_THREAD_TASK_H_ diff --git a/jingle/notifier/base/static_assert.h b/jingle/notifier/base/static_assert.h deleted file mode 100644 index 58a8fe4..0000000 --- a/jingle/notifier/base/static_assert.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2009 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_STATIC_ASSERT_H_ -#define JINGLE_NOTIFIER_BASE_STATIC_ASSERT_H_ - -template<bool> struct STATIC_ASSERTION_FAILURE; - -template<> struct STATIC_ASSERTION_FAILURE<true> { - enum { value = 1 }; -}; - -template<int> struct static_assert_test{}; - -#define STATIC_ASSERT(B) \ -typedef static_assert_test<\ - sizeof(STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\ - static_assert_typedef_ ## __LINE__ - -#endif // JINGLE_NOTIFIER_BASE_STATIC_ASSERT_H_ diff --git a/jingle/notifier/communicator/login.cc b/jingle/notifier/communicator/login.cc index 041bc67..cd0cbbf 100644 --- a/jingle/notifier/communicator/login.cc +++ b/jingle/notifier/communicator/login.cc @@ -11,7 +11,6 @@ #include "base/time.h" #include "jingle/notifier/communicator/connection_options.h" #include "jingle/notifier/communicator/login_settings.h" -#include "jingle/notifier/communicator/product_info.h" #include "jingle/notifier/communicator/single_login_attempt.h" #include "net/base/host_port_pair.h" #include "talk/base/common.h" @@ -32,7 +31,6 @@ namespace notifier { static const int kRedirectTimeoutMinutes = 5; Login::Login(talk_base::TaskParent* parent, - bool use_chrome_async_socket, const buzz::XmppClientSettings& user_settings, const ConnectionOptions& options, std::string lang, @@ -43,7 +41,6 @@ Login::Login(talk_base::TaskParent* parent, bool try_ssltcp_first, bool proxy_only) : parent_(parent), - use_chrome_async_socket_(use_chrome_async_socket), login_settings_(new LoginSettings(user_settings, options, lang, @@ -83,9 +80,7 @@ void Login::StartConnection() { LOG(INFO) << "Starting connection..."; single_attempt_ = new SingleLoginAttempt(parent_, - login_settings_.get(), - use_chrome_async_socket_, - true); + login_settings_.get()); // Do the signaling hook-ups. single_attempt_->SignalUnexpectedDisconnect.connect( diff --git a/jingle/notifier/communicator/login.h b/jingle/notifier/communicator/login.h index 84e89a8..27b2543 100644 --- a/jingle/notifier/communicator/login.h +++ b/jingle/notifier/communicator/login.h @@ -49,7 +49,6 @@ class Login : public net::NetworkChangeNotifier::Observer, public: // firewall may be NULL. Login(talk_base::TaskParent* parent, - bool use_chrome_async_socket, const buzz::XmppClientSettings& user_settings, const ConnectionOptions& options, std::string lang, @@ -98,7 +97,6 @@ class Login : public net::NetworkChangeNotifier::Observer, void DoReconnect(); talk_base::TaskParent* parent_; - bool use_chrome_async_socket_; scoped_ptr<LoginSettings> login_settings_; LoginConnectionState state_; SingleLoginAttempt* single_attempt_; diff --git a/jingle/notifier/communicator/product_info.cc b/jingle/notifier/communicator/product_info.cc deleted file mode 100644 index c1deafb..0000000 --- a/jingle/notifier/communicator/product_info.cc +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2009 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 <string> - -namespace notifier { -std::string GetUserAgentString() { - return kXmppProductName; -} - -std::string GetProductSignature() { - return kXmppProductName; -} -} // namespace notifier diff --git a/jingle/notifier/communicator/product_info.h b/jingle/notifier/communicator/product_info.h deleted file mode 100644 index 9e8e5d0..0000000 --- a/jingle/notifier/communicator/product_info.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2009 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_COMMUNICATOR_PRODUCT_INFO_H_ -#define JINGLE_NOTIFIER_COMMUNICATOR_PRODUCT_INFO_H_ - -#include <string> - -namespace notifier { -std::string GetUserAgentString(); -std::string GetProductSignature(); -} // namespace notifier - -#endif // JINGLE_NOTIFIER_COMMUNICATOR_PRODUCT_INFO_H_ diff --git a/jingle/notifier/communicator/single_login_attempt.cc b/jingle/notifier/communicator/single_login_attempt.cc index ccdf0ce..4db7758 100644 --- a/jingle/notifier/communicator/single_login_attempt.cc +++ b/jingle/notifier/communicator/single_login_attempt.cc @@ -18,16 +18,9 @@ #include "jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h" #include "jingle/notifier/communicator/login_failure.h" #include "jingle/notifier/communicator/login_settings.h" -#include "jingle/notifier/communicator/product_info.h" #include "jingle/notifier/communicator/xmpp_connection_generator.h" -#include "jingle/notifier/communicator/xmpp_socket_adapter.h" #include "net/base/ssl_config_service.h" #include "net/socket/client_socket_factory.h" -#include "talk/base/asynchttprequest.h" -#include "talk/base/firewallsocketserver.h" -#include "talk/base/signalthread.h" -#include "talk/base/taskrunner.h" -#include "talk/base/win32socketinit.h" #include "talk/xmllite/xmlelement.h" #include "talk/xmpp/xmppclient.h" #include "talk/xmpp/xmppclientsettings.h" @@ -61,23 +54,15 @@ static void GetClientErrorInformation( } SingleLoginAttempt::SingleLoginAttempt(talk_base::TaskParent* parent, - LoginSettings* login_settings, - bool use_chrome_async_socket, - bool successful_connection) + LoginSettings* login_settings) : talk_base::Task(parent), - use_chrome_async_socket_(use_chrome_async_socket), state_(buzz::XmppEngine::STATE_NONE), code_(buzz::XmppEngine::ERROR_NONE), subcode_(0), need_authentication_(false), certificate_expired_(false), - cookie_refreshed_(false), - successful_connection_(successful_connection), login_settings_(login_settings), client_(NULL) { -#if defined(OS_WIN) - talk_base::EnsureWinsockInit(); -#endif connection_generator_.reset(new XmppConnectionGenerator( this, login_settings_->host_resolver(), @@ -154,14 +139,7 @@ void SingleLoginAttempt::OnAttemptedAllConnections( LOG(INFO) << "Connection failed with error " << code_; - // We were connected and we had a problem. - if (successful_connection_) { - SignalNeedAutoReconnect(); - // Expect to be deleted at this point. - return; - } - - DiagnoseConnectionError(); + SignalNeedAutoReconnect(); } void SingleLoginAttempt::UseNextConnection() { @@ -225,39 +203,24 @@ void SingleLoginAttempt::OnCertificateExpired() { buzz::AsyncSocket* SingleLoginAttempt::CreateSocket( const buzz::XmppClientSettings& xcs) { - if (use_chrome_async_socket_) { - bool use_fake_ssl_client_socket = - (xcs.protocol() == cricket::PROTO_SSLTCP); - net::ClientSocketFactory* const client_socket_factory = - new XmppClientSocketFactory( - net::ClientSocketFactory::GetDefaultFactory(), - use_fake_ssl_client_socket); - // The default SSLConfig is good enough for us for now. - const net::SSLConfig ssl_config; - // A read buffer of 64k ought to be sufficient. - const size_t kReadBufSize = 64U * 1024U; - // This number was taken from a similar number in - // XmppSocketAdapter. - const size_t kWriteBufSize = 64U * 1024U; - // TODO(akalin): Use a real NetLog. - net::NetLog* const net_log = NULL; - return new ChromeAsyncSocket( - client_socket_factory, ssl_config, - kReadBufSize, kWriteBufSize, net_log); - } - // TODO(akalin): Always use ChromeAsyncSocket and get rid of this - // code. - bool allow_unverified_certs = - login_settings_->connection_options().allow_unverified_certs(); - XmppSocketAdapter* adapter = new XmppSocketAdapter(xcs, - allow_unverified_certs); - adapter->SignalAuthenticationError.connect( - this, - &SingleLoginAttempt::OnAuthenticationError); - if (login_settings_->firewall()) { - adapter->set_firewall(true); - } - return adapter; + bool use_fake_ssl_client_socket = + (xcs.protocol() == cricket::PROTO_SSLTCP); + net::ClientSocketFactory* const client_socket_factory = + new XmppClientSocketFactory( + net::ClientSocketFactory::GetDefaultFactory(), + use_fake_ssl_client_socket); + // The default SSLConfig is good enough for us for now. + const net::SSLConfig ssl_config; + // A read buffer of 64k ought to be sufficient. + const size_t kReadBufSize = 64U * 1024U; + // This number was taken from a similar number in + // XmppSocketAdapter. + const size_t kWriteBufSize = 64U * 1024U; + // TODO(akalin): Use a real NetLog. + net::NetLog* const net_log = NULL; + return new ChromeAsyncSocket( + client_socket_factory, ssl_config, + kReadBufSize, kWriteBufSize, net_log); } buzz::PreXmppAuth* SingleLoginAttempt::CreatePreXmppAuth( @@ -267,147 +230,6 @@ buzz::PreXmppAuth* SingleLoginAttempt::CreatePreXmppAuth( jid.Str(), xcs.auth_cookie(), xcs.token_service()); } -void SingleLoginAttempt::OnFreshAuthCookie(const std::string& auth_cookie) { - // Remember this is a fresh cookie. - cookie_refreshed_ = true; - - // TODO(sync): do the cookie logic (part of which is in the #if 0 below). - - // The following code is what PhoneWindow does for the equivalent method. -#if 0 - // Save cookie - AccountInfo current(account_history_.current()); - current.set_auth_cookie(auth_cookie); - account_history_.set_current(current); - - // Calc next time to refresh cookie, between 5 and 10 days. The cookie has - // 14 days of life; this gives at least 4 days of retries before the current - // cookie expires, maximizing the chance of having a valid cookie next time - // the connection servers go down. - FTULL now; - - // NOTE: The following line is win32. Address this when implementing this - // code (doing "the cookie logic"). - GetSystemTimeAsFileTime(&(now.ft)); - ULONGLONG five_days = (ULONGLONG)10000 * 1000 * 60 * 60 * 24 * 5; // 5 days - ULONGLONG random = (ULONGLONG)10000 * // get to 100 ns units - ((rand() % (5 * 24 * 60)) * (60 * 1000) + // random min. in 5 day period - (rand() % 1000) * 60); // random 1/1000th of a minute - next_cookie_refresh_ = now.ull + five_days + random; // 5-10 days -#endif -} - -void SingleLoginAttempt::DiagnoseConnectionError() { - switch (code_) { - case buzz::XmppEngine::ERROR_MISSING_USERNAME: - case buzz::XmppEngine::ERROR_NETWORK_TIMEOUT: - case buzz::XmppEngine::ERROR_DOCUMENT_CLOSED: - case buzz::XmppEngine::ERROR_BIND: - case buzz::XmppEngine::ERROR_AUTH: - case buzz::XmppEngine::ERROR_TLS: - case buzz::XmppEngine::ERROR_UNAUTHORIZED: - case buzz::XmppEngine::ERROR_VERSION: - case buzz::XmppEngine::ERROR_STREAM: - case buzz::XmppEngine::ERROR_XML: - case buzz::XmppEngine::ERROR_NONE: - default: { - LoginFailure failure(LoginFailure::XMPP_ERROR, code_, subcode_); - SignalLoginFailure(failure); - return; - } - - // The following errors require diagnosistics: - // * spurious close of connection - // * socket errors after auth - case buzz::XmppEngine::ERROR_CONNECTION_CLOSED: - case buzz::XmppEngine::ERROR_SOCKET: - break; - } - - talk_base::AsyncHttpRequest *http_request = - new talk_base::AsyncHttpRequest(GetUserAgentString()); - http_request->set_host("www.google.com"); - http_request->set_port(80); - http_request->set_secure(false); - http_request->request().path = "/"; - http_request->request().verb = talk_base::HV_GET; - - talk_base::ProxyInfo proxy; - DCHECK(connection_generator_.get()); - if (connection_generator_.get()) { - proxy = connection_generator_->proxy(); - } - http_request->set_proxy(proxy); - http_request->set_firewall(login_settings_->firewall()); - - http_request->SignalWorkDone.connect(this, - &SingleLoginAttempt::OnHttpTestDone); - http_request->Start(); - http_request->Release(); -} - -void SingleLoginAttempt::OnHttpTestDone(talk_base::SignalThread* thread) { - DCHECK(thread); - - talk_base::AsyncHttpRequest* request = - static_cast<talk_base::AsyncHttpRequest*>(thread); - - if (request->response().scode == 200) { - // We were able to do an HTTP GET of www.google.com:80 - - // - // The original error should be reported - // - LoginFailure failure(LoginFailure::XMPP_ERROR, code_, subcode_); - SignalLoginFailure(failure); - return; - } - - // Otherwise lets transmute the error into ERROR_SOCKET, and put the subcode - // as an indicator of what we think the problem might be. - -#if 0 - // TODO(sync): determine if notifier has an analogous situation. - - // - // We weren't able to do an HTTP GET of www.google.com:80 - // - GAutoupdater::Version version_logged_in(g_options.version_logged_in()); - GAutoupdater::Version version_installed(GetProductVersion().c_str()); - if (version_logged_in < version_installed) { - // - // Google Talk has been updated and can no longer connect to the Google - // Talk Service. Your firewall is probably not allowing the new version of - // Google Talk to connect to the internet. Please adjust your firewall - // settings to allow the new version of Google Talk to connect to the - // internet. - // - // We'll use the "error=1" to help figure this out for now. - // - LoginFailure failure(LoginFailure::XMPP_ERROR, - buzz::XmppEngine::ERROR_SOCKET, - 1); - SignalLoginFailure(failure); - return; - } -#endif - - // - // Any other checking we can add here? - // - - // - // Google Talk is unable to use your internet connection. Either your network - // isn't configured or Google Talk is being blocked by a local firewall. - // - // We'll use the "error=0" to help figure this out for now - // - LoginFailure failure(LoginFailure::XMPP_ERROR, - buzz::XmppEngine::ERROR_SOCKET, - 0); - SignalLoginFailure(failure); -} - void SingleLoginAttempt::OnClientStateChange(buzz::XmppEngine::State state) { if (state_ == state) return; @@ -419,10 +241,8 @@ void SingleLoginAttempt::OnClientStateChange(buzz::XmppEngine::State state) { case buzz::XmppEngine::STATE_NONE: case buzz::XmppEngine::STATE_START: case buzz::XmppEngine::STATE_OPENING: - // Do nothing. - break; case buzz::XmppEngine::STATE_OPEN: - successful_connection_ = true; + // Do nothing. break; case buzz::XmppEngine::STATE_CLOSED: OnClientStateChangeClosed(previous_state); @@ -499,14 +319,6 @@ void SingleLoginAttempt::HandleConnectionError( // Or internal server binding error - // All these are temporary problems, so continue reconnecting. - // GaiaAuth signals this directly via SignalCertificateExpired, but - // SChannelAdapter propagates the error through SocketWindow as a socket - // error. - if (code_ == buzz::XmppEngine::ERROR_SOCKET && - subcode_ == SEC_E_CERT_EXPIRED) { - certificate_expired_ = true; - } - login_settings_->modifiable_user_settings()->set_resource(""); // Look for stream::error server redirection stanza "see-other-host". diff --git a/jingle/notifier/communicator/single_login_attempt.h b/jingle/notifier/communicator/single_login_attempt.h index 8b4f93b..1b9900c 100644 --- a/jingle/notifier/communicator/single_login_attempt.h +++ b/jingle/notifier/communicator/single_login_attempt.h @@ -47,9 +47,7 @@ class XmppConnectionGenerator; class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> { public: SingleLoginAttempt(talk_base::TaskParent* parent, - LoginSettings* login_settings, - bool use_chrome_async_socket, - bool successful_connection); + LoginSettings* login_settings); ~SingleLoginAttempt(); virtual int ProcessStart(); void UseNextConnection(); @@ -107,25 +105,18 @@ class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> { const buzz::XmlElement* stream_error); void HandleConnectionPasswordError(); - void DiagnoseConnectionError(); - void OnHttpTestDone(talk_base::SignalThread* thread); - void OnAuthenticationError(); void OnCertificateExpired(); - void OnFreshAuthCookie(const std::string& auth_cookie); void OnClientStateChange(buzz::XmppEngine::State state); void OnClientStateChangeClosed(buzz::XmppEngine::State previous_state); void OnAttemptedAllConnections(bool successfully_resolved_dns, int first_dns_error); - bool use_chrome_async_socket_; buzz::XmppEngine::State state_; buzz::XmppEngine::Error code_; int subcode_; bool need_authentication_; bool certificate_expired_; - bool cookie_refreshed_; - bool successful_connection_; LoginSettings* login_settings_; buzz::XmppClient* client_; scoped_ptr<XmppConnectionGenerator> connection_generator_; diff --git a/jingle/notifier/communicator/xmpp_connection_generator.cc b/jingle/notifier/communicator/xmpp_connection_generator.cc index ad551d2..25b131c 100644 --- a/jingle/notifier/communicator/xmpp_connection_generator.cc +++ b/jingle/notifier/communicator/xmpp_connection_generator.cc @@ -23,10 +23,8 @@ #include "base/callback.h" #include "base/compiler_specific.h" #include "base/logging.h" -#include "jingle/notifier/base/signal_thread_task.h" #include "jingle/notifier/communicator/connection_options.h" #include "jingle/notifier/communicator/connection_settings.h" -#include "jingle/notifier/communicator/product_info.h" #include "net/base/net_errors.h" #include "net/base/sys_addrinfo.h" #include "talk/base/httpcommon-inl.h" diff --git a/jingle/notifier/listener/mediator_thread_impl.cc b/jingle/notifier/listener/mediator_thread_impl.cc index 02d48fb1..918b49b 100644 --- a/jingle/notifier/listener/mediator_thread_impl.cc +++ b/jingle/notifier/listener/mediator_thread_impl.cc @@ -16,8 +16,6 @@ #include "jingle/notifier/listener/subscribe_task.h" #include "net/base/host_port_pair.h" #include "net/base/host_resolver.h" -#include "talk/base/physicalsocketserver.h" -#include "talk/base/thread.h" #include "talk/xmpp/xmppclient.h" #include "talk/xmpp/xmppclientsettings.h" @@ -51,44 +49,6 @@ 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) { - worker_message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod(this, &MediatorThreadImpl::StartLibjingleThread)); - } -} - -void MediatorThreadImpl::StartLibjingleThread() { - DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.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()); - worker_message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod(this, &MediatorThreadImpl::PumpLibjingleLoop)); -} - -void MediatorThreadImpl::StopLibjingleThread() { - DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.use_chrome_async_socket); - talk_base::ThreadManager::SetCurrent(NULL); - libjingle_thread_.reset(); - socket_server_.reset(); -} - -void MediatorThreadImpl::PumpLibjingleLoop() { - DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.use_chrome_async_socket); - // Pump the libjingle message loop 100ms at a time. - if (!libjingle_thread_.get()) { - // StopLibjingleThread() was called. - return; - } - libjingle_thread_->ProcessMessages(100); - worker_message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod(this, &MediatorThreadImpl::PumpLibjingleLoop)); } void MediatorThreadImpl::Login(const buzz::XmppClientSettings& settings) { @@ -103,11 +63,6 @@ void MediatorThreadImpl::Logout() { worker_message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &MediatorThreadImpl::DoDisconnect)); - if (!notifier_options_.use_chrome_async_socket) { - worker_message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod(this, &MediatorThreadImpl::StopLibjingleThread)); - } // TODO(akalin): Decomp this into a separate stop method. worker_thread_.Stop(); // Process any messages the worker thread may be posted on our @@ -205,7 +160,6 @@ 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, settings, options, lang, diff --git a/jingle/notifier/listener/mediator_thread_impl.h b/jingle/notifier/listener/mediator_thread_impl.h index 755731e..342079f 100644 --- a/jingle/notifier/listener/mediator_thread_impl.h +++ b/jingle/notifier/listener/mediator_thread_impl.h @@ -93,10 +93,6 @@ class MediatorThreadImpl MessageLoop* parent_message_loop_; private: - void StartLibjingleThread(); - void PumpLibjingleLoop(); - void StopLibjingleThread(); - // Called from within the thread on internal events. void DoLogin(const buzz::XmppClientSettings& settings); void DoDisconnect(); @@ -137,10 +133,6 @@ class MediatorThreadImpl scoped_ptr<notifier::TaskPump> pump_; scoped_ptr<notifier::Login> login_; - // Used only when |use_chrome_async_socket_| is false. - scoped_ptr<talk_base::SocketServer> socket_server_; - scoped_ptr<talk_base::Thread> libjingle_thread_; - DISALLOW_COPY_AND_ASSIGN(MediatorThreadImpl); }; diff --git a/remoting/DEPS b/remoting/DEPS index 4370b43..6bfe57b 100644 --- a/remoting/DEPS +++ b/remoting/DEPS @@ -3,6 +3,7 @@ include_rules = [ "+gfx", "+google/protobuf", "+media/base", + "+net", "+jingle", diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc index 01e607b..d3ca67e 100644 --- a/remoting/jingle_glue/jingle_client.cc +++ b/remoting/jingle_glue/jingle_client.cc @@ -7,10 +7,10 @@ #include "base/logging.h" #include "base/message_loop.h" #include "jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h" -#include "jingle/notifier/communicator/xmpp_socket_adapter.h" #include "remoting/jingle_glue/iq_request.h" #include "remoting/jingle_glue/jingle_thread.h" #include "remoting/jingle_glue/relay_port_allocator.h" +#include "remoting/jingle_glue/xmpp_socket_adapter.h" #include "third_party/libjingle/source/talk/base/asyncsocket.h" #include "third_party/libjingle/source/talk/base/ssladapter.h" #include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h" @@ -94,7 +94,7 @@ void JingleClient::DoInitialize(const std::string& username, client_->SignalStateChange.connect( this, &JingleClient::OnConnectionStateChanged); - buzz::AsyncSocket* socket = new notifier::XmppSocketAdapter(settings, false); + buzz::AsyncSocket* socket = new XmppSocketAdapter(settings, false); client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); client_->Start(); diff --git a/jingle/notifier/base/ssl_adapter.cc b/remoting/jingle_glue/ssl_adapter.cc index 2111244..68d350c 100644 --- a/jingle/notifier/base/ssl_adapter.cc +++ b/remoting/jingle_glue/ssl_adapter.cc @@ -2,26 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "jingle/notifier/base/ssl_adapter.h" +#include "remoting/jingle_glue/ssl_adapter.h" #if defined(OS_WIN) #include "talk/base/ssladapter.h" #else -#include "jingle/notifier/communicator/ssl_socket_adapter.h" +#include "remoting/jingle_glue/ssl_socket_adapter.h" #endif -namespace notifier { +namespace remoting { talk_base::SSLAdapter* CreateSSLAdapter(talk_base::AsyncSocket* socket) { talk_base::SSLAdapter* ssl_adapter = #if defined(OS_WIN) talk_base::SSLAdapter::Create(socket); #else - notifier::SSLSocketAdapter::Create(socket); + remoting::SSLSocketAdapter::Create(socket); #endif DCHECK(ssl_adapter); return ssl_adapter; } -} // namespace notifier +} // namespace remoting diff --git a/jingle/notifier/base/ssl_adapter.h b/remoting/jingle_glue/ssl_adapter.h index 32517cd..56b03be 100644 --- a/jingle/notifier/base/ssl_adapter.h +++ b/remoting/jingle_glue/ssl_adapter.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef JINGLE_NOTIFIER_BASE_SSL_ADAPTER_H_ -#define JINGLE_NOTIFIER_BASE_SSL_ADAPTER_H_ +#ifndef REMOTING_JINGLE_GLUE_SSL_ADAPTER_H_ +#define REMOTING_JINGLE_GLUE_SSL_ADAPTER_H_ namespace talk_base { class AsyncSocket; class SSLAdapter; } // namespace talk_base -namespace notifier { +namespace remoting { // Wraps the given socket in a platform-dependent SSLAdapter // implementation. @@ -23,11 +23,11 @@ class SSLAdapterSocketFactory : public SocketFactory { public: virtual talk_base::SSLAdapter* CreateSSLAdapter( talk_base::AsyncSocket* socket) { - return ::notifier::CreateSSLAdapter(socket); + return ::remoting::CreateSSLAdapter(socket); } }; -} // namespace notifier +} // namespace remoting -#endif // JINGLE_NOTIFIER_BASE_SSL_ADAPTER_H_ +#endif // REMOTING_JINGLE_GLUE_SSL_ADAPTER_H_ diff --git a/jingle/notifier/communicator/ssl_socket_adapter.cc b/remoting/jingle_glue/ssl_socket_adapter.cc index cac3041..3ea404b 100644 --- a/jingle/notifier/communicator/ssl_socket_adapter.cc +++ b/remoting/jingle_glue/ssl_socket_adapter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "jingle/notifier/communicator/ssl_socket_adapter.h" +#include "remoting/jingle_glue/ssl_socket_adapter.h" #include "base/compiler_specific.h" #include "base/message_loop.h" @@ -13,7 +13,7 @@ #include "net/socket/client_socket_factory.h" #include "net/url_request/url_request_context.h" -namespace notifier { +namespace remoting { namespace { @@ -383,4 +383,4 @@ void TransportSocket::OnWriteEvent(talk_base::AsyncSocket* socket) { } } -} // namespace notifier +} // namespace remoting diff --git a/jingle/notifier/communicator/ssl_socket_adapter.h b/remoting/jingle_glue/ssl_socket_adapter.h index cdbc94e..a22e2b7 100644 --- a/jingle/notifier/communicator/ssl_socket_adapter.h +++ b/remoting/jingle_glue/ssl_socket_adapter.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef JINGLE_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ -#define JINGLE_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ +#ifndef REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ +#define REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ #include "base/scoped_ptr.h" #include "net/base/completion_callback.h" @@ -15,7 +15,7 @@ #include "talk/base/asyncsocket.h" #include "talk/base/ssladapter.h" -namespace notifier { +namespace remoting { class SSLSocketAdapter; @@ -81,7 +81,7 @@ class TransportSocket : public net::ClientSocket, public sigslot::has_slots<> { }; // This provides a talk_base::AsyncSocketAdapter interface around Chromium's -// net::SSLClientSocket class. This allows notifier to use Chromium's SSL +// net::SSLClientSocket class. This allows remoting to use Chromium's SSL // implementation instead of OpenSSL. class SSLSocketAdapter : public talk_base::SSLAdapter { public: @@ -140,6 +140,6 @@ class SSLSocketAdapter : public talk_base::SSLAdapter { DISALLOW_COPY_AND_ASSIGN(SSLSocketAdapter); }; -} // namespace notifier +} // namespace remoting -#endif // JINGLE_NOTIFIER_COMMUNICATOR_SSL_SOCKET_ADAPTER_H_ +#endif // REMOTING_JINGLE_GLUE_SSL_SOCKET_ADAPTER_H_ diff --git a/jingle/notifier/communicator/xmpp_socket_adapter.cc b/remoting/jingle_glue/xmpp_socket_adapter.cc index 7d7a2e9..08f72aa 100644 --- a/jingle/notifier/communicator/xmpp_socket_adapter.cc +++ b/remoting/jingle_glue/xmpp_socket_adapter.cc @@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "jingle/notifier/communicator/xmpp_socket_adapter.h" +#include "remoting/jingle_glue/xmpp_socket_adapter.h" #include <iomanip> #include <string> #include "base/logging.h" -#include "jingle/notifier/base/ssl_adapter.h" -#include "jingle/notifier/communicator/product_info.h" +#include "remoting/jingle_glue/ssl_adapter.h" #include "talk/base/byteorder.h" #include "talk/base/common.h" #include "talk/base/firewallsocketserver.h" @@ -19,7 +18,7 @@ #include "talk/base/thread.h" #include "talk/xmpp/xmppengine.h" -namespace notifier { +namespace remoting { XmppSocketAdapter::XmppSocketAdapter(const buzz::XmppClientSettings& xcs, bool allow_unverified_certs) @@ -111,7 +110,7 @@ bool XmppSocketAdapter::Connect(const talk_base::SocketAddress& addr) { } else { // Note: we are trying unknown proxies as HTTPS currently. proxy_socket = new talk_base::AsyncHttpsProxySocket(socket, - GetUserAgentString(), proxy_.address, proxy_.username, + "chromoting", proxy_.address, proxy_.username, proxy_.password); } if (!proxy_socket) { @@ -134,7 +133,7 @@ bool XmppSocketAdapter::Connect(const talk_base::SocketAddress& addr) { } #if defined(FEATURE_ENABLE_SSL) - talk_base::SSLAdapter* ssl_adapter = notifier::CreateSSLAdapter(socket); + talk_base::SSLAdapter* ssl_adapter = remoting::CreateSSLAdapter(socket); socket = ssl_adapter; // For our purposes the SSL adapter is the socket. #endif @@ -426,4 +425,4 @@ bool XmppSocketAdapter::HandleWritable() { return true; } -} // namespace notifier +} // namespace remoting diff --git a/jingle/notifier/communicator/xmpp_socket_adapter.h b/remoting/jingle_glue/xmpp_socket_adapter.h index ff22a9c..d1a6f65 100644 --- a/jingle/notifier/communicator/xmpp_socket_adapter.h +++ b/remoting/jingle_glue/xmpp_socket_adapter.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef JINGLE_NOTIFIER_COMMUNICATOR_XMPP_SOCKET_ADAPTER_H_ -#define JINGLE_NOTIFIER_COMMUNICATOR_XMPP_SOCKET_ADAPTER_H_ +#ifndef REMOTING_JINGLE_GLUE_XMPP_SOCKET_ADAPTER_H_ +#define REMOTING_JINGLE_GLUE_XMPP_SOCKET_ADAPTER_H_ #include <string> @@ -18,7 +18,7 @@ #define WSA_NOT_ENOUGH_MEMORY ENOMEM #endif -namespace notifier { +namespace remoting { class XmppSocketAdapter : public buzz::AsyncSocket, public sigslot::has_slots<> { @@ -82,6 +82,6 @@ class XmppSocketAdapter : public buzz::AsyncSocket, DISALLOW_COPY_AND_ASSIGN(XmppSocketAdapter); }; -} // namespace notifier +} // namespace remoting -#endif // JINGLE_NOTIFIER_COMMUNICATOR_XMPP_SOCKET_ADAPTER_H_ +#endif // REMOTING_JINGLE_GLUE_XMPP_SOCKET_ADAPTER_H_ diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 71b81d0..b0c52e2 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -316,6 +316,12 @@ 'jingle_glue/jingle_thread.h', 'jingle_glue/relay_port_allocator.cc', 'jingle_glue/relay_port_allocator.h', + 'jingle_glue/ssl_adapter.h', + 'jingle_glue/ssl_adapter.cc', + 'jingle_glue/ssl_socket_adapter.cc', + 'jingle_glue/ssl_socket_adapter.h', + 'jingle_glue/xmpp_socket_adapter.cc', + 'jingle_glue/xmpp_socket_adapter.h', ], }, # end of target 'chromoting_jingle_glue' |