browser/extensions/shumway/content/ShumwayTelemetry.jsm

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/extensions/shumway/content/ShumwayTelemetry.jsm	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
     1.6 +/* Copyright 2013 Mozilla Foundation
     1.7 + *
     1.8 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.9 + * you may not use this file except in compliance with the License.
    1.10 + * You may obtain a copy of the License at
    1.11 + *
    1.12 + *     http://www.apache.org/licenses/LICENSE-2.0
    1.13 + *
    1.14 + * Unless required by applicable law or agreed to in writing, software
    1.15 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.16 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.17 + * See the License for the specific language governing permissions and
    1.18 + * limitations under the License.
    1.19 + */
    1.20 +/* jshint esnext:true */
    1.21 +
    1.22 +'use strict';
    1.23 +
    1.24 +this.EXPORTED_SYMBOLS = ['ShumwayTelemetry'];
    1.25 +
    1.26 +const Cu = Components.utils;
    1.27 +Cu.import('resource://gre/modules/Services.jsm');
    1.28 +
    1.29 +const BANNER_SIZES = [
    1.30 +  "88x31", "120x60", "120x90", "120x240", "120x600", "125x125", "160x600",
    1.31 +  "180x150", "234x60", "240x400", "250x250", "300x100", "300x250", "300x600",
    1.32 +  "300x1050", "336x280", "468x60", "550x480", "720x100", "728x90", "970x90",
    1.33 +  "970x250"];
    1.34 +
    1.35 +function getBannerType(width, height) {
    1.36 +  return BANNER_SIZES.indexOf(width + 'x' + height) + 1;
    1.37 +}
    1.38 +
    1.39 +this.ShumwayTelemetry = {
    1.40 +  onFirstFrame: function (timeToDisplay) {
    1.41 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_TIME_TO_VIEW_MS");
    1.42 +    histogram.add(timeToDisplay);
    1.43 +  },
    1.44 +  onParseInfo: function (parseInfo) {
    1.45 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_PARSING_MS");
    1.46 +    histogram.add(parseInfo.parseTime);
    1.47 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_SIZE_KB");
    1.48 +    histogram.add(parseInfo.size / 1024);
    1.49 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_VERSION");
    1.50 +    histogram.add(parseInfo.swfVersion);
    1.51 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_FRAME_RATE");
    1.52 +    histogram.add(parseInfo.frameRate);
    1.53 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_AREA");
    1.54 +    histogram.add(parseInfo.width * parseInfo.height);
    1.55 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_BANNER");
    1.56 +    histogram.add(getBannerType(parseInfo.width, parseInfo.height));
    1.57 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_AVM2");
    1.58 +    histogram.add(parseInfo.isAvm2);
    1.59 +  },
    1.60 +  onError: function (errorType) {
    1.61 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_ERROR");
    1.62 +    histogram.add(errorType);
    1.63 +  },
    1.64 +  onPageIndex: function (pageIndex) {
    1.65 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_SWF_INDEX_ON_PAGE");
    1.66 +    histogram.add(pageIndex);
    1.67 +  },
    1.68 +  onFeature: function (featureType) {
    1.69 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_FEATURE_USED");
    1.70 +    histogram.add(featureType);
    1.71 +  },
    1.72 +  onFallback: function (userAction) {
    1.73 +    var histogram = Services.telemetry.getHistogramById("SHUMWAY_FALLBACK");
    1.74 +    histogram.add(userAction);
    1.75 +  }
    1.76 +};

mercurial