Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ |
michael@0 | 3 | /* Copyright 2013 Mozilla Foundation |
michael@0 | 4 | * |
michael@0 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 6 | * you may not use this file except in compliance with the License. |
michael@0 | 7 | * You may obtain a copy of the License at |
michael@0 | 8 | * |
michael@0 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 10 | * |
michael@0 | 11 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 14 | * See the License for the specific language governing permissions and |
michael@0 | 15 | * limitations under the License. |
michael@0 | 16 | */ |
michael@0 | 17 | /* jshint esnext:true */ |
michael@0 | 18 | |
michael@0 | 19 | 'use strict'; |
michael@0 | 20 | |
michael@0 | 21 | this.EXPORTED_SYMBOLS = ['ShumwayTelemetry']; |
michael@0 | 22 | |
michael@0 | 23 | const Cu = Components.utils; |
michael@0 | 24 | Cu.import('resource://gre/modules/Services.jsm'); |
michael@0 | 25 | |
michael@0 | 26 | const BANNER_SIZES = [ |
michael@0 | 27 | "88x31", "120x60", "120x90", "120x240", "120x600", "125x125", "160x600", |
michael@0 | 28 | "180x150", "234x60", "240x400", "250x250", "300x100", "300x250", "300x600", |
michael@0 | 29 | "300x1050", "336x280", "468x60", "550x480", "720x100", "728x90", "970x90", |
michael@0 | 30 | "970x250"]; |
michael@0 | 31 | |
michael@0 | 32 | function getBannerType(width, height) { |
michael@0 | 33 | return BANNER_SIZES.indexOf(width + 'x' + height) + 1; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | this.ShumwayTelemetry = { |
michael@0 | 37 | onFirstFrame: function (timeToDisplay) { |
michael@0 | 38 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_TIME_TO_VIEW_MS"); |
michael@0 | 39 | histogram.add(timeToDisplay); |
michael@0 | 40 | }, |
michael@0 | 41 | onParseInfo: function (parseInfo) { |
michael@0 | 42 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_PARSING_MS"); |
michael@0 | 43 | histogram.add(parseInfo.parseTime); |
michael@0 | 44 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_SIZE_KB"); |
michael@0 | 45 | histogram.add(parseInfo.size / 1024); |
michael@0 | 46 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_VERSION"); |
michael@0 | 47 | histogram.add(parseInfo.swfVersion); |
michael@0 | 48 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_FRAME_RATE"); |
michael@0 | 49 | histogram.add(parseInfo.frameRate); |
michael@0 | 50 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_AREA"); |
michael@0 | 51 | histogram.add(parseInfo.width * parseInfo.height); |
michael@0 | 52 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_BANNER"); |
michael@0 | 53 | histogram.add(getBannerType(parseInfo.width, parseInfo.height)); |
michael@0 | 54 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_AVM2"); |
michael@0 | 55 | histogram.add(parseInfo.isAvm2); |
michael@0 | 56 | }, |
michael@0 | 57 | onError: function (errorType) { |
michael@0 | 58 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_ERROR"); |
michael@0 | 59 | histogram.add(errorType); |
michael@0 | 60 | }, |
michael@0 | 61 | onPageIndex: function (pageIndex) { |
michael@0 | 62 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_INDEX_ON_PAGE"); |
michael@0 | 63 | histogram.add(pageIndex); |
michael@0 | 64 | }, |
michael@0 | 65 | onFeature: function (featureType) { |
michael@0 | 66 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_FEATURE_USED"); |
michael@0 | 67 | histogram.add(featureType); |
michael@0 | 68 | }, |
michael@0 | 69 | onFallback: function (userAction) { |
michael@0 | 70 | var histogram = Services.telemetry.getHistogramById("SHUMWAY_FALLBACK"); |
michael@0 | 71 | histogram.add(userAction); |
michael@0 | 72 | } |
michael@0 | 73 | }; |