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