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

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

Issue 12221123: Include version information in heartbeats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « no previous file | no next file » | 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 #include "remoting/host/heartbeat_sender.h" 5 #include "remoting/host/heartbeat_sender.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/strings/stringize_macros.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "remoting/base/constants.h" 16 #include "remoting/base/constants.h"
16 #include "remoting/host/server_log_entry.h" 17 #include "remoting/host/server_log_entry.h"
17 #include "remoting/jingle_glue/iq_sender.h" 18 #include "remoting/jingle_glue/iq_sender.h"
18 #include "remoting/jingle_glue/signal_strategy.h" 19 #include "remoting/jingle_glue/signal_strategy.h"
19 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 20 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
20 #include "third_party/libjingle/source/talk/xmpp/constants.h" 21 #include "third_party/libjingle/source/talk/xmpp/constants.h"
21 22
22 using buzz::QName; 23 using buzz::QName;
23 using buzz::XmlElement; 24 using buzz::XmlElement;
24 25
25 namespace remoting { 26 namespace remoting {
26 27
27 namespace { 28 namespace {
28 29
29 const char kHeartbeatQueryTag[] = "heartbeat"; 30 const char kHeartbeatQueryTag[] = "heartbeat";
30 const char kHostIdAttr[] = "hostid"; 31 const char kHostIdAttr[] = "hostid";
32 const char kHostVersionAttr[] = "host-version";
31 const char kHeartbeatSignatureTag[] = "signature"; 33 const char kHeartbeatSignatureTag[] = "signature";
32 const char kSequenceIdAttr[] = "sequence-id"; 34 const char kSequenceIdAttr[] = "sequence-id";
33 35
34 const char kErrorTag[] = "error"; 36 const char kErrorTag[] = "error";
35 const char kNotFoundTag[] = "item-not-found"; 37 const char kNotFoundTag[] = "item-not-found";
36 38
37 const char kHeartbeatResultTag[] = "heartbeat-result"; 39 const char kHeartbeatResultTag[] = "heartbeat-result";
38 const char kSetIntervalTag[] = "set-interval"; 40 const char kSetIntervalTag[] = "set-interval";
39 const char kExpectedSequenceIdTag[] = "expected-sequence-id"; 41 const char kExpectedSequenceIdTag[] = "expected-sequence-id";
40 42
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 sequence_id_was_set_ = true; 236 sequence_id_was_set_ = true;
235 } 237 }
236 238
237 scoped_ptr<XmlElement> HeartbeatSender::CreateHeartbeatMessage() { 239 scoped_ptr<XmlElement> HeartbeatSender::CreateHeartbeatMessage() {
238 // Create heartbeat stanza. 240 // Create heartbeat stanza.
239 scoped_ptr<XmlElement> query(new XmlElement( 241 scoped_ptr<XmlElement> query(new XmlElement(
240 QName(kChromotingXmlNamespace, kHeartbeatQueryTag))); 242 QName(kChromotingXmlNamespace, kHeartbeatQueryTag)));
241 query->AddAttr(QName(kChromotingXmlNamespace, kHostIdAttr), host_id_); 243 query->AddAttr(QName(kChromotingXmlNamespace, kHostIdAttr), host_id_);
242 query->AddAttr(QName(kChromotingXmlNamespace, kSequenceIdAttr), 244 query->AddAttr(QName(kChromotingXmlNamespace, kSequenceIdAttr),
243 base::IntToString(sequence_id_)); 245 base::IntToString(sequence_id_));
246 query->AddAttr(QName(kChromotingXmlNamespace, kHostVersionAttr),
Sergey Ulanov 2013/02/11 20:29:11 nit: Does this need to be an attribute? It may be
Jamie 2013/02/11 20:41:25 Either works for me. I'd be interested to know wha
Sergey Ulanov 2013/02/11 21:40:49 There are no hard rules about it, but in general e
Jamie 2013/02/13 18:25:26 Thanks for the summary. Done.
247 STRINGIZE(VERSION));
244 query->AddElement(CreateSignature().release()); 248 query->AddElement(CreateSignature().release());
245 // Append log message (which isn't signed). 249 // Append log message (which isn't signed).
246 scoped_ptr<XmlElement> log(ServerLogEntry::MakeStanza()); 250 scoped_ptr<XmlElement> log(ServerLogEntry::MakeStanza());
Sergey Ulanov 2013/02/11 20:29:11 The log entry should already include information a
Jamie 2013/02/11 20:41:25 Renato suggested that in the bug discussion, but d
Sergey Ulanov 2013/02/11 21:40:49 Yes. I agree. Given that we want to store this inf
Jamie 2013/02/13 18:25:26 So it sounds like you're in favour of the approach
Sergey Ulanov 2013/02/13 18:53:15 Yes, I'm in favor of this approach. Sorry for not
247 scoped_ptr<ServerLogEntry> log_entry(ServerLogEntry::MakeForHeartbeat()); 251 scoped_ptr<ServerLogEntry> log_entry(ServerLogEntry::MakeForHeartbeat());
248 log_entry->AddHostFields(); 252 log_entry->AddHostFields();
249 log->AddElement(log_entry->ToStanza().release()); 253 log->AddElement(log_entry->ToStanza().release());
250 query->AddElement(log.release()); 254 query->AddElement(log.release());
251 return query.Pass(); 255 return query.Pass();
252 } 256 }
253 257
254 scoped_ptr<XmlElement> HeartbeatSender::CreateSignature() { 258 scoped_ptr<XmlElement> HeartbeatSender::CreateSignature() {
255 scoped_ptr<XmlElement> signature_tag(new XmlElement( 259 scoped_ptr<XmlElement> signature_tag(new XmlElement(
256 QName(kChromotingXmlNamespace, kHeartbeatSignatureTag))); 260 QName(kChromotingXmlNamespace, kHeartbeatSignatureTag)));
257 261
258 std::string message = signal_strategy_->GetLocalJid() + ' ' + 262 std::string message = signal_strategy_->GetLocalJid() + ' ' +
259 base::IntToString(sequence_id_); 263 base::IntToString(sequence_id_);
260 std::string signature(key_pair_->GetSignature(message)); 264 std::string signature(key_pair_->GetSignature(message));
261 signature_tag->AddText(signature); 265 signature_tag->AddText(signature);
262 266
263 return signature_tag.Pass(); 267 return signature_tag.Pass();
264 } 268 }
265 269
266 } // namespace remoting 270 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698