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.
5 #ifndef REMOTING_CLIENT_SERVER_LOG_ENTRY_H_
6 #define REMOTING_CLIENT_SERVER_LOG_ENTRY_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/time/time.h"
13 #include "remoting/protocol/connection_to_host.h"
14 #include "remoting/protocol/errors.h"
22 class ChromotingStats;
24 // Temporary namespace to prevent conflict with the same-named class in
25 // remoting/host when linking unittests.
27 // TODO(lambroslambrou): Remove this and factor out any shared code.
30 class ServerLogEntry {
32 // The mode of a connection.
38 // Constructs a log stanza. The caller should add one or more log entry
39 // stanzas as children of this stanza, before sending the log stanza to
41 static scoped_ptr<buzz::XmlElement> MakeStanza();
43 // Constructs a log entry for a session state change.
44 static scoped_ptr<ServerLogEntry> MakeForSessionStateChange(
45 remoting::protocol::ConnectionToHost::State state,
46 remoting::protocol::ErrorCode error);
48 // Constructs a log entry for reporting statistics.
49 static scoped_ptr<ServerLogEntry> MakeForStatistics(
50 remoting::ChromotingStats* statistics);
52 // Constructs a log entry for reporting session ID is old.
53 static scoped_ptr<ServerLogEntry> MakeForSessionIdOld(
54 const std::string& session_id);
56 // Constructs a log entry for reporting session ID is old.
57 static scoped_ptr<ServerLogEntry> MakeForSessionIdNew(
58 const std::string& session_id);
62 // Adds fields describing the client to this log entry.
63 void AddClientFields();
65 // Adds a field describing the mode of a connection to this log entry.
66 void AddModeField(Mode mode);
68 void AddEventName(const std::string& event_name);
69 void AddSessionId(const std::string& session_id);
70 void AddSessionDuration(base::TimeDelta duration);
72 // Converts this object to an XML stanza.
73 scoped_ptr<buzz::XmlElement> ToStanza() const;
76 typedef std::map<std::string, std::string> ValuesMap;
79 void Set(const std::string& key, const std::string& value);
81 static const char* GetValueSessionState(
82 remoting::protocol::ConnectionToHost::State state);
83 static const char* GetValueError(remoting::protocol::ErrorCode error);
84 static const char* GetValueMode(Mode mode);
86 ValuesMap values_map_;
91 } // namespace remoting
93 #endif // REMOTING_CLIENT_SERVER_LOG_ENTRY_H_