| OLD | NEW |
| (Empty) | |
| 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_CLIENT_SERVER_LOG_ENTRY_H_ |
| 6 #define REMOTING_CLIENT_SERVER_LOG_ENTRY_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
| 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" |
| 15 |
| 16 namespace buzz { |
| 17 class XmlElement; |
| 18 } // namespace buzz |
| 19 |
| 20 namespace remoting { |
| 21 |
| 22 class ChromotingStats; |
| 23 |
| 24 // Temporary namespace to prevent conflict with the same-named class in |
| 25 // remoting/host when linking unittests. |
| 26 // |
| 27 // TODO(lambroslambrou): Remove this and factor out any shared code. |
| 28 namespace client { |
| 29 |
| 30 class ServerLogEntry { |
| 31 public: |
| 32 // The mode of a connection. |
| 33 enum Mode { |
| 34 IT2ME, |
| 35 ME2ME |
| 36 }; |
| 37 |
| 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 |
| 40 // the remoting bot. |
| 41 static scoped_ptr<buzz::XmlElement> MakeStanza(); |
| 42 |
| 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); |
| 47 |
| 48 // Constructs a log entry for reporting statistics. |
| 49 static scoped_ptr<ServerLogEntry> MakeForStatistics( |
| 50 remoting::ChromotingStats* statistics); |
| 51 |
| 52 // Constructs a log entry for reporting session ID is old. |
| 53 static scoped_ptr<ServerLogEntry> MakeForSessionIdOld( |
| 54 const std::string& session_id); |
| 55 |
| 56 // Constructs a log entry for reporting session ID is old. |
| 57 static scoped_ptr<ServerLogEntry> MakeForSessionIdNew( |
| 58 const std::string& session_id); |
| 59 |
| 60 ~ServerLogEntry(); |
| 61 |
| 62 // Adds fields describing the client to this log entry. |
| 63 void AddClientFields(); |
| 64 |
| 65 // Adds a field describing the mode of a connection to this log entry. |
| 66 void AddModeField(Mode mode); |
| 67 |
| 68 void AddEventName(const std::string& event_name); |
| 69 void AddSessionId(const std::string& session_id); |
| 70 void AddSessionDuration(base::TimeDelta duration); |
| 71 |
| 72 // Converts this object to an XML stanza. |
| 73 scoped_ptr<buzz::XmlElement> ToStanza() const; |
| 74 |
| 75 private: |
| 76 typedef std::map<std::string, std::string> ValuesMap; |
| 77 |
| 78 ServerLogEntry(); |
| 79 void Set(const std::string& key, const std::string& value); |
| 80 |
| 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); |
| 85 |
| 86 ValuesMap values_map_; |
| 87 }; |
| 88 |
| 89 } // namespace client |
| 90 |
| 91 } // namespace remoting |
| 92 |
| 93 #endif // REMOTING_CLIENT_SERVER_LOG_ENTRY_H_ |
| OLD | NEW |