diff options
author | sergeyu <sergeyu@chromium.org> | 2015-08-04 13:14:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-04 20:15:35 +0000 |
commit | bbcbf5be6f584402cd757e8736be51808ad99cec (patch) | |
tree | 171da02d0f151a8e72cd74fc0b564510cee784ab /remoting | |
parent | dffac136a0f11b67435d5f1c0898c53e653aa525 (diff) | |
download | chromium_src-bbcbf5be6f584402cd757e8736be51808ad99cec.zip chromium_src-bbcbf5be6f584402cd757e8736be51808ad99cec.tar.gz chromium_src-bbcbf5be6f584402cd757e8736be51808ad99cec.tar.bz2 |
Add persisted experiments list in the webapp to be passed to the plugin.
Added remoting.experimental.enableExperiment() that allows to enable
an experiment. List of enabled experiments is passed to the client
plugin. The state of the experiements is persisted. Currently there is
only VP9, but in the future the same feature can be used for QUIC and
other experimental features.
BUG=134202
Review URL: https://codereview.chromium.org/1271883004
Cr-Commit-Position: refs/heads/master@{#341778}
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/remoting_webapp_files.gypi | 1 | ||||
-rw-r--r-- | remoting/webapp/base/js/client_plugin_impl.js | 53 | ||||
-rw-r--r-- | remoting/webapp/base/js/experiments.js | 72 | ||||
-rw-r--r-- | remoting/webapp/files.gni | 1 |
4 files changed, 108 insertions, 19 deletions
diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index 298683d..70f6819 100644 --- a/remoting/remoting_webapp_files.gypi +++ b/remoting/remoting_webapp_files.gypi @@ -175,6 +175,7 @@ 'webapp/base/js/connected_view.js', 'webapp/base/js/connection_info.js', 'webapp/base/js/credentials_provider.js', + 'webapp/base/js/experiments.js', 'webapp/base/js/host_desktop.js', 'webapp/base/js/smart_reconnector.js', 'webapp/base/js/telemetry_event_writer.js', diff --git a/remoting/webapp/base/js/client_plugin_impl.js b/remoting/webapp/base/js/client_plugin_impl.js index c89c0cf..4cf17c8 100644 --- a/remoting/webapp/base/js/client_plugin_impl.js +++ b/remoting/webapp/base/js/client_plugin_impl.js @@ -498,8 +498,21 @@ remoting.ClientPluginImpl.prototype.onIncomingIq = function(iq) { * @param {string} localJid Local jid. * @param {remoting.CredentialsProvider} credentialsProvider */ -remoting.ClientPluginImpl.prototype.connect = - function(host, localJid, credentialsProvider) { +remoting.ClientPluginImpl.prototype.connect = function(host, localJid, + credentialsProvider) { + remoting.experiments.get().then(this.connectWithExperiments_.bind( + this, host, localJid, credentialsProvider)); +}; + +/** + * @param {remoting.Host} host The host to connect to. + * @param {string} localJid Local jid. + * @param {remoting.CredentialsProvider} credentialsProvider + * @param {Array.<string>} experiments List of enabled experiments. + * @private + */ +remoting.ClientPluginImpl.prototype.connectWithExperiments_ = function( + host, localJid, credentialsProvider, experiments) { var keyFilter = ''; if (remoting.platformIsMac()) { keyFilter = 'mac'; @@ -511,26 +524,28 @@ remoting.ClientPluginImpl.prototype.connect = // previous versions of Chrome, see crbug.com/459103 and crbug.com/463577 . var enableVideoDecodeRenderer = parseInt((remoting.getChromeVersion() || '0').split('.')[0], 10) >= 43; - this.plugin_.postMessage(JSON.stringify( - { method: 'delegateLargeCursors', data: {} })); + this.plugin_.postMessage( + JSON.stringify({method: 'delegateLargeCursors', data: {}})); var methods = 'third_party,spake2_pair,spake2_hmac,spake2_plain'; this.credentials_ = credentialsProvider; this.useAsyncPinDialog_(); - this.plugin_.postMessage(JSON.stringify( - { method: 'connect', data: { - hostJid: host.jabberId, - hostPublicKey: host.publicKey, - localJid: localJid, - sharedSecret: '', - authenticationMethods: methods, - authenticationTag: host.hostId, - capabilities: this.capabilities_.join(" "), - clientPairingId: credentialsProvider.getPairingInfo().clientId, - clientPairedSecret: credentialsProvider.getPairingInfo().sharedSecret, - keyFilter: keyFilter, - enableVideoDecodeRenderer: enableVideoDecodeRenderer - } - })); + this.plugin_.postMessage(JSON.stringify({ + method: 'connect', + data: { + hostJid: host.jabberId, + hostPublicKey: host.publicKey, + localJid: localJid, + sharedSecret: '', + authenticationMethods: methods, + authenticationTag: host.hostId, + capabilities: this.capabilities_.join(" "), + clientPairingId: credentialsProvider.getPairingInfo().clientId, + clientPairedSecret: credentialsProvider.getPairingInfo().sharedSecret, + keyFilter: keyFilter, + enableVideoDecodeRenderer: enableVideoDecodeRenderer, + experiments: experiments.join(" ") + } + })); }; /** diff --git a/remoting/webapp/base/js/experiments.js b/remoting/webapp/base/js/experiments.js new file mode 100644 index 0000000..b6228c4 --- /dev/null +++ b/remoting/webapp/base/js/experiments.js @@ -0,0 +1,72 @@ +// Copyright 2015 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. + +/** + * @fileoverview + * Class for enabling experimental features. + */ + +'use strict'; + +/** @suppress {duplicate} */ +var remoting = remoting || {}; + +(function () { + +var kExperimentsStorageName = 'remoting-experiments'; + +/** + * @param {Array.<string>} list + */ +function save(list) { + var storageMap = {}; + storageMap[kExperimentsStorageName] = list; + chrome.storage.local.set(storageMap); +}; + +/** @type {Object} */ +remoting.experiments = {}; + +/** + * Enables an experiment. + * + * @param {string} experiment to enable. + */ +remoting.experiments.enable = function(experiment) { + remoting.experiments.get().then(function(/** Array.<string> */list) { + if (list.indexOf(experiment) == -1) { + list.push(experiment); + save(list); + } + }); +}; + +/** + * Disables an experiment. + * + * @param {string} experiment to disable. + */ +remoting.experiments.disable = function(experiment) { + remoting.experiments.get().then(function(/** Array.<string> */list) { + list = list.filter(function(e) { return e !== experiment; }); + save(list); + }); +}; + +/** + * Returns list of all enabled experiments. + * @return {Promise} + */ +remoting.experiments.get = function() { + return new Promise(function(resolve, reject) { + chrome.storage.local.get(kExperimentsStorageName, function(items) { + if (items.hasOwnProperty(kExperimentsStorageName)) { + resolve(items[kExperimentsStorageName]); + } + resolve([]); + }); + }); +}; + +})(); diff --git a/remoting/webapp/files.gni b/remoting/webapp/files.gni index 32c4492..3aec739c 100644 --- a/remoting/webapp/files.gni +++ b/remoting/webapp/files.gni @@ -165,6 +165,7 @@ remoting_webapp_shared_js_client_files = [ "base/js/connected_view.js", "base/js/connection_info.js", "base/js/credentials_provider.js", + "base/js/experiments.js", "base/js/host_desktop.js", "base/js/smart_reconnector.js", "base/js/telemetry_event_writer.js", |