| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_HOST_SERVER_LOG_ENTRY_H_ | |
| 6 #define REMOTING_HOST_SERVER_LOG_ENTRY_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "remoting/host/host_exit_codes.h" | |
| 13 #include "remoting/host/host_status_sender.h" | |
| 14 #include "remoting/protocol/transport.h" | |
| 15 | |
| 16 namespace buzz { | |
| 17 class XmlElement; | |
| 18 } // namespace buzz | |
| 19 | |
| 20 namespace remoting { | |
| 21 | |
| 22 class ServerLogEntry { | |
| 23 public: | |
| 24 // The mode of a connection. | |
| 25 enum Mode { | |
| 26 IT2ME, | |
| 27 ME2ME | |
| 28 }; | |
| 29 | |
| 30 // Constructs a log stanza. The caller should add one or more log entry | |
| 31 // stanzas as children of this stanza, before sending the log stanza to | |
| 32 // the remoting bot. | |
| 33 static scoped_ptr<buzz::XmlElement> MakeStanza(); | |
| 34 | |
| 35 // Constructs a log entry for a session state change. | |
| 36 // Currently this is either connection or disconnection. | |
| 37 static scoped_ptr<ServerLogEntry> MakeForSessionStateChange(bool connection); | |
| 38 | |
| 39 // Constructs a log entry for a heartbeat. | |
| 40 static scoped_ptr<ServerLogEntry> MakeForHeartbeat(); | |
| 41 | |
| 42 // Constructs a log entry for a host status message. | |
| 43 static scoped_ptr<ServerLogEntry> MakeForHostStatus( | |
| 44 HostStatusSender::HostStatus host_status, HostExitCodes exit_code); | |
| 45 | |
| 46 ~ServerLogEntry(); | |
| 47 | |
| 48 // Adds fields describing the host to this log entry. | |
| 49 void AddHostFields(); | |
| 50 | |
| 51 // Adds a field describing the mode of a connection to this log entry. | |
| 52 void AddModeField(Mode mode); | |
| 53 | |
| 54 // Adds a field describing connection type (direct/stun/relay). | |
| 55 void AddConnectionTypeField(protocol::TransportRoute::RouteType type); | |
| 56 | |
| 57 // Converts this object to an XML stanza. | |
| 58 scoped_ptr<buzz::XmlElement> ToStanza() const; | |
| 59 | |
| 60 private: | |
| 61 typedef std::map<std::string, std::string> ValuesMap; | |
| 62 | |
| 63 ServerLogEntry(); | |
| 64 void Set(const std::string& key, const std::string& value); | |
| 65 | |
| 66 static const char* GetValueSessionState(bool connected); | |
| 67 static const char* GetValueMode(Mode mode); | |
| 68 | |
| 69 ValuesMap values_map_; | |
| 70 }; | |
| 71 | |
| 72 } // namespace remoting | |
| 73 | |
| 74 #endif | |
| OLD | NEW |