• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
34WebInspector.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
46WebInspector.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}
56
57WebInspector.UserMetrics._PanelCodes = {
58    elements: 1,
59    resources: 2,
60    network: 3,
61    scripts: 4,
62    timeline: 5,
63    profiles: 6,
64    audits: 7,
65    console: 8
66}
67
68WebInspector.UserMetrics.UserAction = "UserAction";
69
70WebInspector.UserMetrics.UserActionNames = {
71    ForcedElementState: "forcedElementState",
72    FileSaved: "fileSaved",
73    RevertRevision: "revertRevision",
74    ApplyOriginalContent: "applyOriginalContent",
75    TogglePrettyPrint: "togglePrettyPrint",
76    SetBreakpoint: "setBreakpoint",
77    OpenSourceLink: "openSourceLink",
78    NetworkSort: "networkSort",
79    NetworkRequestSelected: "networkRequestSelected",
80    NetworkRequestTabSelected: "networkRequestTabSelected",
81    HeapSnapshotFilterChanged: "heapSnapshotFilterChanged"
82};
83
84WebInspector.UserMetrics.prototype = {
85    panelShown: function(panelName)
86    {
87        InspectorFrontendHost.recordPanelShown(WebInspector.UserMetrics._PanelCodes[panelName] || 0);
88    }
89}
90
91/**
92 * @constructor
93 */
94WebInspector.UserMetrics._Recorder = function(actionCode)
95{
96    this._actionCode = actionCode;
97}
98
99WebInspector.UserMetrics._Recorder.prototype = {
100    record: function()
101    {
102        InspectorFrontendHost.recordActionTaken(this._actionCode);
103    }
104}
105
106WebInspector.userMetrics = new WebInspector.UserMetrics();
107