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