OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('chrome.invalidations', function() { | 5 cr.define('chrome.invalidations', function() { |
6 /** | 6 /** |
7 * Local variable where we maintain a count of the invalidations received | 7 * Local variable where we maintain a count of the invalidations received |
8 * and of every ObjectId that has ever been updated (note that this doesn't | 8 * and of every ObjectId that has ever been updated (note that this doesn't |
9 * log any invalidations ocurred prior to opening the about:invalidation | 9 * log any invalidations ocurred prior to opening the about:invalidation |
10 * page). | 10 * page). |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 var logMessage = nowTimeString() + | 61 var logMessage = nowTimeString() + |
62 'Invalidations service state changed to ' + quote(newState); | 62 'Invalidations service state changed to ' + quote(newState); |
63 | 63 |
64 appendToLog(logMessage); | 64 appendToLog(logMessage); |
65 $('invalidations-state').textContent = newState + ' (since ' + | 65 $('invalidations-state').textContent = newState + ' (since ' + |
66 new Date(lastChangedTime) + ')'; | 66 new Date(lastChangedTime) + ')'; |
67 } | 67 } |
68 | 68 |
69 /** | 69 /** |
70 * Adds to the log the latest invalidations received | 70 * Adds to the log the latest invalidations received |
71 * @param {!Array.<!Object>} allInvalidations The array of ObjectId | 71 * @param {!Array<!Object>} allInvalidations The array of ObjectId |
72 * that contains the invalidations received by the InvalidatorService. | 72 * that contains the invalidations received by the InvalidatorService. |
73 */ | 73 */ |
74 function logInvalidations(allInvalidations) { | 74 function logInvalidations(allInvalidations) { |
75 for (var i = 0; i < allInvalidations.length; i++) { | 75 for (var i = 0; i < allInvalidations.length; i++) { |
76 var inv = allInvalidations[i]; | 76 var inv = allInvalidations[i]; |
77 if (inv.hasOwnProperty('objectId')) { | 77 if (inv.hasOwnProperty('objectId')) { |
78 var logMessage = nowTimeString() + | 78 var logMessage = nowTimeString() + |
79 'Received Invalidation with type ' + | 79 'Received Invalidation with type ' + |
80 quote(inv.objectId.name) + | 80 quote(inv.objectId.name) + |
81 ' version ' + | 81 ' version ' + |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 tableObjects[key].sessionCount = tableObjects[key].sessionCount + 1; | 132 tableObjects[key].sessionCount = tableObjects[key].sessionCount + 1; |
133 tableObjects[key].time = time.toTimeString(); | 133 tableObjects[key].time = time.toTimeString(); |
134 tableObjects[key].version = version; | 134 tableObjects[key].version = version; |
135 tableObjects[key].payload = payload; | 135 tableObjects[key].payload = payload; |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 /** | 139 /** |
140 * Shows the handlers that are currently registered for invalidations | 140 * Shows the handlers that are currently registered for invalidations |
141 * (but might not have objects ids registered yet). | 141 * (but might not have objects ids registered yet). |
142 * @param {!Array.<string>} allHandlers An array of Strings that are | 142 * @param {!Array<string>} allHandlers An array of Strings that are |
143 * the names of all the handlers currently registered in the | 143 * the names of all the handlers currently registered in the |
144 * InvalidatorService. | 144 * InvalidatorService. |
145 */ | 145 */ |
146 function updateHandlers(allHandlers) { | 146 function updateHandlers(allHandlers) { |
147 var allHandlersFormatted = allHandlers.join(', '); | 147 var allHandlersFormatted = allHandlers.join(', '); |
148 $('registered-handlers').textContent = allHandlersFormatted; | 148 $('registered-handlers').textContent = allHandlersFormatted; |
149 var logMessage = nowTimeString() + | 149 var logMessage = nowTimeString() + |
150 'InvalidatorHandlers currently registered: ' + allHandlersFormatted; | 150 'InvalidatorHandlers currently registered: ' + allHandlersFormatted; |
151 appendToLog(logMessage); | 151 appendToLog(logMessage); |
152 } | 152 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 logInvalidations: logInvalidations, | 204 logInvalidations: logInvalidations, |
205 onLoadWork: onLoadWork, | 205 onLoadWork: onLoadWork, |
206 updateDetailedStatus: updateDetailedStatus, | 206 updateDetailedStatus: updateDetailedStatus, |
207 updateHandlers: updateHandlers, | 207 updateHandlers: updateHandlers, |
208 updateIds: updateIds, | 208 updateIds: updateIds, |
209 updateInvalidatorState: updateInvalidatorState, | 209 updateInvalidatorState: updateInvalidatorState, |
210 }; | 210 }; |
211 }); | 211 }); |
212 | 212 |
213 document.addEventListener('DOMContentLoaded', chrome.invalidations.onLoadWork); | 213 document.addEventListener('DOMContentLoaded', chrome.invalidations.onLoadWork); |
OLD | NEW |