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

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: addressed comments 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 var SyncService = {};
12 }
13 12
14 /** 13 /**
15 * Request Sync Service Status. 14 * Request Sync Service Status.
16 */ 15 */
17 function getServiceStatus() { 16 function getServiceStatus() {
18 chrome.send('getServiceStatus'); 17 chrome.send('getServiceStatus');
19 } 18 }
20 19
21 /** 20 /**
22 * Handles callback from getServiceStatus. 21 * Handles callback from getServiceStatus.
23 * @param {string} Service status enum as a string. 22 * @param {string} Service status enum as a string.
24 */ 23 */
25 SyncService.prototype.onGetServiceStatus = function(statusString) { 24 SyncService.onGetServiceStatus = function(statusString) {
26 $('service-status').textContent = statusString; 25 $('service-status').textContent = statusString;
27 } 26 }
28 27
29 /** 28 /**
30 * Request Google Drive Notification Source. e.g. XMPP or polling. 29 * Request Google Drive Notification Source. e.g. XMPP or polling.
31 */ 30 */
32 function getNotificationSource() { 31 function getNotificationSource() {
33 chrome.send('getNotificationSource'); 32 chrome.send('getNotificationSource');
34 } 33 }
35 34
36 /** 35 /**
37 * Handles callback from getNotificationSource. 36 * Handles callback from getNotificationSource.
38 * @param {string} Notification source as a string. 37 * @param {string} Notification source as a string.
39 */ 38 */
40 SyncService.prototype.onGetNotificationSource = function(sourceString) { 39 SyncService.onGetNotificationSource = function(sourceString) {
41 $('notification-source').textContent = sourceString; 40 $('notification-source').textContent = sourceString;
42 } 41 }
43 42
44 /** 43 /**
45 * Creates an element named |elementName| containing the content |text|. 44 * Creates an element named |elementName| containing the content |text|.
46 * @param {string} elementName Name of the new element to be created. 45 * @param {string} elementName Name of the new element to be created.
47 * @param {string} text Text to be contained in the new element. 46 * @param {string} text Text to be contained in the new element.
48 * @return {HTMLElement} The newly created HTML element. 47 * @return {HTMLElement} The newly created HTML element.
49 */ 48 */
50 function createElementFromText(elementName, text) { 49 function createElementFromText(elementName, text) {
51 var element = document.createElement(elementName); 50 var element = document.createElement(elementName);
52 element.appendChild(document.createTextNode(text)); 51 element.appendChild(document.createTextNode(text));
53 return element; 52 return element;
54 } 53 }
55 54
56 /** 55 /**
57 * Request debug log. 56 * Request debug log.
58 */ 57 */
59 function getLog() { 58 function getLog() {
60 chrome.send('getLog'); 59 chrome.send('getLog');
61 } 60 }
62 61
63 /** 62 /**
64 * Handles callback from getUpdateLog. 63 * Handles callback from getUpdateLog.
65 * @param {Array} list List of dictionaries containing 'time' and 'logEvent'. 64 * @param {Array} list List of dictionaries containing 'time' and 'logEvent'.
66 */ 65 */
67 SyncService.prototype.onGetLog = function(logEntries) { 66 SyncService.onGetLog = function(logEntries) {
68 var itemContainer = $('log-entries'); 67 var itemContainer = $('log-entries');
69 for (var i = 0; i < logEntries.length; i++) { 68 for (var i = 0; i < logEntries.length; i++) {
70 var logEntry = logEntries[i]; 69 var logEntry = logEntries[i];
71 var tr = document.createElement('tr'); 70 var tr = document.createElement('tr');
72 tr.appendChild(createElementFromText('td', logEntry.time)); 71 tr.appendChild(createElementFromText('td', logEntry.time));
73 tr.appendChild(createElementFromText('td', logEntry.logEvent)); 72 tr.appendChild(createElementFromText('td', logEntry.logEvent));
74 itemContainer.appendChild(tr); 73 itemContainer.appendChild(tr);
75 } 74 }
76 } 75 }
77 76
78 /** 77 /**
79 * Get initial sync service values and set listeners to get updated values. 78 * Get initial sync service values and set listeners to get updated values.
80 */ 79 */
81 function main() { 80 function main() {
82 cr.ui.decorate('tabbox', cr.ui.TabBox); 81 cr.ui.decorate('tabbox', cr.ui.TabBox);
83 getServiceStatus(); 82 getServiceStatus();
84 getNotificationSource(); 83 getNotificationSource();
84
85 // TODO: Look for a way to push entries to the page when necessary.
85 window.setInterval(getLog, 1000); 86 window.setInterval(getLog, 1000);
86 } 87 }
87 88
88 document.addEventListener('DOMContentLoaded', main); 89 document.addEventListener('DOMContentLoaded', main);
89 return new SyncService; 90 return SyncService;
90 })(); 91 })();
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