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

Side by Side Diff: remoting/host/heartbeat_sender.h

Issue 10106013: Chromoting: stopping the service if the host ID is permanently not recognized by the could. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feeback. Rebased. Created 8 years, 8 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
« no previous file with comments | « remoting/host/constants.h ('k') | remoting/host/heartbeat_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_HOST_HEARTBEAT_SENDER_H_ 5 #ifndef REMOTING_HOST_HEARTBEAT_SENDER_H_
6 #define REMOTING_HOST_HEARTBEAT_SENDER_H_ 6 #define REMOTING_HOST_HEARTBEAT_SENDER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // stanza of this form: 72 // stanza of this form:
73 // 73 //
74 // <iq type="set" from="remoting@bot.talk.google.com" 74 // <iq type="set" from="remoting@bot.talk.google.com"
75 // to="user@gmail.com/chromoting123123" id="5" xmlns="jabber:client"> 75 // to="user@gmail.com/chromoting123123" id="5" xmlns="jabber:client">
76 // <rem:heartbeat-result xmlns:rem="google:remoting"> 76 // <rem:heartbeat-result xmlns:rem="google:remoting">
77 // <rem:expected-sequence-id>654</rem:expected-sequence-id> 77 // <rem:expected-sequence-id>654</rem:expected-sequence-id>
78 // </rem:heartbeat-result> 78 // </rem:heartbeat-result>
79 // </iq> 79 // </iq>
80 class HeartbeatSender : public SignalStrategy::Listener { 80 class HeartbeatSender : public SignalStrategy::Listener {
81 public: 81 public:
82 // |signal_strategy| and |key_pair| must outlive this 82 class Listener {
83 public:
84 virtual ~Listener() { }
85 // Invoked when the host ID is permanently not recognized by the server.
86 virtual void OnUnknownHostIdError() = 0;
87 };
88
89 // |signal_strategy|, |key_pair| and |delegate| must outlive this
83 // object. Heartbeats will start when the supplied SignalStrategy 90 // object. Heartbeats will start when the supplied SignalStrategy
84 // enters the CONNECTED state. 91 // enters the CONNECTED state.
85 HeartbeatSender(const std::string& host_id, 92 HeartbeatSender(Listener* listener,
93 const std::string& host_id,
86 SignalStrategy* signal_strategy, 94 SignalStrategy* signal_strategy,
87 HostKeyPair* key_pair); 95 HostKeyPair* key_pair);
88 virtual ~HeartbeatSender(); 96 virtual ~HeartbeatSender();
89 97
90 // SignalStrategy::Listener interface. 98 // SignalStrategy::Listener interface.
91 virtual void OnSignalStrategyStateChange( 99 virtual void OnSignalStrategyStateChange(
92 SignalStrategy::State state) OVERRIDE; 100 SignalStrategy::State state) OVERRIDE;
93 101
94 private: 102 private:
95 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, DoSendStanza); 103 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, DoSendStanza);
96 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, 104 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest,
97 DoSendStanzaWithExpectedSequenceId); 105 DoSendStanzaWithExpectedSequenceId);
98 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, CreateHeartbeatMessage); 106 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, CreateHeartbeatMessage);
99 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, ProcessResponseSetInterval); 107 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, ProcessResponseSetInterval);
100 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, 108 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest,
101 ProcessResponseExpectedSequenceId); 109 ProcessResponseExpectedSequenceId);
102 110
103 void SendStanza(); 111 void SendStanza();
104 void ResendStanza(); 112 void ResendStanza();
105 void DoSendStanza(); 113 void DoSendStanza();
106 void ProcessResponse(IqRequest* request, const buzz::XmlElement* response); 114 void ProcessResponse(IqRequest* request, const buzz::XmlElement* response);
107 void SetInterval(int interval); 115 void SetInterval(int interval);
108 void SetSequenceId(int sequence_id); 116 void SetSequenceId(int sequence_id);
109 117
110 // Helper methods used by DoSendStanza() to generate heartbeat stanzas. 118 // Helper methods used by DoSendStanza() to generate heartbeat stanzas.
111 scoped_ptr<buzz::XmlElement> CreateHeartbeatMessage(); 119 scoped_ptr<buzz::XmlElement> CreateHeartbeatMessage();
112 scoped_ptr<buzz::XmlElement> CreateSignature(); 120 scoped_ptr<buzz::XmlElement> CreateSignature();
113 121
122 Listener* listener_;
114 std::string host_id_; 123 std::string host_id_;
115 SignalStrategy* signal_strategy_; 124 SignalStrategy* signal_strategy_;
116 HostKeyPair* key_pair_; 125 HostKeyPair* key_pair_;
117 scoped_ptr<IqSender> iq_sender_; 126 scoped_ptr<IqSender> iq_sender_;
118 scoped_ptr<IqRequest> request_; 127 scoped_ptr<IqRequest> request_;
119 int interval_ms_; 128 int interval_ms_;
120 base::RepeatingTimer<HeartbeatSender> timer_; 129 base::RepeatingTimer<HeartbeatSender> timer_;
121 base::OneShotTimer<HeartbeatSender> timer_resend_; 130 base::OneShotTimer<HeartbeatSender> timer_resend_;
122 int sequence_id_; 131 int sequence_id_;
123 bool sequence_id_was_set_; 132 bool sequence_id_was_set_;
124 int sequence_id_recent_set_num_; 133 int sequence_id_recent_set_num_;
125 bool heartbeat_succeeded_; 134 bool heartbeat_succeeded_;
126 int failed_startup_heartbeat_count_; 135 int failed_startup_heartbeat_count_;
127 136
128 DISALLOW_COPY_AND_ASSIGN(HeartbeatSender); 137 DISALLOW_COPY_AND_ASSIGN(HeartbeatSender);
129 }; 138 };
130 139
131 } // namespace remoting 140 } // namespace remoting
132 141
133 #endif // REMOTING_HOST_HEARTBEAT_SENDER_H_ 142 #endif // REMOTING_HOST_HEARTBEAT_SENDER_H_
OLDNEW
« no previous file with comments | « remoting/host/constants.h ('k') | remoting/host/heartbeat_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698