1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_ 6 #define REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_ 7 8 #include <map> 9 #include <string> 10 11 #include "base/memory/scoped_ptr.h" 12 13 namespace buzz { 14 class XmlElement; 15 } // namespace buzz 16 17 namespace remoting { 18 19 // Utility class for building log entries to send to the remoting bot. This is 20 // a wrapper around a key/value map and is copyable so it can be used in STL 21 // containers. 22 class ServerLogEntry { 23 public: 24 // The mode of a connection. 25 enum Mode { 26 IT2ME, 27 ME2ME 28 }; 29 30 ServerLogEntry(); 31 ~ServerLogEntry(); 32 33 // Sets an arbitrary key/value entry. 34 void Set(const std::string& key, const std::string& value); 35 36 // Adds a field describing the CPU type of the platform. 37 void AddCpuField(); 38 39 // Adds a field describing the mode of a connection to this log entry. 40 void AddModeField(Mode mode); 41 42 // Adds a field describing the role (client/host). 43 void AddRoleField(const char* role); 44 45 // Adds a field describing the type of log entry. 46 void AddEventNameField(const char* name); 47 48 // Constructs a log stanza. The caller should add one or more log entry 49 // stanzas as children of this stanza, before sending the log stanza to 50 // the remoting bot. 51 static scoped_ptr<buzz::XmlElement> MakeStanza(); 52 53 // Converts this object to an XML stanza. 54 scoped_ptr<buzz::XmlElement> ToStanza() const; 55 56 private: 57 typedef std::map<std::string, std::string> ValuesMap; 58 59 ValuesMap values_map_; 60 }; 61 62 } // namespace remoting 63 64 #endif // REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_ 65