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

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

Issue 282063005: Pull out common code from client and host versions of ServerLogEntry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move ServerLogEntry to jingle_glue Created 6 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
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/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringize_macros.h" 13 #include "base/strings/stringize_macros.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "remoting/base/constants.h" 15 #include "remoting/base/constants.h"
16 #include "remoting/base/logging.h" 16 #include "remoting/base/logging.h"
17 #include "remoting/host/server_log_entry.h" 17 #include "remoting/host/server_log_entry_host.h"
18 #include "remoting/jingle_glue/iq_sender.h" 18 #include "remoting/jingle_glue/iq_sender.h"
19 #include "remoting/jingle_glue/server_log_entry.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 {
27 28
28 namespace { 29 namespace {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 heartbeat->AddAttr(QName(kChromotingXmlNamespace, kSequenceIdAttr), 249 heartbeat->AddAttr(QName(kChromotingXmlNamespace, kSequenceIdAttr),
249 base::IntToString(sequence_id_)); 250 base::IntToString(sequence_id_));
250 heartbeat->AddElement(CreateSignature().release()); 251 heartbeat->AddElement(CreateSignature().release());
251 // Append host version. 252 // Append host version.
252 scoped_ptr<XmlElement> version_tag(new XmlElement( 253 scoped_ptr<XmlElement> version_tag(new XmlElement(
253 QName(kChromotingXmlNamespace, kHostVersionTag))); 254 QName(kChromotingXmlNamespace, kHostVersionTag)));
254 version_tag->AddText(STRINGIZE(VERSION)); 255 version_tag->AddText(STRINGIZE(VERSION));
255 heartbeat->AddElement(version_tag.release()); 256 heartbeat->AddElement(version_tag.release());
256 // Append log message (which isn't signed). 257 // Append log message (which isn't signed).
257 scoped_ptr<XmlElement> log(ServerLogEntry::MakeStanza()); 258 scoped_ptr<XmlElement> log(ServerLogEntry::MakeStanza());
258 scoped_ptr<ServerLogEntry> log_entry(ServerLogEntry::MakeForHeartbeat()); 259 scoped_ptr<ServerLogEntry> log_entry(MakeLogEntryForHeartbeat());
259 log_entry->AddHostFields(); 260 AddHostFieldsToLogEntry(log_entry.get());
260 log->AddElement(log_entry->ToStanza().release()); 261 log->AddElement(log_entry->ToStanza().release());
261 heartbeat->AddElement(log.release()); 262 heartbeat->AddElement(log.release());
262 return heartbeat.Pass(); 263 return heartbeat.Pass();
263 } 264 }
264 265
265 scoped_ptr<XmlElement> HeartbeatSender::CreateSignature() { 266 scoped_ptr<XmlElement> HeartbeatSender::CreateSignature() {
266 scoped_ptr<XmlElement> signature_tag(new XmlElement( 267 scoped_ptr<XmlElement> signature_tag(new XmlElement(
267 QName(kChromotingXmlNamespace, kHeartbeatSignatureTag))); 268 QName(kChromotingXmlNamespace, kHeartbeatSignatureTag)));
268 269
269 std::string message = signal_strategy_->GetLocalJid() + ' ' + 270 std::string message = signal_strategy_->GetLocalJid() + ' ' +
270 base::IntToString(sequence_id_); 271 base::IntToString(sequence_id_);
271 std::string signature(key_pair_->SignMessage(message)); 272 std::string signature(key_pair_->SignMessage(message));
272 signature_tag->AddText(signature); 273 signature_tag->AddText(signature);
273 274
274 return signature_tag.Pass(); 275 return signature_tag.Pass();
275 } 276 }
276 277
277 } // namespace remoting 278 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/server_log_entry_client_unittest.cc ('k') | remoting/host/host_status_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698