1 // Copyright 2015 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.
7 // MM ,M9 .gP"Ya ,6"Yb. ,M""bMM `7MMpMMMb.pMMMb. .gP"Ya
8 // MMmmdM9 ,M' Yb 8) MM ,AP MM MM MM MM ,M' Yb
9 // MM YM. 8M"""""" ,pm9MM 8MI MM MM MM MM 8M""""""
10 // MM `Mb.YM. , 8M MM `Mb MM MM MM MM YM. ,
11 // .JMML. .JMM.`Mbmmd' `Moo9^Yo.`Wbmd"MML..JMML JMML JMML.`Mbmmd'
13 // This file defines a JavaScript struct that corresponds to
14 // logs/proto/chromoting/chromoting_extensions.proto
16 // Please keep the two files in sync!
19 /** @suppress {duplicate} */
20 var remoting = remoting || {};
27 * The members in this struct is used as the JSON payload in outgoing XHRs
28 * so they must match the member definitions in chromoting_extensions.proto.
30 * @param {remoting.ChromotingEvent.Type} type
35 remoting.ChromotingEvent = function(type) {
36 /** @type {remoting.ChromotingEvent.Type} */
38 /** @private {remoting.ChromotingEvent.Os} */
40 /** @private {string} */
42 /** @private {string} */
44 /** @private {string} */
48 /** @private {string} */
50 /** @type {remoting.ChromotingEvent.SessionState} */
52 /** @type {remoting.ChromotingEvent.ConnectionType} */
54 /** @private {string} */
58 /** @type {remoting.ChromotingEvent.Role} */
60 /** @type {remoting.ChromotingEvent.ConnectionError} */
61 this.connection_error;
63 this.session_duration;
75 this.roundtrip_latency;
76 /** @type {remoting.ChromotingEvent.Mode} */
78 /** @type {remoting.ChromotingEvent.SignalStrategyType} */
79 this.signal_strategy_type;
80 /** @type {remoting.ChromotingEvent.SignalStrategyProgress} */
81 this.signal_strategy_progress;
87 remoting.ChromotingEvent.prototype.init_ = function() {
89 var systemInfo = remoting.getSystemInfo();
90 this.cpu = systemInfo.cpu;
91 this.os_version = systemInfo.osVersion;
92 if (systemInfo.osName === remoting.Os.WINDOWS) {
93 this.os = remoting.ChromotingEvent.Os.WINDOWS;
94 } else if (systemInfo.osName === remoting.Os.LINUX) {
95 this.os = remoting.ChromotingEvent.Os.LINUX;
96 } else if (systemInfo.osName === remoting.Os.MAC) {
97 this.os = remoting.ChromotingEvent.Os.MAC;
98 } else if (systemInfo.osName === remoting.Os.CHROMEOS) {
99 this.os = remoting.ChromotingEvent.Os.CHROMEOS;
101 this.browser_version = systemInfo.chromeVersion;
104 this.webapp_version = chrome.runtime.getManifest().version;
105 this.application_id = chrome.runtime.id;
109 * @param {remoting.ChromotingEvent} event
112 remoting.ChromotingEvent.isEndOfSession = function(event) {
113 if (event.type !== remoting.ChromotingEvent.Type.SESSION_STATE) {
117 remoting.ChromotingEvent.SessionState.CLOSED,
118 remoting.ChromotingEvent.SessionState.CONNECTION_DROPPED,
119 remoting.ChromotingEvent.SessionState.CONNECTION_FAILED,
120 remoting.ChromotingEvent.SessionState.CONNECTION_CANCELED
122 return endStates.indexOf(event.session_state) !== -1;
130 remoting.ChromotingEvent.Type = {
132 CONNECTION_STATISTICS: 2,
136 HEARTBEAT_REJECTED: 6,
139 SIGNAL_STRATEGY_PROGRESS: 9
142 /** @enum {number} */
143 remoting.ChromotingEvent.Role = {
148 /** @enum {number} */
149 remoting.ChromotingEvent.Os = {
159 /** @enum {number} */
160 remoting.ChromotingEvent.SessionState = {
163 BAD_PLUGIN_VERSION: 3,
164 UNKNOWN_PLUGIN_ERROR: 4,
169 CONNECTION_FAILED: 9,
172 CONNECTION_DROPPED: 12,
173 CONNECTION_CANCELED: 13,
177 /** @enum {number} */
178 remoting.ChromotingEvent.ConnectionType = {
184 /** @enum {number} */
185 remoting.ChromotingEvent.ConnectionError = {
189 INCOMPATIBLE_PROTOCOL: 4,
192 INVALID_ACCESS_CODE: 7,
194 AUTHENTICATION_FAILED: 9,
195 ERROR_BAD_PLUGIN_VERSION: 10,
202 /** @enum {number} */
203 remoting.ChromotingEvent.Mode = {
209 /** @enum {number} */
210 remoting.ChromotingEvent.SignalStrategyType = {
215 /** @enum {number} */
216 remoting.ChromotingEvent.SignalStrategyProgress = {