Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: jingle/notifier/communicator/login.h

Issue 10545170: [Sync] Propagate XMPP auth errors to SyncNotifierObservers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_LOGIN_H_ 5 #ifndef JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_H_
6 #define JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_H_ 6 #define JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 15 matching lines...) Expand all
26 } // namespace buzz 26 } // namespace buzz
27 27
28 namespace net { 28 namespace net {
29 class URLRequestContextGetter; 29 class URLRequestContextGetter;
30 } // namespace net 30 } // namespace net
31 31
32 namespace notifier { 32 namespace notifier {
33 33
34 class LoginSettings; 34 class LoginSettings;
35 35
36 // Workaround for MSVS 2005 bug that fails to handle inheritance from a nested 36 // Does the login, keeps it alive (with refreshing cookies and
37 // class properly if it comes directly on a base class list. 37 // reattempting login when disconnected), and figures out what actions
38 typedef SingleLoginAttempt::Delegate SingleLoginAttemptDelegate; 38 // to take on the various errors that may occur.
39
40 // Does the login, keeps it alive (with refreshing cookies and reattempting
41 // login when disconnected), figures out what actions to take on the various
42 // errors that may occur.
43 class Login : public net::NetworkChangeNotifier::IPAddressObserver, 39 class Login : public net::NetworkChangeNotifier::IPAddressObserver,
44 public SingleLoginAttemptDelegate { 40 public SingleLoginAttempt::Delegate {
45 public: 41 public:
46 class Delegate { 42 class Delegate {
47 public: 43 public:
44 // Called when a connection has been successfully established.
48 virtual void OnConnect( 45 virtual void OnConnect(
49 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) = 0; 46 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) = 0;
47
48 // Called when we've detected a disconnection. A reconnection
49 // will be attempted. May be called multiple times in a row.
50 virtual void OnDisconnect() = 0; 50 virtual void OnDisconnect() = 0;
51 51
52 // Called when our credentials have been rejected. Will not try
53 // to reconnect after this (although the client may still call
54 // StartConnection(), perhaps after calling UpdateXmppSettings()).
55 virtual void OnRejectedCredentials() = 0;
56
52 protected: 57 protected:
53 virtual ~Delegate() {} 58 virtual ~Delegate();
54 }; 59 };
55 60
56 // Does not take ownership of |delegate|, which must not be NULL. 61 // Does not take ownership of |delegate|, which must not be NULL.
57 Login(Delegate* delegate, 62 Login(Delegate* delegate,
58 const buzz::XmppClientSettings& user_settings, 63 const buzz::XmppClientSettings& user_settings,
59 const scoped_refptr<net::URLRequestContextGetter>& 64 const scoped_refptr<net::URLRequestContextGetter>&
60 request_context_getter, 65 request_context_getter,
61 const ServerList& servers, 66 const ServerList& servers,
62 bool try_ssltcp_first, 67 bool try_ssltcp_first,
63 const std::string& auth_mechanism); 68 const std::string& auth_mechanism);
64 virtual ~Login(); 69 virtual ~Login();
65 70
71 // Starts connecting (or forces a reconnection if we're backed off).
66 void StartConnection(); 72 void StartConnection();
67 // The updated settings only take effect the next time StartConnection 73
68 // is called. 74 // The updated settings take effect only the next time when a
75 // connection is attempted (either via reconnection or a call to
76 // StartConnection()).
69 void UpdateXmppSettings(const buzz::XmppClientSettings& user_settings); 77 void UpdateXmppSettings(const buzz::XmppClientSettings& user_settings);
70 78
71 // net::NetworkChangeNotifier::IPAddressObserver implementation. 79 // net::NetworkChangeNotifier::IPAddressObserver implementation.
72 virtual void OnIPAddressChanged() OVERRIDE; 80 virtual void OnIPAddressChanged() OVERRIDE;
73 81
74 // SingleLoginAttempt::Delegate implementation. 82 // SingleLoginAttempt::Delegate implementation.
75 virtual void OnConnect( 83 virtual void OnConnect(
76 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) OVERRIDE; 84 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) OVERRIDE;
77 virtual void OnNeedReconnect() OVERRIDE; 85 virtual void OnNeedReconnect() OVERRIDE;
78 virtual void OnRedirect(const ServerInformation& redirect_server) OVERRIDE; 86 virtual void OnRedirect(const ServerInformation& redirect_server) OVERRIDE;
87 virtual void OnRejectedCredentials() OVERRIDE;
79 88
80 private: 89 private:
81 void OnLogoff(); 90 void OnLogoff();
82 91
83 // Stops any existing reconnect timer and sets an initial reconnect 92 // Stops any existing reconnect timer and sets an initial reconnect
84 // interval. 93 // interval.
85 void ResetReconnectState(); 94 void ResetReconnectState();
86 95
87 // Tries to reconnect in some point in the future. If called 96 // Tries to reconnect in some point in the future. If called
88 // repeatedly, will wait longer and longer until reconnecting. 97 // repeatedly, will wait longer and longer until reconnecting.
89 void TryReconnect(); 98 void TryReconnect();
90 99
91 // The actual function (called by |reconnect_timer_|) that does the 100 // The actual function (called by |reconnect_timer_|) that does the
92 // reconnection. 101 // reconnection.
93 void DoReconnect(); 102 void DoReconnect();
94 103
95 Delegate* const delegate_; 104 Delegate* const delegate_;
96 LoginSettings login_settings_; 105 LoginSettings login_settings_;
97 scoped_ptr<SingleLoginAttempt> single_attempt_; 106 scoped_ptr<SingleLoginAttempt> single_attempt_;
98 107
99 // reconnection state. 108 // reconnection state.
100 base::TimeDelta reconnect_interval_; 109 base::TimeDelta reconnect_interval_;
101 base::OneShotTimer<Login> reconnect_timer_; 110 base::OneShotTimer<Login> reconnect_timer_;
102 111
103 DISALLOW_COPY_AND_ASSIGN(Login); 112 DISALLOW_COPY_AND_ASSIGN(Login);
104 }; 113 };
105 114
106 // Workaround for MSVS 2005 bug that fails to handle inheritance from a nested
107 // class properly if it comes directly on a base class list.
108 typedef Login::Delegate LoginDelegate;
109
110 } // namespace notifier 115 } // namespace notifier
111 116
112 #endif // JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_H_ 117 #endif // JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698