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.SessionState} */
53 this.previous_session_state
;
54 /** @type {remoting.ChromotingEvent.ConnectionType} */
56 /** @private {string} */
60 /** @type {remoting.ChromotingEvent.Role} */
62 /** @type {remoting.ChromotingEvent.ConnectionError} */
63 this.connection_error
;
65 this.session_duration
;
77 this.roundtrip_latency
;
78 /** @type {remoting.ChromotingEvent.Mode} */
80 /** @type {remoting.ChromotingEvent.SignalStrategyType} */
81 this.signal_strategy_type
;
82 /** @type {remoting.ChromotingEvent.SignalStrategyProgress} */
83 this.signal_strategy_progress
;
84 /** @type {?remoting.ChromotingEvent.XmppError} */
86 /** @type {remoting.ChromotingEvent.SessionEntryPoint} */
87 this.session_entry_point
;
93 remoting
.ChromotingEvent
.prototype.init_ = function() {
95 var systemInfo
= remoting
.getSystemInfo();
96 this.cpu
= systemInfo
.cpu
;
97 this.os_version
= systemInfo
.osVersion
;
98 if (systemInfo
.osName
=== remoting
.Os
.WINDOWS
) {
99 this.os
= remoting
.ChromotingEvent
.Os
.WINDOWS
;
100 } else if (systemInfo
.osName
=== remoting
.Os
.LINUX
) {
101 this.os
= remoting
.ChromotingEvent
.Os
.LINUX
;
102 } else if (systemInfo
.osName
=== remoting
.Os
.MAC
) {
103 this.os
= remoting
.ChromotingEvent
.Os
.MAC
;
104 } else if (systemInfo
.osName
=== remoting
.Os
.CHROMEOS
) {
105 this.os
= remoting
.ChromotingEvent
.Os
.CHROMEOS
;
107 this.browser_version
= systemInfo
.chromeVersion
;
110 this.webapp_version
= chrome
.runtime
.getManifest().version
;
111 this.application_id
= chrome
.runtime
.id
;
115 * @param {remoting.ChromotingEvent} event
118 remoting
.ChromotingEvent
.isEndOfSession = function(event
) {
119 if (event
.type
!== remoting
.ChromotingEvent
.Type
.SESSION_STATE
) {
123 remoting
.ChromotingEvent
.SessionState
.CLOSED
,
124 remoting
.ChromotingEvent
.SessionState
.CONNECTION_DROPPED
,
125 remoting
.ChromotingEvent
.SessionState
.CONNECTION_FAILED
,
126 remoting
.ChromotingEvent
.SessionState
.CONNECTION_CANCELED
128 return endStates
.indexOf(event
.session_state
) !== -1;
132 * This is declared as a separate structure to match the proto format
133 * on the cloud. The cloud will parse the raw stanza for more detailed
134 * fields, e.g. error condition, error type, jingle action, etc.
136 * @param {string} stanza
140 remoting
.ChromotingEvent
.XmppError = function(stanza
) {
141 /** @type {string} */
142 this.raw_stanza
= stanza
;
150 remoting
.ChromotingEvent
.Type
= {
152 CONNECTION_STATISTICS
: 2,
156 HEARTBEAT_REJECTED
: 6,
159 SIGNAL_STRATEGY_PROGRESS
: 9
162 /** @enum {number} */
163 remoting
.ChromotingEvent
.Role
= {
168 /** @enum {number} */
169 remoting
.ChromotingEvent
.Os
= {
179 /** @enum {number} */
180 remoting
.ChromotingEvent
.SessionState
= {
181 UNKNOWN
: 1, // deprecated.
182 CREATED
: 2, // deprecated.
183 BAD_PLUGIN_VERSION
: 3, // deprecated.
184 UNKNOWN_PLUGIN_ERROR
: 4, // deprecated.
186 INITIALIZING
: 6, // deprecated.
189 CONNECTION_FAILED
: 9,
191 PLUGIN_DISABLED
: 11, // deprecated.
192 CONNECTION_DROPPED
: 12,
193 CONNECTION_CANCELED
: 13,
200 /** @enum {number} */
201 remoting
.ChromotingEvent
.SessionEntryPoint
= {
204 AUTO_RECONNECT_ON_CONNECTION_DROPPED
: 3,
205 AUTO_RECONNECT_ON_HOST_OFFLINE
: 4
208 /** @enum {number} */
209 remoting
.ChromotingEvent
.ConnectionType
= {
215 /** @enum {number} */
216 remoting
.ChromotingEvent
.ConnectionError
= {
220 INCOMPATIBLE_PROTOCOL
: 4,
223 INVALID_ACCESS_CODE
: 7,
225 AUTHENTICATION_FAILED
: 9,
226 ERROR_BAD_PLUGIN_VERSION
: 10,
233 /** @enum {number} */
234 remoting
.ChromotingEvent
.Mode
= {
240 /** @enum {number} */
241 remoting
.ChromotingEvent
.SignalStrategyType
= {
246 /** @enum {number} */
247 remoting
.ChromotingEvent
.SignalStrategyProgress
= {