| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** | 5 /** |
| 6 * WebUI to monitor the Sync File System Service. | 6 * WebUI to monitor the Sync File System Service. |
| 7 */ | 7 */ |
| 8 var SyncService = (function() { | 8 var SyncService = (function() { |
| 9 'use strict'; | 9 'use strict'; |
| 10 | 10 |
| 11 var SyncService = {}; | 11 var SyncService = {}; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Request Sync Service Status. | 14 * Request Sync Service Status. |
| 15 */ | 15 */ |
| 16 function getServiceStatus() { | 16 function getServiceStatus() { |
| 17 chrome.send('getServiceStatus'); | 17 chrome.send('getServiceStatus'); |
| 18 } | 18 } |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Called when service status is initially retrieved or updated via events. | 21 * Called when service status is initially retrieved or updated via events. |
| 22 * @param {string} Service status enum as a string. | 22 * @param {string} Service status enum as a string. |
| 23 */ | 23 */ |
| 24 SyncService.onGetServiceStatus = function(statusString) { | 24 SyncService.onGetServiceStatus = function(statusString) { |
| 25 $('service-status').textContent = statusString; | 25 $('service-status').textContent = statusString; |
| 26 } | 26 }; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Request Google Drive Notification Source. e.g. XMPP or polling. | 29 * Request Google Drive Notification Source. e.g. XMPP or polling. |
| 30 */ | 30 */ |
| 31 function getNotificationSource() { | 31 function getNotificationSource() { |
| 32 chrome.send('getNotificationSource'); | 32 chrome.send('getNotificationSource'); |
| 33 } | 33 } |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Handles callback from getNotificationSource. | 36 * Handles callback from getNotificationSource. |
| 37 * @param {string} Notification source as a string. | 37 * @param {string} Notification source as a string. |
| 38 */ | 38 */ |
| 39 SyncService.onGetNotificationSource = function(sourceString) { | 39 SyncService.onGetNotificationSource = function(sourceString) { |
| 40 $('notification-source').textContent = sourceString; | 40 $('notification-source').textContent = sourceString; |
| 41 } | 41 }; |
| 42 | 42 |
| 43 // Keeps track of the last log event seen so it's not reprinted. | 43 // Keeps track of the last log event seen so it's not reprinted. |
| 44 var lastLogEventId = -1; | 44 var lastLogEventId = -1; |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Request debug log. | 47 * Request debug log. |
| 48 */ | 48 */ |
| 49 function getLog() { | 49 function getLog() { |
| 50 chrome.send('getLog', [lastLogEventId]); | 50 chrome.send('getLog', [lastLogEventId]); |
| 51 } | 51 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 69 var tr = document.createElement('tr'); | 69 var tr = document.createElement('tr'); |
| 70 var error = /ERROR/.test(logEntry.logEvent) ? ' error' : ''; | 70 var error = /ERROR/.test(logEntry.logEvent) ? ' error' : ''; |
| 71 tr.appendChild(createElementFromText('td', logEntry.time, | 71 tr.appendChild(createElementFromText('td', logEntry.time, |
| 72 {'class': 'log-time'})); | 72 {'class': 'log-time'})); |
| 73 tr.appendChild(createElementFromText('td', logEntry.logEvent, | 73 tr.appendChild(createElementFromText('td', logEntry.logEvent, |
| 74 {'class': 'log-event' + error})); | 74 {'class': 'log-event' + error})); |
| 75 itemContainer.appendChild(tr); | 75 itemContainer.appendChild(tr); |
| 76 | 76 |
| 77 lastLogEventId = logEntry.id; | 77 lastLogEventId = logEntry.id; |
| 78 } | 78 } |
| 79 } | 79 }; |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Get initial sync service values and set listeners to get updated values. | 82 * Get initial sync service values and set listeners to get updated values. |
| 83 */ | 83 */ |
| 84 function main() { | 84 function main() { |
| 85 cr.ui.decorate('tabbox', cr.ui.TabBox); | 85 cr.ui.decorate('tabbox', cr.ui.TabBox); |
| 86 $('clear-log-button').addEventListener('click', clearLogs); | 86 $('clear-log-button').addEventListener('click', clearLogs); |
| 87 getServiceStatus(); | 87 getServiceStatus(); |
| 88 getNotificationSource(); | 88 getNotificationSource(); |
| 89 | 89 |
| 90 // TODO: Look for a way to push entries to the page when necessary. | 90 // TODO: Look for a way to push entries to the page when necessary. |
| 91 window.setInterval(getLog, 1000); | 91 window.setInterval(getLog, 1000); |
| 92 } | 92 } |
| 93 | 93 |
| 94 document.addEventListener('DOMContentLoaded', main); | 94 document.addEventListener('DOMContentLoaded', main); |
| 95 return SyncService; | 95 return SyncService; |
| 96 })(); | 96 })(); |
| OLD | NEW |