Index: ui/webui/resources/js/cr.js |
diff --git a/ui/webui/resources/js/cr.js b/ui/webui/resources/js/cr.js |
index ceb1eb9707474fb9d91f9bc6b12ad5b13858569f..535c85a310948cc67d047b8ca4098b554ce3582a 100644 |
--- a/ui/webui/resources/js/cr.js |
+++ b/ui/webui/resources/js/cr.js |
@@ -320,7 +320,7 @@ var cr = function() { |
* is unique across all invocations of said method. |
* @type {!Map<string, Function>} |
Dan Beam
2015/07/09 21:03:27
^ fix
James Hawkins
2015/07/09 22:02:50
Done.
|
*/ |
- var chromeSendCallbackMap = new Map(); |
+ var chromeSendCallbackMap = Object.create(null); |
/** |
* The named method the WebUI handler calls directly in response to a |
@@ -335,9 +335,9 @@ var cr = function() { |
* response is tied to. |
*/ |
function webUIResponse(id) { |
- chromeSendCallbackMap.get(id).apply( |
+ chromeSendCallbackMap[id].apply( |
null, Array.prototype.slice.call(arguments, 1)); |
- chromeSendCallbackMap.delete(id); |
+ delete chromeSendCallbackMap[id]; |
} |
/** |
@@ -353,7 +353,7 @@ var cr = function() { |
*/ |
function sendWithCallback(methodName, args, callback) { |
var id = methodName + createUid(); |
- chromeSendCallbackMap.set(id, callback); |
+ chromeSendCallbackMap[id] = callback; |
chrome.send(methodName, ['cr.webUIResponse', id].concat(args || [])); |
} |
@@ -362,7 +362,7 @@ var cr = function() { |
* register listeners. |
* @type {!Map<string, Array<Function>>} |
*/ |
- var webUIListenerMap = new Map(); |
+ var webUIListenerMap = Object.create(null); |
/** |
* The named method the WebUI handler calls directly when an event occurs. |
@@ -372,7 +372,7 @@ var cr = function() { |
* @param {string} event The name of the event that has occurred. |
*/ |
function webUIListenerCallback(event) { |
- var listenerCallbacks = webUIListenerMap.get(event); |
+ var listenerCallbacks = webUIListenerMap[event]; |
for (var i = 0; i < listenerCallbacks.length; i++) { |
Dan Beam
2015/07/09 21:03:27
wait, this doesn't make much sense...
chrome.send
James Hawkins
2015/07/09 22:02:50
The code you're commenting is the event listener c
Dan Beam
2015/07/09 22:11:15
ah, no.
btw, i just saw the createUid() that hand
|
var callback = listenerCallbacks[i]; |
callback.apply(null, Array.prototype.slice.call(arguments, 1)); |
@@ -386,10 +386,10 @@ var cr = function() { |
* @param {Function} callback The callback run when the event is fired. |
*/ |
function addWebUIListener(event, callback) { |
- if (!webUIListenerMap.has(event)) |
- webUIListenerMap.set(event, [callback]); |
+ if (event in webUIListenerMap) |
+ webUIListenerMap[event].push(callback); |
else |
- webUIListenerMap.get(event).push(callback); |
+ webUIListenerMap[event] = [callback]; |
} |
return { |