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

Side by Side Diff: chrome/browser/sync/notifier/communicator/single_login_attempt.h

Issue 1956001: Moved XMPP notifier library from chrome/browser/sync to chrome/common.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_
6 #define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_
7
8 #include <string>
9
10 #include "chrome/browser/sync/notifier/communicator/login.h"
11 #include "talk/base/scoped_ptr.h"
12 #include "talk/base/sigslot.h"
13 #include "talk/base/task.h"
14 #include "talk/xmpp/xmppengine.h"
15
16 namespace buzz {
17 class AsyncSocket;
18 class SaslHandler;
19 class XmppClient;
20 class XmppClientSettings;
21 class XmppClientSettings;
22 }
23
24 namespace talk_base {
25 class FirewallManager;
26 struct ProxyInfo;
27 class SignalThread;
28 class Task;
29 }
30
31 namespace notifier {
32
33 class ConnectionSettings;
34 class LoginFailure;
35 class LoginSettings;
36 struct ServerInformation;
37 class XmppConnectionGenerator;
38
39 // Handles all of the aspects of a single login attempt (across multiple ip
40 // addresses) and maintainence. By containing this within one class, when
41 // another login attempt is made, this class will be disposed and all of the
42 // signalling for the previous login attempt will be cleaned up immediately.
43 //
44 // This is a task to allow for cleaning this up when a signal is being fired.
45 // Technically, delete this during the firing of a signal could work but it is
46 // fragile.
47 class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> {
48 public:
49 SingleLoginAttempt(talk_base::Task* parent,
50 LoginSettings* login_settings,
51 bool successful_connection);
52 ~SingleLoginAttempt();
53 virtual int ProcessStart();
54 void UseNextConnection();
55 void UseCurrentConnection();
56
57 buzz::XmppClient* xmpp_client() {
58 return client_;
59 }
60
61 // Returns the proxy that is being used to connect (or the default proxy
62 // information if all attempted connections failed).
63 const talk_base::ProxyInfo& proxy() const;
64
65 // Typically handled by creating a new SingleLoginAttempt and doing
66 // StartConnection.
67 sigslot::signal0<> SignalUnexpectedDisconnect;
68
69 // Typically handled by storing the redirect for 5 seconds, and setting it
70 // into LoginSettings, then creating a new SingleLoginAttempt, and doing
71 // StartConnection.
72 //
73 // SignalRedirect(const std::string& redirect_server, int redirect_port);
74 sigslot::signal2<const std::string&, int> SignalRedirect;
75
76 sigslot::signal0<> SignalNeedAutoReconnect;
77
78 // SignalClientStateChange(buzz::XmppEngine::State new_state);
79 sigslot::signal1<buzz::XmppEngine::State> SignalClientStateChange;
80
81 // See the LoginFailure for how to handle this.
82 sigslot::signal1<const LoginFailure&> SignalLoginFailure;
83
84 // Sent when there is a graceful log-off (state goes to closed with no
85 // error).
86 sigslot::signal0<> SignalLogoff;
87
88 sigslot::repeater2<const char*, int> SignalLogInput;
89 sigslot::repeater2<const char*, int> SignalLogOutput;
90
91 protected:
92 virtual void Stop();
93
94 private:
95 void DoLogin(const ConnectionSettings& connection_settings);
96 buzz::AsyncSocket* CreateSocket(const buzz::XmppClientSettings& xcs);
97 static buzz::SaslHandler* CreateSaslHandler(
98 const buzz::XmppClientSettings& xcs);
99
100 // Cleans up any xmpp client state to get ready for a new one.
101 void ClearClient();
102
103 void HandleConnectionError(
104 buzz::XmppEngine::Error code,
105 int subcode,
106 const buzz::XmlElement* stream_error);
107 void HandleConnectionPasswordError();
108
109 void DiagnoseConnectionError();
110 void OnHttpTestDone(talk_base::SignalThread* thread);
111
112 void OnAuthenticationError();
113 void OnCertificateExpired();
114 void OnFreshAuthCookie(const std::string& auth_cookie);
115 void OnClientStateChange(buzz::XmppEngine::State state);
116 void OnClientStateChangeClosed(buzz::XmppEngine::State previous_state);
117 void OnAttemptedAllConnections(bool successfully_resolved_dns,
118 int first_dns_error);
119
120 bool auto_reconnect() const;
121
122 buzz::XmppEngine::State state_;
123 buzz::XmppEngine::Error code_;
124 int subcode_;
125 bool need_authentication_;
126 bool certificate_expired_;
127 bool cookie_refreshed_;
128 bool successful_connection_;
129 LoginSettings* login_settings_;
130 buzz::XmppClient* client_;
131 scoped_ptr<XmppConnectionGenerator> connection_generator_;
132
133 DISALLOW_COPY_AND_ASSIGN(SingleLoginAttempt);
134 };
135
136 } // namespace notifier
137
138 #endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698