| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef JINGLE_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_ | 5 #ifndef JINGLE_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_ |
| 6 #define JINGLE_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_ | 6 #define JINGLE_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "jingle/notifier/base/xmpp_connection.h" | 10 #include "jingle/notifier/base/xmpp_connection.h" |
| 11 #include "jingle/notifier/communicator/connection_settings.h" | 11 #include "jingle/notifier/communicator/connection_settings.h" |
| 12 #include "jingle/notifier/communicator/login_settings.h" | 12 #include "jingle/notifier/communicator/login_settings.h" |
| 13 #include "talk/xmpp/xmppengine.h" | 13 #include "talk/xmpp/xmppengine.h" |
| 14 | 14 |
| 15 namespace buzz { | 15 namespace buzz { |
| 16 class XmppTaskParentInterface; | 16 class XmppTaskParentInterface; |
| 17 } // namespace buzz | 17 } // namespace buzz |
| 18 | 18 |
| 19 namespace notifier { | 19 namespace notifier { |
| 20 | 20 |
| 21 struct ServerInformation; | 21 struct ServerInformation; |
| 22 | 22 |
| 23 // Handles all of the aspects of a single login attempt. By | 23 // Handles all of the aspects of a single login attempt. By |
| 24 // containing this within one class, when another login attempt is | 24 // containing this within one class, when another login attempt is |
| 25 // made, this class can be destroyed to immediately stop the previous | 25 // made, this class can be destroyed to immediately stop the previous |
| 26 // login attempt. | 26 // login attempt. |
| 27 class SingleLoginAttempt : public XmppConnection::Delegate { | 27 class SingleLoginAttempt : public XmppConnection::Delegate { |
| 28 public: | 28 public: |
| 29 // At most one delegate method will be called, depending on the |
| 30 // result of the login attempt. After the delegate method is |
| 31 // called, this class won't do anything anymore until it is |
| 32 // destroyed, at which point it will disconnect if necessary. |
| 29 class Delegate { | 33 class Delegate { |
| 30 public: | 34 public: |
| 31 virtual void OnConnect( | 35 virtual void OnConnect( |
| 32 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) = 0; | 36 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) = 0; |
| 33 virtual void OnNeedReconnect() = 0; | 37 virtual void OnNeedReconnect() = 0; |
| 34 virtual void OnRedirect(const ServerInformation& redirect_server) = 0; | 38 virtual void OnRedirect(const ServerInformation& redirect_server) = 0; |
| 39 virtual void OnRejectedCredentials() = 0; |
| 35 | 40 |
| 36 protected: | 41 protected: |
| 37 virtual ~Delegate(); | 42 virtual ~Delegate(); |
| 38 }; | 43 }; |
| 39 | 44 |
| 40 // Does not take ownership of |delegate|, which must not be NULL. | 45 // Does not take ownership of |delegate|, which must not be NULL. |
| 41 SingleLoginAttempt(const LoginSettings& login_settings, Delegate* delegate); | 46 SingleLoginAttempt(const LoginSettings& login_settings, Delegate* delegate); |
| 42 | 47 |
| 43 virtual ~SingleLoginAttempt(); | 48 virtual ~SingleLoginAttempt(); |
| 44 | 49 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 const ConnectionSettingsList settings_list_; | 62 const ConnectionSettingsList settings_list_; |
| 58 ConnectionSettingsList::const_iterator current_settings_; | 63 ConnectionSettingsList::const_iterator current_settings_; |
| 59 scoped_ptr<XmppConnection> xmpp_connection_; | 64 scoped_ptr<XmppConnection> xmpp_connection_; |
| 60 | 65 |
| 61 DISALLOW_COPY_AND_ASSIGN(SingleLoginAttempt); | 66 DISALLOW_COPY_AND_ASSIGN(SingleLoginAttempt); |
| 62 }; | 67 }; |
| 63 | 68 |
| 64 } // namespace notifier | 69 } // namespace notifier |
| 65 | 70 |
| 66 #endif // JINGLE_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_ | 71 #endif // JINGLE_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_ |
| OLD | NEW |