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

Side by Side Diff: chrome/browser/resources/chromeos/drive_internals.js

Issue 10828422: drive: Add information about in-flight operations to chrome:drive-internals (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase, add const Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * Updates the Authentication Status section. 6 * Updates the Authentication Status section.
7 * @param {Object} authStatus Dictionary containing auth status. 7 * @param {Object} authStatus Dictionary containing auth status.
8 */ 8 */
9 function updateAuthStatus(authStatus) { 9 function updateAuthStatus(authStatus) {
10 $('has-refresh-token').textContent = authStatus['has-refresh-token']; 10 $('has-refresh-token').textContent = authStatus['has-refresh-token'];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 tr.appendChild(createElementFromText('td', cacheEntry.is_pinned)); 63 tr.appendChild(createElementFromText('td', cacheEntry.is_pinned));
64 tr.appendChild(createElementFromText('td', cacheEntry.is_dirty)); 64 tr.appendChild(createElementFromText('td', cacheEntry.is_dirty));
65 tr.appendChild(createElementFromText('td', cacheEntry.is_mounted)); 65 tr.appendChild(createElementFromText('td', cacheEntry.is_mounted));
66 tr.appendChild(createElementFromText('td', cacheEntry.is_persistent)); 66 tr.appendChild(createElementFromText('td', cacheEntry.is_persistent));
67 67
68 $('cache-contents').appendChild(tr); 68 $('cache-contents').appendChild(tr);
69 } 69 }
70 70
71 /** 71 /**
72 * Updates the Local Storage summary. 72 * Updates the Local Storage summary.
73 * @param {Object} localStorageSummary Dictionaty describing the status of local 73 * @param {Object} localStorageSummary Dictionary describing the status of local
74 * stogage. 74 * stogage.
75 */ 75 */
76 function updateLocalStorageUsage(localStorageSummary) { 76 function updateLocalStorageUsage(localStorageSummary) {
77 var freeSpaceInMB = localStorageSummary.free_space / (1 << 20); 77 var freeSpaceInMB = localStorageSummary.free_space / (1 << 20);
78 $('local-storage-freespace').innerText = freeSpaceInMB; 78 $('local-storage-freespace').innerText = freeSpaceInMB;
79 } 79 }
80 80
81 /** 81 /**
82 * Updates the summary about in-flight operations.
83 * @param {Array} inFlightOperations List of dictionaries describing the status
84 * of in-flight operations.
85 */
86 function updateInFlightOperations(inFlightOperations) {
87 var container = $('in-flight-operations-contents');
88
89 // Reset the table.
90 var existingNodes = container.childNodes;
91 for (var i = 0; i < existingNodes.length; i++) {
92 var node = existingNodes[i];
93 if (node.className == 'in-flight-operation')
94 container.removeChild(node);
95 }
96
97 // Add in-flight operations.
98 for (var i = 0; i < inFlightOperations.length; i++) {
99 var operation = inFlightOperations[i];
100 var tr = document.createElement('tr');
101 tr.className = 'in-flight-operation';
102 tr.appendChild(createElementFromText('td', operation.operation_id));
103 tr.appendChild(createElementFromText('td', operation.operation_type));
104 tr.appendChild(createElementFromText('td', operation.file_path));
105 tr.appendChild(createElementFromText('td', operation.transfer_state));
106 tr.appendChild(createElementFromText('td', operation.start_time));
107 var progress = operation.progress_current + '/' + operation.progress_total;
108 if (operation.progress_total > 0) {
109 progress += ' (' +
110 (operation.progress_current / operation.progress_total * 100) + '%)';
111 }
112 tr.appendChild(createElementFromText('td', progress));
113
114 container.appendChild(tr);
115 }
116 }
117
118 /**
82 * Creates an element named |elementName| containing the content |text|. 119 * Creates an element named |elementName| containing the content |text|.
83 * @param {string} elementName Name of the new element to be created. 120 * @param {string} elementName Name of the new element to be created.
84 * @param {string} text Text to be contained in the new element. 121 * @param {string} text Text to be contained in the new element.
85 * @return {HTMLElement} The newly created HTML element. 122 * @return {HTMLElement} The newly created HTML element.
86 */ 123 */
87 function createElementFromText(elementName, text) { 124 function createElementFromText(elementName, text) {
88 var element = document.createElement(elementName); 125 var element = document.createElement(elementName);
89 element.appendChild(document.createTextNode(text)); 126 element.appendChild(document.createTextNode(text));
90 return element; 127 return element;
91 } 128 }
92 129
93 document.addEventListener('DOMContentLoaded', function() { 130 document.addEventListener('DOMContentLoaded', function() {
94 chrome.send('pageLoaded'); 131 chrome.send('pageLoaded');
132 window.setInterval(function() {
133 chrome.send('periodicUpdate');
134 }, 1000);
95 }); 135 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.html ('k') | chrome/browser/ui/webui/chromeos/drive_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698