michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ michael@0: /* Copyright 2013 Mozilla Foundation michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: /* jshint esnext:true */ michael@0: michael@0: 'use strict'; michael@0: michael@0: this.EXPORTED_SYMBOLS = ['ShumwayTelemetry']; michael@0: michael@0: const Cu = Components.utils; michael@0: Cu.import('resource://gre/modules/Services.jsm'); michael@0: michael@0: const BANNER_SIZES = [ michael@0: "88x31", "120x60", "120x90", "120x240", "120x600", "125x125", "160x600", michael@0: "180x150", "234x60", "240x400", "250x250", "300x100", "300x250", "300x600", michael@0: "300x1050", "336x280", "468x60", "550x480", "720x100", "728x90", "970x90", michael@0: "970x250"]; michael@0: michael@0: function getBannerType(width, height) { michael@0: return BANNER_SIZES.indexOf(width + 'x' + height) + 1; michael@0: } michael@0: michael@0: this.ShumwayTelemetry = { michael@0: onFirstFrame: function (timeToDisplay) { michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_TIME_TO_VIEW_MS"); michael@0: histogram.add(timeToDisplay); michael@0: }, michael@0: onParseInfo: function (parseInfo) { michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_PARSING_MS"); michael@0: histogram.add(parseInfo.parseTime); michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_SIZE_KB"); michael@0: histogram.add(parseInfo.size / 1024); michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_VERSION"); michael@0: histogram.add(parseInfo.swfVersion); michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_FRAME_RATE"); michael@0: histogram.add(parseInfo.frameRate); michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_AREA"); michael@0: histogram.add(parseInfo.width * parseInfo.height); michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_BANNER"); michael@0: histogram.add(getBannerType(parseInfo.width, parseInfo.height)); michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_AVM2"); michael@0: histogram.add(parseInfo.isAvm2); michael@0: }, michael@0: onError: function (errorType) { michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_ERROR"); michael@0: histogram.add(errorType); michael@0: }, michael@0: onPageIndex: function (pageIndex) { michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_INDEX_ON_PAGE"); michael@0: histogram.add(pageIndex); michael@0: }, michael@0: onFeature: function (featureType) { michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_FEATURE_USED"); michael@0: histogram.add(featureType); michael@0: }, michael@0: onFallback: function (userAction) { michael@0: var histogram = Services.telemetry.getHistogramById("SHUMWAY_FALLBACK"); michael@0: histogram.add(userAction); michael@0: } michael@0: };