Index: remoting/host/heartbeat_sender.h |
diff --git a/remoting/host/heartbeat_sender.h b/remoting/host/heartbeat_sender.h |
index 08665c6451145ec07798f66e45a21eb12843fe9a..686cee9aeab786e282527e8545a08ad666481fca 100644 |
--- a/remoting/host/heartbeat_sender.h |
+++ b/remoting/host/heartbeat_sender.h |
@@ -10,10 +10,12 @@ |
#include "base/scoped_ptr.h" |
#include "base/ref_counted.h" |
#include "remoting/jingle_glue/iq_request.h" |
+#include "testing/gtest/include/gtest/gtest_prod.h" |
namespace remoting { |
class IqRequest; |
+class HostKeyPair; |
class JingleClient; |
class MutableHostConfig; |
@@ -22,21 +24,47 @@ class MutableHostConfig; |
class HeartbeatSender : public base::RefCountedThreadSafe<HeartbeatSender> { |
public: |
HeartbeatSender(); |
+ ~HeartbeatSender(); |
- // Starts heart-beating for |jingle_client|. |
- void Start(MutableHostConfig* config, JingleClient* jingle_client); |
+ // Initializes heart-beating for |jingle_client| with the specified |
+ // config. Returns false if the config is invalid (e.g. private key |
+ // cannot be parsed), true otherwise. |
awong
2010/08/02 19:53:49
Drop the ", true otherwise." It's implied.
Sergey Ulanov
2010/08/03 02:10:39
Done.
|
+ bool Init(MutableHostConfig* config, JingleClient* jingle_client); |
+ |
+ // Starts heart-beating. Must be called after init |
awong
2010/08/02 19:53:49
Period at end of sentence.
Sergey Ulanov
2010/08/03 02:10:39
Done.
|
+ void Start(); |
+ |
+ // Stops heart-beating. Must be called before corresponding JingleClient |
+ // is destroyed otherwise heartbeating would continue indefinitely and |
+ // this object would never be destroyed. Heartbeating cannot be started |
+ // After it has been stopped, new sender must be created instead. |
awong
2010/08/02 19:53:49
What happens if you neglec to call Stop() before d
Sergey Ulanov
2010/08/03 02:10:39
Done.
|
+ void Stop(); |
private: |
+ FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, DoSendStanza); |
+ |
+ enum State { |
+ CREATED, |
+ INITIALIZED, |
+ STARTED, |
+ STOPPED, |
+ }; |
+ |
void DoStart(); |
+ void DoStop(); |
awong
2010/08/02 19:53:49
Been trying to switch us over to a different style
Sergey Ulanov
2010/08/03 02:10:39
Done.
|
void DoSendStanza(); |
+ // Helper method used by DoSendStanza() to sign heartbeat stanzas. |
+ buzz::XmlElement* CreateSignature(const std::string& jid); |
awong
2010/08/02 19:53:49
Who owns the returned XmlElement?
Sergey Ulanov
2010/08/03 02:10:39
Caller. Added comments about it.
|
+ |
void ProcessResponse(const buzz::XmlElement* response); |
- bool started_; |
+ State state_; |
scoped_refptr<MutableHostConfig> config_; |
JingleClient* jingle_client_; |
scoped_ptr<IqRequest> request_; |
std::string host_id_; |
+ scoped_refptr<HostKeyPair> key_pair_; |
}; |
} // namespace remoting |