| Index: chrome/browser/resources/quota_internals/mock_chrome_message.js
|
| diff --git a/chrome/browser/resources/quota_internals/mock_chrome_message.js b/chrome/browser/resources/quota_internals/mock_chrome_message.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..efed121d6fe8aaa270fb6910073b25dfae018b28
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/quota_internals/mock_chrome_message.js
|
| @@ -0,0 +1,152 @@
|
| +// Copyright (c) 2011 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.
|
| +
|
| +/**
|
| + * Mock browser interface for chrome://quota-internals/ test mode.
|
| + */
|
| +
|
| +(function() {
|
| +'use strict';
|
| +
|
| +// If we have |chrome.send|, then the page is run as WebUI page,
|
| +// and we need not provide mock interface.
|
| +if (!window.chrome || !chrome.send) {
|
| + document.title += ' (test mode)';
|
| +
|
| + /**
|
| + * |available_space| is to be passed as payload of
|
| + * 'AvailableSpaceUpdated' message.
|
| + * @type {string} Available disk space for profile directory.
|
| + */
|
| + var available_space = '1000000000000';
|
| +
|
| + /**
|
| + * |global_data_temporary| and |global_data_persistent| are to be passed as
|
| + * payload of 'GlobalDataUpdated' message.
|
| + * This records contain:
|
| + * |type|:
|
| + * Storage type. "temporary" or "persistent".
|
| + * |usage|:
|
| + * Total usage of this storage.
|
| + * |unlimited_usage|:
|
| + * Usage of the storage used by unlimited-quota origins.
|
| + * |quota|:
|
| + * Upper limit for total usage of this storage.
|
| + * This field is available for temporary storage only.
|
| + * @type {{
|
| + * type: {!string},
|
| + * usage: {?string},
|
| + * unlimited_usage: {?string},
|
| + * quota: {?string}
|
| + * }}
|
| + */
|
| + var global_data_temporary = {
|
| + type: 'temporary',
|
| + usage: '1000',
|
| + unlimited_usage: '100',
|
| + quota: '1000000'
|
| + };
|
| + var global_data_persistent = {
|
| + type: 'persistent',
|
| + usage: '10',
|
| + quota: '10000'
|
| + };
|
| +
|
| + /**
|
| + * |host_data| is an array, to be pased with 'HostDataUpdated' message.
|
| + * Each of elements is a record contains:
|
| + * |host|:
|
| + * Host name.
|
| + * |type|:
|
| + * Storage type. "temporary" or "persistent"
|
| + * |usage|:
|
| + * Total usage of the storage for the host.
|
| + * |quota|:
|
| + * Upper limit for usage of the storage for this host.
|
| + * This field is available for persistent storage only.
|
| + * @type {Array.<{
|
| + * host: {!string},
|
| + * type: {!string},
|
| + * usage: {?string},
|
| + * quota: {?string}
|
| + * }>}
|
| + */
|
| + var host_data = [{
|
| + host: 'example.com',
|
| + type: 'temporary',
|
| + usage: '0'
|
| + }, {
|
| + host: 'example.com',
|
| + type: 'persistent',
|
| + usage: '0',
|
| + quota: '0'
|
| + }];
|
| +
|
| + /**
|
| + * |origin_data| is an array, to be passed with 'OriginDataUpdated' message.
|
| + * Each of elements contains:
|
| + * |origin|:
|
| + * Origin URL of this entry.
|
| + * |type|:
|
| + * Storage type. "temporary" or "persistent"
|
| + * |host|:
|
| + * Host name of the |origin|.
|
| + * |in_use|:
|
| + * True if the storage is in use by the origin.
|
| + * |used_count|:
|
| + * Count of
|
| + * |last_access_time|:
|
| + * Last access time of the origin.
|
| + * Number of millisecond from Jan 1, 1970.
|
| + * @type {Array.<{
|
| + * origin: {!string},
|
| + * type: {!string},
|
| + * host: {!string},
|
| + * in_use: {?boolean}
|
| + * used_count: {?number},
|
| + * last_access_time: {?number}
|
| + * }>}
|
| + */
|
| + var origin_data = [{
|
| + origin: 'http://example.com/',
|
| + type: 'temporary',
|
| + host: 'example.com',
|
| + in_use: true,
|
| + used_count: 1,
|
| + last_access_time: Date.now()
|
| + }, {
|
| + origin: 'http://example.com/',
|
| + type: 'persistent',
|
| + host: 'example.com'
|
| + }];
|
| +
|
| + /**
|
| + * |stat_data| is to be passed with 'StatisticsUpdated' message.
|
| + * @type {Object} Key-value pair of strings.
|
| + */
|
| + var stat_data = {
|
| + 'eviction-rounds': '1000',
|
| + 'evicted-origins': '123'
|
| + };
|
| +
|
| + if (!window.chrome)
|
| + window.chrome = {};
|
| + window.chrome.send = function(msg, param) {
|
| + switch (msg) {
|
| + case 'requestData':
|
| + cr.quota.messageHandler_('AvailableSpaceUpdated', available_space);
|
| + cr.quota.messageHandler_('GlobalDataUpdated', global_data_temporary);
|
| + cr.quota.messageHandler_('GlobalDataUpdated', global_data_persistent);
|
| + cr.quota.messageHandler_('HostDataUpdated', host_data);
|
| + cr.quota.messageHandler_('OriginDataUpdated', origin_data);
|
| + cr.quota.messageHandler_('StatisticsUpdated', stat_data);
|
| + break;
|
| + default:
|
| + console.log('Unknown Message: ' + msg);
|
| + break;
|
| + }
|
| + };
|
| +}
|
| +
|
| +})();
|
|
|