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

Side by Side Diff: remoting/jingle_glue/signal_strategy.h

Issue 10378110: Verify that xmpp_login specified in the config matches auth token. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
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 REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ 5 #ifndef REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_
6 #define REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ 6 #define REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 12 matching lines...) Expand all
23 CONNECTING, 23 CONNECTING,
24 24
25 // Signalling is connected. 25 // Signalling is connected.
26 CONNECTED, 26 CONNECTED,
27 27
28 // Connection is closed due to an error or because Disconnect() 28 // Connection is closed due to an error or because Disconnect()
29 // was called. 29 // was called.
30 DISCONNECTED, 30 DISCONNECTED,
31 }; 31 };
32 32
33 enum Error {
34 NO_ERROR,
35 AUTHENTICATION_FAILED,
36 NETWORK_ERROR,
37 };
38
33 // Callback interface for signaling event. Event handlers are not 39 // Callback interface for signaling event. Event handlers are not
34 // allowed to destroy SignalStrategy, but may add or remove other 40 // allowed to destroy SignalStrategy, but may add or remove other
35 // listeners. 41 // listeners.
36 class Listener { 42 class Listener {
37 public: 43 public:
38 virtual ~Listener() {} 44 virtual ~Listener() {}
39 45
40 // Called after state of the connection has changed. 46 // Called after state of the connection has changed. |error| is
47 // specified state is set to DISCONNECTED.
simonmorris 2012/05/11 19:57:25 There's no |error| now. Maybe something like "If t
Sergey Ulanov 2012/05/11 20:48:05 Done.
41 virtual void OnSignalStrategyStateChange(State state) {} 48 virtual void OnSignalStrategyStateChange(State state) {}
42 49
43 // Must return true if the stanza was handled, false 50 // Must return true if the stanza was handled, false
44 // otherwise. The signal strategy must not be deleted from a 51 // otherwise. The signal strategy must not be deleted from a
45 // handler of this message. 52 // handler of this message.
46 virtual bool OnSignalStrategyIncomingStanza( 53 virtual bool OnSignalStrategyIncomingStanza(
47 const buzz::XmlElement* stanza) { return false; } 54 const buzz::XmlElement* stanza) { return false; }
48 }; 55 };
49 56
50 SignalStrategy() {} 57 SignalStrategy() {}
51 virtual ~SignalStrategy() {} 58 virtual ~SignalStrategy() {}
52 59
53 // Starts connection attempt. If connection is currently active 60 // Starts connection attempt. If connection is currently active
54 // disconnects it and opens a new connection (implicit disconnect 61 // disconnects it and opens a new connection (implicit disconnect
55 // triggers CLOSED notification). Connection is finished 62 // triggers CLOSED notification). Connection is finished
56 // asynchronously. 63 // asynchronously.
57 virtual void Connect() = 0; 64 virtual void Connect() = 0;
58 65
59 // Disconnects current connection if connected. Triggers CLOSED 66 // Disconnects current connection if connected. Triggers CLOSED
60 // notification. 67 // notification.
61 virtual void Disconnect() = 0; 68 virtual void Disconnect() = 0;
62 69
63 // Returns current state. 70 // Returns current state.
64 virtual State GetState() const = 0; 71 virtual State GetState() const = 0;
65 72
73 // Returns the last error. Set when state changes to DISCONNECT.
74 virtual Error GetError() const = 0;
75
66 // Returns local JID or an empty string when not connected. 76 // Returns local JID or an empty string when not connected.
67 virtual std::string GetLocalJid() const = 0; 77 virtual std::string GetLocalJid() const = 0;
68 78
69 // Add a |listener| that can listen to all incoming 79 // Add a |listener| that can listen to all incoming
70 // messages. Doesn't take ownership of the |listener|. All listeners 80 // messages. Doesn't take ownership of the |listener|. All listeners
71 // must be removed before this object is destroyed. 81 // must be removed before this object is destroyed.
72 virtual void AddListener(Listener* listener) = 0; 82 virtual void AddListener(Listener* listener) = 0;
73 83
74 // Remove a |listener| previously added with AddListener(). 84 // Remove a |listener| previously added with AddListener().
75 virtual void RemoveListener(Listener* listener) = 0; 85 virtual void RemoveListener(Listener* listener) = 0;
76 86
77 // Sends a raw XMPP stanza. 87 // Sends a raw XMPP stanza.
78 virtual bool SendStanza(scoped_ptr<buzz::XmlElement> stanza) = 0; 88 virtual bool SendStanza(scoped_ptr<buzz::XmlElement> stanza) = 0;
79 89
80 // Returns new ID that should be used for the next outgoing IQ 90 // Returns new ID that should be used for the next outgoing IQ
81 // request. 91 // request.
82 virtual std::string GetNextId() = 0; 92 virtual std::string GetNextId() = 0;
83 93
84 private: 94 private:
85 DISALLOW_COPY_AND_ASSIGN(SignalStrategy); 95 DISALLOW_COPY_AND_ASSIGN(SignalStrategy);
86 }; 96 };
87 97
88 } // namespace remoting 98 } // namespace remoting
89 99
90 #endif // REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ 100 #endif // REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698