Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 | 11 |
| 12 namespace buzz { | 12 namespace buzz { |
| 13 class XmlElement; | 13 class XmlElement; |
| 14 } // namespace buzz | 14 } // namespace buzz |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 class SignalStrategy { | 18 class SignalStrategy { |
| 19 public: | 19 public: |
| 20 class StatusObserver { | 20 enum State { |
| 21 public: | 21 // Connection is being established. |
| 22 enum State { | 22 CONNECTING, |
| 23 START, | |
| 24 CONNECTING, | |
| 25 CONNECTED, | |
| 26 CLOSED, | |
| 27 }; | |
| 28 | 23 |
| 29 // Called when state of the connection is changed. | 24 // Signalling is connected. |
| 30 virtual void OnStateChange(State state) = 0; | 25 CONNECTED, |
| 31 virtual void OnJidChange(const std::string& full_jid) = 0; | 26 |
| 27 // Connection is closed due to an error or because Disconnect() | |
| 28 // was called. | |
| 29 CLOSED, | |
|
Wez
2011/12/21 23:35:30
CONNECTED -> DISCONNECTED, or OPEN -> CLOSED
Sergey Ulanov
2011/12/22 21:45:10
Done.
| |
| 32 }; | 30 }; |
| 33 | 31 |
| 34 class Listener { | 32 class Listener { |
| 35 public: | 33 public: |
| 34 virtual ~Listener() {} | |
| 35 | |
| 36 // Called after state of the connection has changed. | |
| 37 virtual void OnSignalStrategyStateChange(State state) = 0; | |
|
Wez
2011/12/21 23:35:30
Is it safe to tear-down the SignallingStrategy fro
Wez
2011/12/21 23:35:30
Consider giving this a default empty implementatio
Sergey Ulanov
2011/12/22 21:45:10
Done.
Sergey Ulanov
2011/12/22 21:45:10
Done.
| |
| 38 | |
| 36 // Must return true if the stanza was handled, false otherwise. | 39 // Must return true if the stanza was handled, false otherwise. |
| 37 virtual bool OnIncomingStanza(const buzz::XmlElement* stanza) = 0; | 40 virtual bool OnSignalStrategyIncomingStanza( |
|
Wez
2011/12/21 23:35:30
Same here?
Sergey Ulanov
2011/12/22 21:45:10
Done.
| |
| 41 const buzz::XmlElement* stanza) = 0; | |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 SignalStrategy() {} | 44 SignalStrategy() {} |
| 41 virtual ~SignalStrategy() {} | 45 virtual ~SignalStrategy() {} |
| 42 virtual void Init(StatusObserver* observer) = 0; | 46 |
| 43 virtual void Close() = 0; | 47 // Starts connection attempt. If connection is currently active |
| 48 // disconnects it and opens a new connection. Connection is finished | |
|
Wez
2011/12/21 23:35:30
Will the implicit disconnect trigger a CLOSED noti
Sergey Ulanov
2011/12/22 21:45:10
Done.
| |
| 49 // asynchronously. | |
| 50 virtual void Connect() = 0; | |
| 51 | |
| 52 // Disconnects current connection. | |
| 53 virtual void Disconnect() = 0; | |
|
Wez
2011/12/21 23:35:30
Will the Listeners see CLOSED notifications?
Sergey Ulanov
2011/12/22 21:45:10
Done.
| |
| 54 | |
| 55 // Returns current state. | |
| 56 virtual State GetState() const = 0; | |
| 57 | |
| 58 // Returns local JID or an empty string when not connected. | |
| 59 virtual std::string GetLocalJid() const = 0; | |
|
Wez
2011/12/21 23:35:30
nit: GetLocalEndpointId? This interface is notion
Sergey Ulanov
2011/12/22 21:45:10
This interface is specific to XMPP signalling mess
| |
| 44 | 60 |
| 45 // Add a |listener| that can listen to all incoming | 61 // Add a |listener| that can listen to all incoming |
| 46 // messages. Doesn't take ownership of the |listener|. | 62 // messages. Doesn't take ownership of the |listener|. |
|
Wez
2011/12/21 23:35:30
Do Listeners need removing before teardown?
Sergey Ulanov
2011/12/22 21:45:10
Done.
| |
| 47 virtual void AddListener(Listener* listener) = 0; | 63 virtual void AddListener(Listener* listener) = 0; |
| 48 | 64 |
| 49 // Remove a |listener| previously added with AddListener(). | 65 // Remove a |listener| previously added with AddListener(). |
| 50 virtual void RemoveListener(Listener* listener) = 0; | 66 virtual void RemoveListener(Listener* listener) = 0; |
| 51 | 67 |
| 52 // Sends a raw XMPP stanza. Takes ownership of the |stanza|. | 68 // Sends a raw XMPP stanza. Takes ownership of the |stanza|. |
| 53 virtual bool SendStanza(buzz::XmlElement* stanza) = 0; | 69 virtual bool SendStanza(buzz::XmlElement* stanza) = 0; |
| 54 | 70 |
| 55 // Returns new ID that should be used for the next outgoing IQ | 71 // Returns new ID that should be used for the next outgoing IQ |
| 56 // request. | 72 // request. |
| 57 virtual std::string GetNextId() = 0; | 73 virtual std::string GetNextId() = 0; |
| 58 | 74 |
| 59 private: | 75 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(SignalStrategy); | 76 DISALLOW_COPY_AND_ASSIGN(SignalStrategy); |
| 61 }; | 77 }; |
| 62 | 78 |
| 63 } // namespace remoting | 79 } // namespace remoting |
| 64 | 80 |
| 65 #endif // REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ | 81 #endif // REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ |
| OLD | NEW |