summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/discards/database_tab.html
blob: 6c234286474b121db2b63c88f97ff57758a8e7ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!--
Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.

This is an internal only page meant for debugging. It is not intended for
general use and is not localized.
-->
<link rel="import" href="chrome://resources/html/polymer.html">

<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="mojo_api.html">
<link rel="import" href="sorted_table_behavior.html">

<dom-module id="database-tab">
  <template>
    <style>
      .add-origin-container {
        display: flex;
        padding-top: 10px;
      }

      table {
        border-collapse: collapse;
      }

      table td,
      table th {
        border: 1px solid #777;
        padding-left: 4px;
        padding-right: 4px;
      }

      table th {
        background: rgb(224, 236, 255);
        padding-bottom: 4px;
        padding-inline-end: 16px;
        padding-top: 4px;
        white-space: nowrap;
      }

      .header-cell-container {
        align-items: center;
        display: flex;
        justify-content: flex-start;
      }

      table th[data-sort-key] {
        cursor: pointer;
      }

      th div.header-cell-container::after {
        content: '▲';
        opacity: 0;
      }

      th.sort-column div.header-cell-container::after {
        content: '▲';
        opacity: 1;
      }

      th.sort-column-reverse div.header-cell-container::after {
        content: '▼';
        opacity: 1;
      }
    </style>
    <div>
      <div>Database Rows: [[optionalIntegerToString_(size_.numRows)]]</div>
      <div>Database Size: [[kilobytesToString_(size_.onDiskSizeKb)]]</div>
    </div>
    <table>
      <thead>
        <tr>
          <th data-sort-key="origin" class="sort-column" on-click="onSortClick">
            <div class="header-cell-container">
              Origin
            </div>
          </th>
          <th data-sort-key="dirty" on-click="onSortClick">
            <div class="header-cell-container">
              Dirty
            </div>
          </th>
          <th data-sort-key="lastLoaded" on-click="onSortClick">
            <div class="header-cell-container">
              Last Loaded
            </div>
          </th>
          <th>
            <div class="header-cell-container">
              <div>
                <div>Updates Favicon</div>
                <div>In Background</div>
              </div>
            </div>
          </th>
          <th>
            <div class="header-cell-container">
              <div>
                <div>Updates Title</div>
                <div>In Background</div>
              </div>
            </div>
          </th>
          <th>
            <div class="header-cell-container">
              <div>
                <div>Used Audio</div>
                <div>In Background</div>
              </div>
            </div>
          </th>
          <th>
            <div class="header-cell-container">
              <div>
                <div>Uses Notifications</div>
                <div>In Background</div>
              </div>
            </div>
          </th>
          <th data-sort-key="cpuUsage" on-click="onSortClick">
            <div class="header-cell-container">
              <div>
                <div>Average</div>
                <div>CPU Usage</div>
              </div>
            </div>
          </th>
          <th data-sort-key="memoryUsage" on-click="onSortClick">
            <div class="header-cell-container">
              <div>
                <div>Average Memory</div>
                <div>Footprint</div>
              </div>
            </div>
          </th>
          <th data-sort-key="loadDuration" on-click="onSortClick">
            <div class="header-cell-container">
              <div>
                <div>Average Load</div>
                <div>Time</div>
            </div>
            </div>
          </th>
        </tr>
      </thead>
      <tbody>
        <template is="dom-repeat" items="[[rows_]]"
            sort="[[computeSortFunction_(sortKey, sortReverse)]]">
          <tr>
            <td class="origin-cell">[[item.origin]]</td>
            <td class="dirty-cell">[[boolToString_(item.isDirty)]]</td>
            <td>[[lastUseToString_(item.value.lastLoaded)]]</td>
            <td>[[featureToString_(item.value.updatesFaviconInBackground)]]</td>
            <td>[[featureToString_(item.value.updatesTitleInBackground)]]</td>
            <td>[[featureToString_(item.value.usesAudioInBackground)]]</td>
            <td>
                [[featureToString_(item.value.usesNotificationsInBackground)]]
            </td>
            <td>[[getLoadTimeEstimate_(item, "avgCpuUsageUs")]]</td>
            <td>[[getLoadTimeEstimate_(item, "avgFootprintKb")]]</td>
            <td>[[getLoadTimeEstimate_(item, "avgLoadDurationUs")]]</td>
          </tr>
        </template>
      </tbody>
    </table>
    <div class="add-origin-container">
      <cr-input id="addOriginInput" label="Add Origin" value="{{newOrigin_}}"
           on-keydown="onOriginKeydown_" placeholder="https://example.org"
           invalid="[[!isEmptyOrValidOrigin_(newOrigin_)]]"
           error-message="The origin must be a valid URL without a path."
           autofocus>
        <button slot="suffix" label="Add Origin"
            on-click="onAddOriginClick_"
            disabled="[[!isValidOrigin_(newOrigin_)]]">
          <iron-icon icon="cr:check"></iron-icon>
        </button>
      </cr-input>
    </div>
  </template>
  <script src="database_tab.js"></script>
</dom-module>