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

Side by Side Diff: remoting/host/host_status_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: 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/host_status_sender.h" 5 #include "remoting/host/host_status_sender.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringize_macros.h" 8 #include "base/strings/stringize_macros.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
11 #include "remoting/base/logging.h" 11 #include "remoting/base/logging.h"
12 #include "remoting/host/server_log_entry.h" 12 #include "remoting/host/server_log_entry_host.h"
13 #include "remoting/jingle_glue/iq_sender.h" 13 #include "remoting/jingle_glue/iq_sender.h"
14 #include "remoting/jingle_glue/signal_strategy.h" 14 #include "remoting/jingle_glue/signal_strategy.h"
15 #include "remoting/protocol/server_log_entry.h"
15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
16 #include "third_party/libjingle/source/talk/xmpp/constants.h" 17 #include "third_party/libjingle/source/talk/xmpp/constants.h"
17 18
18 using buzz::QName; 19 using buzz::QName;
19 using buzz::XmlElement; 20 using buzz::XmlElement;
21 using remoting::protocol::ServerLogEntry;
20 22
21 namespace remoting { 23 namespace remoting {
22 24
23 namespace { 25 namespace {
24 26
25 const char kHostStatusTag[] = "host-status"; 27 const char kHostStatusTag[] = "host-status";
26 const char kHostIdAttr[] = "hostid"; 28 const char kHostIdAttr[] = "hostid";
27 const char kExitCodeAttr[] = "exit-code"; 29 const char kExitCodeAttr[] = "exit-code";
28 const char kHostVersionTag[] = "host-version"; 30 const char kHostVersionTag[] = "host-version";
29 const char kSignatureTag[] = "signature"; 31 const char kSignatureTag[] = "signature";
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 118
117 // Append host version. 119 // Append host version.
118 scoped_ptr<XmlElement> version_tag(new XmlElement( 120 scoped_ptr<XmlElement> version_tag(new XmlElement(
119 QName(kChromotingXmlNamespace, kHostVersionTag))); 121 QName(kChromotingXmlNamespace, kHostVersionTag)));
120 version_tag->AddText(STRINGIZE(VERSION)); 122 version_tag->AddText(STRINGIZE(VERSION));
121 host_status->AddElement(version_tag.release()); 123 host_status->AddElement(version_tag.release());
122 124
123 // Append log message (which isn't signed). 125 // Append log message (which isn't signed).
124 scoped_ptr<XmlElement> log(ServerLogEntry::MakeStanza()); 126 scoped_ptr<XmlElement> log(ServerLogEntry::MakeStanza());
125 scoped_ptr<ServerLogEntry> log_entry( 127 scoped_ptr<ServerLogEntry> log_entry(
126 ServerLogEntry::MakeForHostStatus(status, exit_code)); 128 MakeLogEntryForHostStatus(status, exit_code));
127 log_entry->AddHostFields(); 129 AddHostFieldsToLogEntry(log_entry.get());
128 log->AddElement(log_entry->ToStanza().release()); 130 log->AddElement(log_entry->ToStanza().release());
129 host_status->AddElement(log.release()); 131 host_status->AddElement(log.release());
130 return host_status.Pass(); 132 return host_status.Pass();
131 } 133 }
132 134
133 scoped_ptr<XmlElement> HostStatusSender::CreateSignature( 135 scoped_ptr<XmlElement> HostStatusSender::CreateSignature(
134 HostStatus status, HostExitCodes exit_code) { 136 HostStatus status, HostExitCodes exit_code) {
135 scoped_ptr<XmlElement> signature_tag(new XmlElement( 137 scoped_ptr<XmlElement> signature_tag(new XmlElement(
136 QName(kChromotingXmlNamespace, kSignatureTag))); 138 QName(kChromotingXmlNamespace, kSignatureTag)));
137 139
(...skipping 15 matching lines...) Expand all
153 if (status == OFFLINE) 155 if (status == OFFLINE)
154 message += std::string(" ") + ExitCodeToString(exit_code); 156 message += std::string(" ") + ExitCodeToString(exit_code);
155 157
156 std::string signature(key_pair_->SignMessage(message)); 158 std::string signature(key_pair_->SignMessage(message));
157 signature_tag->AddText(signature); 159 signature_tag->AddText(signature);
158 160
159 return signature_tag.Pass(); 161 return signature_tag.Pass();
160 } 162 }
161 163
162 } // namespace remoting 164 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698