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

Unified Diff: chrome/browser/resources/quota_internals/message_dispatcher.js

Issue 7053009: Add chrome://quota-internals/ resources (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/quota_internals/message_dispatcher.js
diff --git a/chrome/browser/resources/quota_internals/message_dispatcher.js b/chrome/browser/resources/quota_internals/message_dispatcher.js
new file mode 100644
index 0000000000000000000000000000000000000000..37e5e94ad3c4779929988b3a7a4c7351deb75378
--- /dev/null
+++ b/chrome/browser/resources/quota_internals/message_dispatcher.js
@@ -0,0 +1,82 @@
+// 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.
+
+// require cr.js
+// require cr/event_target.js
+// require cr/util.js
+
+/**
+ * Bridge between the browser and the page.
+ * In this file:
+ * * define EventTargets to recieve message from the browser,
+ * * dispatch browser messages to EventTarget,
+ * * define interface to request data to the browser.
+ */
+
+cr.define('cr.quota', function() {
+ 'use strict';
+
+ /**
+ * Post requestData message to Browser.
+ */
+ function requestData() {
+ chrome.send('requestData');
+ }
+
+ /**
+ * Callback entry point from Browser.
+ * Messages are Dispatched as Event to:
+ * * onAvailableSpaceUpdated,
+ * * onGlobalDataUpdated,
+ * * onHostDataUpdated,
+ * * onOriginDataUpdated,
+ * * onStatisticsUpdated.
+ * @param {string} message Message label. Possible Values are:
+ * * 'AvailableSpaceUpdated',
+ * * 'GlobalDataUpdated',
+ * * 'HostDataUpdated',
+ * * 'OriginDataUpdated',
+ * * 'StatisticsUpdated'.
+ * @param {Object} detail Message specific additional data.
+ */
+ function messageHandler(message, detail) {
+ var target = null;
+ switch (message) {
+ case 'AvailableSpaceUpdated':
+ target = cr.quota.onAvailableSpaceUpdated;
+ break;
+ case 'GlobalDataUpdated':
+ target = cr.quota.onGlobalDataUpdated;
+ break;
+ case 'HostDataUpdated':
+ target = cr.quota.onHostDataUpdated;
+ break;
+ case 'OriginDataUpdated':
+ target = cr.quota.onOriginDataUpdated;
+ break;
+ case 'StatisticsUpdated':
+ target = cr.quota.onStatisticsUpdated;
+ break;
+ default:
+ console.error('Unknown Message');
+ break;
+ }
+ if (target) {
+ var event = cr.doc.createEvent('CustomEvent');
+ event.initCustomEvent('update', false, false, detail);
+ target.dispatchEvent(event);
+ }
+ }
+
+ return {
+ onAvailableSpaceUpdated: new cr.EventTarget(),
+ onGlobalDataUpdated: new cr.EventTarget(),
+ onHostDataUpdated: new cr.EventTarget(),
+ onOriginDataUpdated: new cr.EventTarget(),
+ onStatisticsUpdated: new cr.EventTarget(),
+
+ requestData: requestData,
+ messageHandler: messageHandler
+ };
+});
« no previous file with comments | « chrome/browser/resources/quota_internals/main.html ('k') | chrome/browser/resources/quota_internals_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698