Home | History | Annotate | Download | only in host
      1 /*
      2  * Copyright (C) 2011 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 /**
     32  * @constructor
     33  */
     34 WebInspector.UserMetrics = function()
     35 {
     36     for (var actionName in WebInspector.UserMetrics._ActionCodes) {
     37         var actionCode = WebInspector.UserMetrics._ActionCodes[actionName];
     38         this[actionName] = new WebInspector.UserMetrics._Recorder(actionCode);
     39     }
     40 }
     41 
     42 // Codes below are used to collect UMA histograms in the Chromium port.
     43 // Do not change the values below, additional actions are needed on the Chromium side
     44 // in order to add more codes.
     45 
     46 WebInspector.UserMetrics._ActionCodes = {
     47     WindowDocked: 1,
     48     WindowUndocked: 2,
     49     ScriptsBreakpointSet: 3,
     50     TimelineStarted: 4,
     51     ProfilesCPUProfileTaken: 5,
     52     ProfilesHeapProfileTaken: 6,
     53     AuditsStarted: 7,
     54     ConsoleEvaluated: 8,
     55     FileSavedInWorkspace: 9,
     56     DeviceModeEnabled: 10
     57 }
     58 
     59 WebInspector.UserMetrics._PanelCodes = {
     60     elements: 1,
     61     resources: 2,
     62     network: 3,
     63     sources: 4,
     64     timeline: 5,
     65     profiles: 6,
     66     audits: 7,
     67     console: 8
     68 }
     69 
     70 WebInspector.UserMetrics.UserAction = "UserAction";
     71 
     72 WebInspector.UserMetrics.UserActionNames = {
     73     ForcedElementState: "forcedElementState",
     74     FileSaved: "fileSaved",
     75     RevertRevision: "revertRevision",
     76     ApplyOriginalContent: "applyOriginalContent",
     77     TogglePrettyPrint: "togglePrettyPrint",
     78     SetBreakpoint: "setBreakpoint",
     79     OpenSourceLink: "openSourceLink",
     80     NetworkSort: "networkSort",
     81     NetworkRequestSelected: "networkRequestSelected",
     82     NetworkRequestTabSelected: "networkRequestTabSelected",
     83     HeapSnapshotFilterChanged: "heapSnapshotFilterChanged"
     84 };
     85 
     86 WebInspector.UserMetrics.prototype = {
     87     panelShown: function(panelName)
     88     {
     89         InspectorFrontendHost.recordPanelShown(WebInspector.UserMetrics._PanelCodes[panelName] || 0);
     90     }
     91 }
     92 
     93 /**
     94  * @constructor
     95  */
     96 WebInspector.UserMetrics._Recorder = function(actionCode)
     97 {
     98     this._actionCode = actionCode;
     99 }
    100 
    101 WebInspector.UserMetrics._Recorder.prototype = {
    102     record: function()
    103     {
    104         InspectorFrontendHost.recordActionTaken(this._actionCode);
    105     }
    106 }
    107 
    108 WebInspector.userMetrics = new WebInspector.UserMetrics();
    109