summaryrefslogtreecommitdiffstats
path: root/remoting/signaling/server_log_entry.h
blob: fbcba0f0118bd8715d93440e72c90b382d3ee947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_
#define REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_

#include <map>
#include <string>

#include "base/memory/scoped_ptr.h"

namespace buzz {
class XmlElement;
}  // namespace buzz

namespace remoting {

// Utility class for building log entries to send to the remoting bot. This is
// a wrapper around a key/value map and is copyable so it can be used in STL
// containers.
class ServerLogEntry {
 public:
  // The mode of a connection.
  enum Mode {
    IT2ME,
    ME2ME
  };

  ServerLogEntry();
  ServerLogEntry(const ServerLogEntry& other);
  ~ServerLogEntry();

  // Sets an arbitrary key/value entry.
  void Set(const std::string& key, const std::string& value);

  // Adds a field describing the CPU type of the platform.
  void AddCpuField();

  // Adds a field describing the mode of a connection to this log entry.
  void AddModeField(Mode mode);

  // Adds a field describing the role (client/host).
  void AddRoleField(const char* role);

  // Adds a field describing the type of log entry.
  void AddEventNameField(const char* name);

  // Constructs a log stanza. The caller should add one or more log entry
  // stanzas as children of this stanza, before sending the log stanza to
  // the remoting bot.
  static scoped_ptr<buzz::XmlElement> MakeStanza();

  // Converts this object to an XML stanza.
  scoped_ptr<buzz::XmlElement> ToStanza() const;

 private:
  typedef std::map<std::string, std::string> ValuesMap;

  ValuesMap values_map_;
};

}  // namespace remoting

#endif  // REMOTING_SIGNALING_SERVER_LOG_ENTRY_H_