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

Side by Side Diff: chrome/browser/resources/sync_file_system_internals/sync_service.js

Issue 16404008: Do not create instance just to expose SyncService methods from sync_service.js (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 function SyncService() { 11 function SyncService() {
Bernhard Bauer 2013/06/10 14:18:49 SyncService doesn't need to be a function now, it
kinuko 2013/06/10 14:44:26 Done.
12 } 12 }
13 13
14 /** 14 /**
15 * Request Sync Service Status. 15 * Request Sync Service Status.
16 */ 16 */
17 function getServiceStatus() { 17 function getServiceStatus() {
18 chrome.send('getServiceStatus'); 18 chrome.send('getServiceStatus');
19 } 19 }
20 20
21 /** 21 /**
22 * Handles callback from getServiceStatus. 22 * Handles callback from getServiceStatus.
23 * @param {string} Service status enum as a string. 23 * @param {string} Service status enum as a string.
24 */ 24 */
25 SyncService.prototype.onGetServiceStatus = function(statusString) { 25 SyncService.onGetServiceStatus = function(statusString) {
26 $('service-status').textContent = statusString; 26 $('service-status').textContent = statusString;
27 } 27 }
28 28
29 /** 29 /**
30 * Request Google Drive Notification Source. e.g. XMPP or polling. 30 * Request Google Drive Notification Source. e.g. XMPP or polling.
31 */ 31 */
32 function getNotificationSource() { 32 function getNotificationSource() {
33 chrome.send('getNotificationSource'); 33 chrome.send('getNotificationSource');
34 } 34 }
35 35
36 /** 36 /**
37 * Handles callback from getNotificationSource. 37 * Handles callback from getNotificationSource.
38 * @param {string} Notification source as a string. 38 * @param {string} Notification source as a string.
39 */ 39 */
40 SyncService.prototype.onGetNotificationSource = function(sourceString) { 40 SyncService.onGetNotificationSource = function(sourceString) {
41 $('notification-source').textContent = sourceString; 41 $('notification-source').textContent = sourceString;
42 } 42 }
43 43
44 /** 44 /**
45 * Creates an element named |elementName| containing the content |text|. 45 * Creates an element named |elementName| containing the content |text|.
46 * @param {string} elementName Name of the new element to be created. 46 * @param {string} elementName Name of the new element to be created.
47 * @param {string} text Text to be contained in the new element. 47 * @param {string} text Text to be contained in the new element.
48 * @return {HTMLElement} The newly created HTML element. 48 * @return {HTMLElement} The newly created HTML element.
49 */ 49 */
50 function createElementFromText(elementName, text) { 50 function createElementFromText(elementName, text) {
51 var element = document.createElement(elementName); 51 var element = document.createElement(elementName);
52 element.appendChild(document.createTextNode(text)); 52 element.appendChild(document.createTextNode(text));
53 return element; 53 return element;
54 } 54 }
55 55
56 /** 56 /**
57 * Request debug log. 57 * Request debug log.
58 */ 58 */
59 function getLog() { 59 function getLog() {
60 chrome.send('getLog'); 60 chrome.send('getLog');
61 } 61 }
62 62
63 /** 63 /**
64 * Handles callback from getUpdateLog. 64 * Handles callback from getUpdateLog.
65 * @param {Array} list List of dictionaries containing 'time' and 'logEvent'. 65 * @param {Array} list List of dictionaries containing 'time' and 'logEvent'.
66 */ 66 */
67 SyncService.prototype.onGetLog = function(logEntries) { 67 SyncService.onGetLog = function(logEntries) {
68 var itemContainer = $('log-entries'); 68 var itemContainer = $('log-entries');
69 for (var i = 0; i < logEntries.length; i++) { 69 for (var i = 0; i < logEntries.length; i++) {
70 var logEntry = logEntries[i]; 70 var logEntry = logEntries[i];
71 var tr = document.createElement('tr'); 71 var tr = document.createElement('tr');
72 tr.appendChild(createElementFromText('td', logEntry.time)); 72 tr.appendChild(createElementFromText('td', logEntry.time));
73 tr.appendChild(createElementFromText('td', logEntry.logEvent)); 73 tr.appendChild(createElementFromText('td', logEntry.logEvent));
74 itemContainer.appendChild(tr); 74 itemContainer.appendChild(tr);
75 } 75 }
76 } 76 }
77 77
78 /** 78 /**
79 * Get initial sync service values and set listeners to get updated values. 79 * Get initial sync service values and set listeners to get updated values.
80 */ 80 */
81 function main() { 81 function main() {
82 cr.ui.decorate('tabbox', cr.ui.TabBox); 82 cr.ui.decorate('tabbox', cr.ui.TabBox);
83 getServiceStatus(); 83 getServiceStatus();
84 getNotificationSource(); 84 getNotificationSource();
85 window.setInterval(getLog, 1000); 85 window.setInterval(getLog, 1000);
Bernhard Bauer 2013/06/10 14:18:49 This makes me sad. Can't we push entries to the pa
kinuko 2013/06/10 14:44:26 Right, we're aware that it's not the ideal behavio
86 } 86 }
87 87
88 document.addEventListener('DOMContentLoaded', main); 88 document.addEventListener('DOMContentLoaded', main);
89 return new SyncService; 89 return SyncService;
90 })(); 90 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698