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

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

Issue 7259007: Revert 90447 - Add chrome://quota-internals/ resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 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 // require cr.js
6 // require cr/event_target.js
7 // require cr/util.js
8
9 /**
10 * Bridge between the browser and the page.
11 * In this file:
12 * * define EventTargets to recieve message from the browser,
13 * * dispatch browser messages to EventTarget,
14 * * define interface to request data to the browser.
15 */
16
17 cr.define('cr.quota', function() {
18 'use strict';
19
20 /**
21 * Post requestData message to Browser.
22 */
23 function requestData() {
24 chrome.send('requestData');
25 }
26
27 /**
28 * Callback entry point from Browser.
29 * Messages are Dispatched as Event to:
30 * * onAvailableSpaceUpdated,
31 * * onGlobalDataUpdated,
32 * * onHostDataUpdated,
33 * * onOriginDataUpdated,
34 * * onStatisticsUpdated.
35 * @param {string} message Message label. Possible Values are:
36 * * 'AvailableSpaceUpdated',
37 * * 'GlobalDataUpdated',
38 * * 'HostDataUpdated',
39 * * 'OriginDataUpdated',
40 * * 'StatisticsUpdated'.
41 * @param {Object} detail Message specific additional data.
42 */
43 function messageHandler(message, detail) {
44 var target = null;
45 switch (message) {
46 case 'AvailableSpaceUpdated':
47 target = cr.quota.onAvailableSpaceUpdated;
48 break;
49 case 'GlobalDataUpdated':
50 target = cr.quota.onGlobalDataUpdated;
51 break;
52 case 'HostDataUpdated':
53 target = cr.quota.onHostDataUpdated;
54 break;
55 case 'OriginDataUpdated':
56 target = cr.quota.onOriginDataUpdated;
57 break;
58 case 'StatisticsUpdated':
59 target = cr.quota.onStatisticsUpdated;
60 break;
61 default:
62 console.error('Unknown Message');
63 break;
64 }
65 if (target) {
66 var event = cr.doc.createEvent('CustomEvent');
67 event.initCustomEvent('update', false, false, detail);
68 target.dispatchEvent(event);
69 }
70 }
71
72 return {
73 onAvailableSpaceUpdated: new cr.EventTarget(),
74 onGlobalDataUpdated: new cr.EventTarget(),
75 onHostDataUpdated: new cr.EventTarget(),
76 onOriginDataUpdated: new cr.EventTarget(),
77 onStatisticsUpdated: new cr.EventTarget(),
78
79 requestData: requestData,
80 messageHandler: messageHandler
81 };
82 });
OLDNEW
« 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