server_log_entry.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_
  5. #define REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_
  6. #include <map>
  7. #include <memory>
  8. #include <string>
  9. #include "remoting/proto/remoting/v1/generic_log_entry.pb.h"
  10. namespace jingle_xmpp {
  11. class XmlElement;
  12. } // namespace jingle_xmpp
  13. namespace remoting {
  14. // Utility class for building log entries to send to the remoting bot. This is
  15. // a wrapper around a key/value map and is copyable so it can be used in STL
  16. // containers.
  17. class ServerLogEntry {
  18. public:
  19. // The mode of a connection.
  20. enum Mode {
  21. IT2ME,
  22. ME2ME
  23. };
  24. ServerLogEntry();
  25. ServerLogEntry(const ServerLogEntry& other);
  26. ~ServerLogEntry();
  27. // Sets an arbitrary key/value entry.
  28. void Set(const std::string& key, const std::string& value);
  29. // Adds a field describing the CPU type of the platform.
  30. void AddCpuField();
  31. // Adds a field describing the mode of a connection to this log entry.
  32. void AddModeField(Mode mode);
  33. // Adds a field describing the role (client/host).
  34. void AddRoleField(const char* role);
  35. // Adds a field describing the type of log entry.
  36. void AddEventNameField(const char* name);
  37. // Constructs a log stanza. The caller should add one or more log entry
  38. // stanzas as children of this stanza, before sending the log stanza to
  39. // the remoting bot.
  40. static std::unique_ptr<jingle_xmpp::XmlElement> MakeStanza();
  41. // Converts this object to an XML stanza.
  42. std::unique_ptr<jingle_xmpp::XmlElement> ToStanza() const;
  43. apis::v1::GenericLogEntry ToGenericLogEntry() const;
  44. private:
  45. typedef std::map<std::string, std::string> ValuesMap;
  46. ValuesMap values_map_;
  47. };
  48. } // namespace remoting
  49. #endif // REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_