Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: chrome/browser/resources/quota_internals/mock_chrome_message.js

Issue 7053009: Add chrome://quota-internals/ resources (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add comment, merge test.html to index.html. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * Mock browser interface for chrome://quota-internals/ test mode.
7 */
8
9 (function() {
10 'use strict';
11
12 // If we have |chrome.send|, then the page is run as WebUI page,
13 // and we need not provide mock interface.
14 if (!window.chrome || !chrome.send) {
15 document.title += ' (test mode)';
16
17 /**
18 * |available_space| is to be passed as payload of
19 * 'AvailableSpaceUpdated' message.
20 * @type {string} Available disk space for profile directory.
21 */
22 var available_space = '1000000000000';
23
24 /**
25 * |global_data_temporary| and |global_data_persistent| are to be passed as
26 * payload of 'GlobalDataUpdated' message.
27 * This records contain:
28 * |type|:
29 * Storage type. "temporary" or "persistent".
30 * |usage|:
31 * Total usage of this storage.
32 * |unlimited_usage|:
33 * Usage of the storage used by unlimited-quota origins.
34 * |quota|:
35 * Upper limit for total usage of this storage.
36 * This field is available for temporary storage only.
37 * @type {{
38 * type: {!string},
39 * usage: {?string},
40 * unlimited_usage: {?string},
41 * quota: {?string}
42 * }}
43 */
44 var global_data_temporary = {
45 type: 'temporary',
46 usage: '1000',
47 unlimited_usage: '100',
48 quota: '1000000'
49 };
50 var global_data_persistent = {
51 type: 'persistent',
52 usage: '10',
53 quota: '10000'
54 };
55
56 /**
57 * |host_data| is an array, to be pased with 'HostDataUpdated' message.
58 * Each of elements is a record contains:
59 * |host|:
60 * Host name.
61 * |type|:
62 * Storage type. "temporary" or "persistent"
63 * |usage|:
64 * Total usage of the storage for the host.
65 * |quota|:
66 * Upper limit for usage of the storage for this host.
67 * This field is available for persistent storage only.
68 * @type {Array.<{
69 * host: {!string},
70 * type: {!string},
71 * usage: {?string},
72 * quota: {?string}
73 * }>}
74 */
75 var host_data = [{
76 host: 'example.com',
77 type: 'temporary',
78 usage: '0'
79 }, {
80 host: 'example.com',
81 type: 'persistent',
82 usage: '0',
83 quota: '0'
84 }];
85
86 /**
87 * |origin_data| is an array, to be passed with 'OriginDataUpdated' message.
88 * Each of elements contains:
89 * |origin|:
90 * Origin URL of this entry.
91 * |type|:
92 * Storage type. "temporary" or "persistent"
93 * |host|:
94 * Host name of the |origin|.
95 * |in_use|:
96 * True if the storage is in use by the origin.
97 * |used_count|:
98 * Count of
99 * |last_access_time|:
100 * Last access time of the origin.
101 * Number of millisecond from Jan 1, 1970.
102 * @type {Array.<{
103 * origin: {!string},
104 * type: {!string},
105 * host: {!string},
106 * in_use: {?boolean}
107 * used_count: {?number},
108 * last_access_time: {?number}
109 * }>}
110 */
111 var origin_data = [{
112 origin: 'http://example.com/',
113 type: 'temporary',
114 host: 'example.com',
115 in_use: true,
116 used_count: 1,
117 last_access_time: Date.now()
118 }, {
119 origin: 'http://example.com/',
120 type: 'persistent',
121 host: 'example.com'
122 }];
123
124 /**
125 * |stat_data| is to be passed with 'StatisticsUpdated' message.
126 * @type {Object} Key-value pair of strings.
127 */
128 var stat_data = {
129 'eviction-rounds': '1000',
130 'evicted-origins': '123'
131 };
132
133 if (!window.chrome)
134 window.chrome = {};
135 window.chrome.send = function(msg, param) {
136 switch (msg) {
137 case 'requestData':
138 cr.quota.messageHandler_('AvailableSpaceUpdated', available_space);
139 cr.quota.messageHandler_('GlobalDataUpdated', global_data_temporary);
140 cr.quota.messageHandler_('GlobalDataUpdated', global_data_persistent);
141 cr.quota.messageHandler_('HostDataUpdated', host_data);
142 cr.quota.messageHandler_('OriginDataUpdated', origin_data);
143 cr.quota.messageHandler_('StatisticsUpdated', stat_data);
144 break;
145 default:
146 console.log('Unknown Message: ' + msg);
147 break;
148 }
149 };
150 }
151
152 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698