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

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

Issue 10409017: [Chromoting] Add platform data to heartbeats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/host/log_to_server.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 #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/time.h" 14 #include "base/time.h"
15 #include "remoting/base/constants.h" 15 #include "remoting/base/constants.h"
16 #include "remoting/host/constants.h" 16 #include "remoting/host/constants.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/jingle_thread.h" 19 #include "remoting/jingle_glue/jingle_thread.h"
19 #include "remoting/jingle_glue/signal_strategy.h" 20 #include "remoting/jingle_glue/signal_strategy.h"
20 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 21 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
21 #include "third_party/libjingle/source/talk/xmpp/constants.h" 22 #include "third_party/libjingle/source/talk/xmpp/constants.h"
22 23
23 using buzz::QName; 24 using buzz::QName;
24 using buzz::XmlElement; 25 using buzz::XmlElement;
25 26
26 namespace remoting { 27 namespace remoting {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 (1 + base::RandDouble()) * kResendDelayMs; 223 (1 + base::RandDouble()) * kResendDelayMs;
223 if (delay <= interval_ms_) { 224 if (delay <= interval_ms_) {
224 timer_resend_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay), 225 timer_resend_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay),
225 this, &HeartbeatSender::ResendStanza); 226 this, &HeartbeatSender::ResendStanza);
226 } 227 }
227 } 228 }
228 sequence_id_was_set_ = true; 229 sequence_id_was_set_ = true;
229 } 230 }
230 231
231 scoped_ptr<XmlElement> HeartbeatSender::CreateHeartbeatMessage() { 232 scoped_ptr<XmlElement> HeartbeatSender::CreateHeartbeatMessage() {
233 // Create heartbeat stanza.
232 scoped_ptr<XmlElement> query(new XmlElement( 234 scoped_ptr<XmlElement> query(new XmlElement(
233 QName(kChromotingXmlNamespace, kHeartbeatQueryTag))); 235 QName(kChromotingXmlNamespace, kHeartbeatQueryTag)));
234 query->AddAttr(QName(kChromotingXmlNamespace, kHostIdAttr), host_id_); 236 query->AddAttr(QName(kChromotingXmlNamespace, kHostIdAttr), host_id_);
235 query->AddAttr(QName(kChromotingXmlNamespace, kSequenceIdAttr), 237 query->AddAttr(QName(kChromotingXmlNamespace, kSequenceIdAttr),
236 base::IntToString(sequence_id_)); 238 base::IntToString(sequence_id_));
237 query->AddElement(CreateSignature().release()); 239 query->AddElement(CreateSignature().release());
240 // Append log message (which isn't signed).
241 scoped_ptr<XmlElement> log(ServerLogEntry::MakeStanza());
242 scoped_ptr<ServerLogEntry> log_entry(ServerLogEntry::MakeForHeartbeat());
243 log_entry->AddHostFields();
244 log->AddElement(log_entry->ToStanza().release());
245 query->AddElement(log.release());
238 return query.Pass(); 246 return query.Pass();
239 } 247 }
240 248
241 scoped_ptr<XmlElement> HeartbeatSender::CreateSignature() { 249 scoped_ptr<XmlElement> HeartbeatSender::CreateSignature() {
242 scoped_ptr<XmlElement> signature_tag(new XmlElement( 250 scoped_ptr<XmlElement> signature_tag(new XmlElement(
243 QName(kChromotingXmlNamespace, kHeartbeatSignatureTag))); 251 QName(kChromotingXmlNamespace, kHeartbeatSignatureTag)));
244 252
245 std::string message = signal_strategy_->GetLocalJid() + ' ' + 253 std::string message = signal_strategy_->GetLocalJid() + ' ' +
246 base::IntToString(sequence_id_); 254 base::IntToString(sequence_id_);
247 std::string signature(key_pair_->GetSignature(message)); 255 std::string signature(key_pair_->GetSignature(message));
248 signature_tag->AddText(signature); 256 signature_tag->AddText(signature);
249 257
250 return signature_tag.Pass(); 258 return signature_tag.Pass();
251 } 259 }
252 260
253 } // namespace remoting 261 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/log_to_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698