Commit ce29dde5 authored by jamiewalch's avatar jamiewalch Committed by Commit bot

Log host and client screen sizes.

BUG=642519

Review-Url: https://codereview.chromium.org/2369013008
Cr-Commit-Position: refs/heads/master@{#422952}
parent 2c32acd5
......@@ -120,6 +120,15 @@ remoting.ChromotingEvent = function(type) {
* @type {remoting.ChromotingEvent.FeatureTracker}
*/
this.feature_tracker;
/** @type {remoting.ChromotingEvent.ScreenResolution} */
this.host_all_screens_size;
/** @type {remoting.ChromotingEvent.ScreenResolution} */
this.client_video_size;
/** @type {remoting.ChromotingEvent.ScreenResolution} */
this.client_window_size;
/** @type {boolean} */
this.client_fullscreen;
this.init_();
};
......@@ -230,6 +239,24 @@ remoting.ChromotingEvent.FeatureTracker = function() {
this.fullscreen_esc_count = 0;
};
/**
* Client or host screen resolution.
*
* @param {number} width
* @param {number} height
* @param {number} dpi
* @struct
* @constructor
*/
remoting.ChromotingEvent.ScreenResolution = function(width, height, dpi) {
/** @type {number} */
this.width = width;
/** @type {number} */
this.height = height;
/** @type {number} */
this.dpi = dpi;
};
})();
/**
......@@ -245,7 +272,8 @@ remoting.ChromotingEvent.Type = {
RESTART: 7,
HOST_STATUS: 8,
SIGNAL_STRATEGY_PROGRESS: 9,
FEATURE_TRACKING: 10
FEATURE_TRACKING: 10,
SCREEN_RESOLUTIONS: 11,
};
/** @enum {number} */
......
......@@ -262,6 +262,24 @@ remoting.SessionLogger.prototype.logStatistics = function(stats) {
}
};
/**
* Logs host and client dimensions.
*
* @param {{width: number, height: number}} hostSize
* @param {{width: number, height: number}} clientPluginSize
* @param {{width: number, height: number}} clientWindowSize
* @param {boolean} clientFullscreen
*/
remoting.SessionLogger.prototype.logScreenResolutions =
function(hostSize, hostDpi, clientPluginSize, clientWindowSize, clientDpi,
clientFullscreen) {
this.maybeExpireSessionId_();
var entry = this.makeScreenResolutions_(hostSize, hostDpi, clientPluginSize,
clientWindowSize, clientDpi,
clientFullscreen);
this.log_(entry);
};
/**
* @param {remoting.ChromotingEvent.SessionState} state
* @param {remoting.Error=} opt_error
......@@ -289,6 +307,30 @@ remoting.SessionLogger.prototype.makeSessionStateChange_ =
return entry;
};
/**
* @param {{width: number, height: number}} hostSize
* @param {{width: number, height: number}} clientPluginSize
* @param {{width: number, height: number}} clientWindowSize
* @param {boolean} clientFullscreen
* @return {remoting.ChromotingEvent}
* @private
*/
remoting.SessionLogger.prototype.makeScreenResolutions_ =
function(hostSize, hostDpi, clientPluginSize, clientWindowSize, clientDpi,
clientFullscreen) {
var entry = new remoting.ChromotingEvent(
remoting.ChromotingEvent.Type.SCREEN_RESOLUTIONS);
entry.client_video_size = new remoting.ChromotingEvent.ScreenResolution(
clientPluginSize.width, clientPluginSize.height, clientDpi);
entry.client_window_size = new remoting.ChromotingEvent.ScreenResolution(
clientWindowSize.width, clientWindowSize.height, clientDpi);
entry.host_all_screens_size = new remoting.ChromotingEvent.ScreenResolution(
hostSize.width, hostSize.height, hostDpi);
entry.client_fullscreen = clientFullscreen;
this.fillEvent_(entry);
return entry;
};
/**
* @return {remoting.ChromotingEvent}
* @private
......
......@@ -15,11 +15,12 @@ var remoting = remoting || {};
/**
* @param {HTMLElement} container
* @param {remoting.ConnectionInfo} connectionInfo
* @param {remoting.SessionLogger} logger
* @constructor
* @extends {base.EventSourceImpl}
* @implements {base.Disposable}
*/
remoting.DesktopConnectedView = function(container, connectionInfo) {
remoting.DesktopConnectedView = function(container, connectionInfo, logger) {
/** @private {HTMLElement} */
this.container_ = container;
......@@ -33,6 +34,9 @@ remoting.DesktopConnectedView = function(container, connectionInfo) {
/** @private */
this.host_ = connectionInfo.host();
/** @private */
this.logger_ = logger;
/** @private {remoting.DesktopViewport} */
this.viewport_ = null;
......@@ -179,7 +183,8 @@ remoting.DesktopConnectedView.prototype.initUI_ = function() {
this.viewport_ = new remoting.DesktopViewport(
scrollerElement || document.body,
this.plugin_.hostDesktop(),
this.host_.options);
this.host_.options,
this.logger_);
if (remoting.windowFrame) {
remoting.windowFrame.setDesktopConnectedView(this);
......@@ -300,8 +305,10 @@ remoting.DesktopConnectedView.prototype.setRemapKeys = function(remappings) {
*
* @param {HTMLElement} container
* @param {remoting.ConnectionInfo} connectionInfo
* @param {remoting.SessionLogger} logger
* @return {remoting.DesktopConnectedView}
*/
remoting.DesktopConnectedView.create = function(container, connectionInfo) {
return new remoting.DesktopConnectedView(container, connectionInfo);
remoting.DesktopConnectedView.create = function(container, connectionInfo,
logger) {
return new remoting.DesktopConnectedView(container, connectionInfo, logger);
};
......@@ -103,7 +103,8 @@ remoting.DesktopRemotingActivity.prototype.onConnected =
}
this.connectedView_ = remoting.DesktopConnectedView.create(
base.getHtmlElement('client-container'), connectionInfo);
base.getHtmlElement('client-container'), connectionInfo,
this.logger_);
// Apply the default or previously-specified keyboard remapping.
var remapping = connectionInfo.host().options.getRemapKeys();
......
......@@ -22,11 +22,13 @@ var remoting = remoting || {};
* are showing scrollbars on.
* @param {remoting.HostDesktop} hostDesktop
* @param {remoting.HostOptions} hostOptions
* @param {!remoting.SessionLogger} logger
*
* @constructor
* @implements {base.Disposable}
*/
remoting.DesktopViewport = function(rootElement, hostDesktop, hostOptions) {
remoting.DesktopViewport = function(rootElement, hostDesktop, hostOptions,
logger) {
/** @private */
this.rootElement_ = rootElement;
/** @private */
......@@ -49,6 +51,10 @@ remoting.DesktopViewport = function(rootElement, hostDesktop, hostOptions) {
this.pluginWidthForBumpScrollTesting_ = 0;
/** @private {number} */
this.pluginHeightForBumpScrollTesting_ = 0;
/** @private {!remoting.SessionLogger} */
this.logger_ = logger;
/** @private {number?} */
this.loggingTimer_ = null;
this.eventHooks_ = new base.Disposables(
new base.EventHook(
......@@ -331,11 +337,18 @@ remoting.DesktopViewport.prototype.updateDimensions_ = function() {
height: dimensions.height };
var desktopDpi = { x: dimensions.xDpi,
y: dimensions.yDpi };
var clientSize = this.getClientArea();
var newSize = remoting.Viewport.choosePluginSize(
this.getClientArea(), window.devicePixelRatio,
clientSize, window.devicePixelRatio,
desktopSize, desktopDpi, this.hostOptions_.getDesktopScale(),
remoting.fullscreen.isActive(), this.hostOptions_.getShrinkToFit());
// Log the host and client dimensions. Since we don't support differing x- and
// y-DPIs, arbitrarily pick one for the host DPI.
this.logDimensions_(desktopSize, desktopDpi.x, newSize, clientSize,
window.devicePixelRatio * 96,
remoting.fullscreen.isActive());
// Resize the plugin if necessary.
console.log('plugin dimensions:' + newSize.width + 'x' + newSize.height);
this.pluginElement_.style.width = newSize.width + 'px';
......@@ -366,4 +379,31 @@ remoting.DesktopViewport.prototype.setDesktopScale = function(desktopScale) {
this.hostOptions_.save();
};
/**
* Log the specified client and host sizes after a short delay. Since the host
* size may change in response to a change in the client size, the delay allows
* time for the desktop size change notification to arrive from the host, and
* avoids logging the intermediate state.
*
* @param {{width: number, height: number}} hostSize
* @param {{width: number, height: number}} clientPluginSize
* @param {{width: number, height: number}} clientWindowSize
* @param {boolean} clientFullscreen
*/
remoting.DesktopViewport.prototype.logDimensions_ =
function(hostSize, hostDpi, clientPluginSize, clientWindowSize, clientDpi,
isFullscreen) {
if (this.loggingTimer_ !== null) {
window.clearTimeout(this.loggingTimer_);
}
var kLoggingRateLimitMs = 2000;
this.loggingTimer_ = window.setTimeout(
() => {
this.logger_.logScreenResolutions(hostSize, hostDpi, clientPluginSize,
clientWindowSize, clientDpi,
isFullscreen);
},
kLoggingRateLimitMs);
};
}());
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment