OLD | NEW |
| (Empty) |
1 // Copyright 2016 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_SIGNALING_CHROMOTING_EVENT_H_ | |
6 #define REMOTING_SIGNALING_CHROMOTING_EVENT_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/values.h" | |
12 | |
13 namespace remoting { | |
14 | |
15 // This is the representation of the log entry being sent to the telemetry | |
16 // server. The content should be synced with chromoting_event.js and | |
17 // chromoting_extensions.proto. | |
18 class ChromotingEvent { | |
19 public: | |
20 enum class ConnectionError { | |
21 NONE = 1, | |
22 HOST_OFFLINE = 2, | |
23 SESSION_REJECTED = 3, | |
24 INCOMPATIBLE_PROTOCOL = 4, | |
25 NETWORK_FAILURE = 5, | |
26 UNKNOWN_ERROR = 6, | |
27 INVALID_ACCESS_CODE = 7, | |
28 MISSING_PLUGIN = 8, | |
29 AUTHENTICATION_FAILED = 9, | |
30 BAD_VERSION = 10, | |
31 HOST_OVERLOAD = 11, | |
32 P2P_FAILURE = 12, | |
33 UNEXPECTED = 13, | |
34 CLIENT_SUSPENDED = 14, | |
35 NACL_DISABLED = 15, | |
36 MAX_SESSION_LENGTH = 16, | |
37 HOST_CONFIGURATION_ERROR = 17, | |
38 NACL_PLUGIN_CRASHED = 18 | |
39 }; | |
40 | |
41 enum class Mode { IT2ME = 1, ME2ME = 2, LGAPP = 3 }; | |
42 | |
43 // macro defines from command line have polluted OS names like | |
44 // "LINUX", "ANDROID", etc. | |
45 enum class Os { | |
46 CHROMOTING_LINUX = 1, | |
47 CHROMOTING_CHROMEOS = 2, | |
48 CHROMOTING_MAC = 3, | |
49 CHROMOTING_WINDOWS = 4, | |
50 OTHER = 5, | |
51 CHROMOTING_ANDROID = 6, | |
52 CHROMOTING_IOS = 7 | |
53 }; | |
54 | |
55 enum class Role { CLIENT = 0, HOST = 1 }; | |
56 | |
57 enum class SessionState { | |
58 UNKNOWN = 1, // deprecated. | |
59 CREATED = 2, // deprecated. | |
60 BAD_PLUGIN_VERSION = 3, // deprecated. | |
61 UNKNOWN_PLUGIN_ERROR = 4, // deprecated. | |
62 CONNECTING = 5, | |
63 INITIALIZING = 6, // deprecated. | |
64 CONNECTED = 7, | |
65 CLOSED = 8, | |
66 CONNECTION_FAILED = 9, | |
67 UNDEFINED = 10, | |
68 PLUGIN_DISABLED = 11, // deprecated. | |
69 CONNECTION_DROPPED = 12, | |
70 CONNECTION_CANCELED = 13, | |
71 AUTHENTICATED = 14, | |
72 STARTED = 15, | |
73 SIGNALING = 16, | |
74 CREATING_PLUGIN = 17, | |
75 }; | |
76 | |
77 enum class Type { | |
78 SESSION_STATE = 1, | |
79 CONNECTION_STATISTICS = 2, | |
80 SESSION_ID_OLD = 3, | |
81 SESSION_ID_NEW = 4, | |
82 HEARTBEAT = 5, | |
83 HEARTBEAT_REJECTED = 6, | |
84 RESTART = 7, | |
85 HOST_STATUS = 8, | |
86 SIGNAL_STRATEGY_PROGRESS = 9 | |
87 }; | |
88 | |
89 static const char kCaptureLatencyKey[]; | |
90 static const char kConnectionErrorKey[]; | |
91 static const char kCpuKey[]; | |
92 static const char kDecodeLatencyKey[]; | |
93 static const char kEncodeLatencyKey[]; | |
94 static const char kMaxCaptureLatencyKey[]; | |
95 static const char kMaxDecodeLatencyKey[]; | |
96 static const char kMaxEncodeLatencyKey[]; | |
97 static const char kMaxRenderLatencyKey[]; | |
98 static const char kMaxRoundtripLatencyKey[]; | |
99 static const char kModeKey[]; | |
100 static const char kOsKey[]; | |
101 static const char kOsVersionKey[]; | |
102 static const char kRenderLatencyKey[]; | |
103 static const char kRoleKey[]; | |
104 static const char kRoundtripLatencyKey[]; | |
105 static const char kSessionDurationKey[]; | |
106 static const char kSessionIdKey[]; | |
107 static const char kSessionStateKey[]; | |
108 static const char kTypeKey[]; | |
109 static const char kVideoBandwidthKey[]; | |
110 | |
111 ChromotingEvent(); | |
112 explicit ChromotingEvent(Type type); | |
113 ChromotingEvent(const ChromotingEvent& other); | |
114 ChromotingEvent(ChromotingEvent&& other); | |
115 | |
116 ~ChromotingEvent(); | |
117 | |
118 ChromotingEvent& operator=(const ChromotingEvent& other); | |
119 ChromotingEvent& operator=(ChromotingEvent&& other); | |
120 | |
121 // Sets an arbitrary key/value entry. | |
122 void SetString(const std::string& key, const std::string& value); | |
123 void SetInteger(const std::string& key, int value); | |
124 void SetBoolean(const std::string& key, bool value); | |
125 void SetDouble(const std::string& key, double value); | |
126 template <typename E> | |
127 void SetEnum(const std::string& key, E e) { | |
128 SetInteger(key, static_cast<int>(e)); | |
129 } | |
130 | |
131 // Adds fields of CPU type, OS type and OS version. | |
132 void AddSystemInfo(); | |
133 | |
134 void IncrementTryCount(); | |
135 int try_count() const { return try_count_; } | |
136 | |
137 // Returns a copy of the internal dictionary value. | |
138 std::unique_ptr<base::DictionaryValue> CopyDictionaryValue() const; | |
139 | |
140 // Returns true if the SessionState concludes the end of session. | |
141 static bool IsEndOfSession(SessionState state); | |
142 | |
143 private: | |
144 std::unique_ptr<base::DictionaryValue> values_map_; | |
145 | |
146 int try_count_ = 0; | |
147 }; | |
148 | |
149 } // namespace remoting | |
150 | |
151 #endif // REMOTING_SIGNALING_CHROMOTING_EVENT_H_ | |
OLD | NEW |