Commit 04131fca authored by dpapad's avatar dpapad Committed by Chromium LUCI CQ

Run clang-format under c/b/r/sync_file_system_internals

This step was intentionally skipped in previous CL that migrated
this UI to JS modules to make reviewing easier.

Fixed: 1154192
Change-Id: I505e3960bcb5a86a8de11b548b08834ce6fd1f77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567462
Commit-Queue: John Lee <johntlee@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833407}
parent d931ed0b
...@@ -10,14 +10,14 @@ import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; ...@@ -10,14 +10,14 @@ import {sendWithPromise} from 'chrome://resources/js/cr.m.js';
import {$} from 'chrome://resources/js/util.m.js'; import {$} from 'chrome://resources/js/util.m.js';
import {createElementFromText} from './utils.js'; import {createElementFromText} from './utils.js';
/** /**
* Get the database dump. * Get the database dump.
*/ */
function refreshDatabaseDump() { function refreshDatabaseDump() {
sendWithPromise('getDatabaseDump').then(onGetDatabaseDump); sendWithPromise('getDatabaseDump').then(onGetDatabaseDump);
} }
/** /**
* Creates a table by filling |header| and |body|. * Creates a table by filling |header| and |body|.
* @param {!HTMLElement} div The outer container of the table to be * @param {!HTMLElement} div The outer container of the table to be
* renderered. * renderered.
...@@ -31,7 +31,7 @@ import {createElementFromText} from './utils.js'; ...@@ -31,7 +31,7 @@ import {createElementFromText} from './utils.js';
* which can be iterated using the 'keys' fields given by the first * which can be iterated using the 'keys' fields given by the first
* element. * element.
*/ */
function createDatabaseDumpTable(div, header, body, databaseDump) { function createDatabaseDumpTable(div, header, body, databaseDump) {
const metadata = databaseDump.shift(); const metadata = databaseDump.shift();
div.appendChild(createElementFromText('h3', metadata['title'])); div.appendChild(createElementFromText('h3', metadata['title']));
...@@ -49,13 +49,13 @@ import {createElementFromText} from './utils.js'; ...@@ -49,13 +49,13 @@ import {createElementFromText} from './utils.js';
} }
body.appendChild(tr); body.appendChild(tr);
} }
} }
/** /**
* Handles callback from onGetDatabaseDump. * Handles callback from onGetDatabaseDump.
* @param {Array} databaseDump List of lists for the database dump. * @param {Array} databaseDump List of lists for the database dump.
*/ */
function onGetDatabaseDump(databaseDump) { function onGetDatabaseDump(databaseDump) {
const placeholder = $('dump-database-placeholder'); const placeholder = $('dump-database-placeholder');
placeholder.innerHTML = trustedTypes.emptyHTML; placeholder.innerHTML = trustedTypes.emptyHTML;
for (let i = 0; i < databaseDump.length; ++i) { for (let i = 0; i < databaseDump.length; ++i) {
...@@ -71,11 +71,11 @@ import {createElementFromText} from './utils.js'; ...@@ -71,11 +71,11 @@ import {createElementFromText} from './utils.js';
div.appendChild(table); div.appendChild(table);
placeholder.appendChild(div); placeholder.appendChild(div);
} }
} }
function main() { function main() {
refreshDatabaseDump(); refreshDatabaseDump();
$('refresh-database-dump').addEventListener('click', refreshDatabaseDump); $('refresh-database-dump').addEventListener('click', refreshDatabaseDump);
} }
document.addEventListener('DOMContentLoaded', main); document.addEventListener('DOMContentLoaded', main);
...@@ -10,15 +10,15 @@ import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; ...@@ -10,15 +10,15 @@ import {sendWithPromise} from 'chrome://resources/js/cr.m.js';
import {$} from 'chrome://resources/js/util.m.js'; import {$} from 'chrome://resources/js/util.m.js';
import {createElementFromText} from './utils.js'; import {createElementFromText} from './utils.js';
/** /**
* Get initial map of extension statuses (pending batch sync, enabled and * Get initial map of extension statuses (pending batch sync, enabled and
* disabled). * disabled).
*/ */
function refreshExtensionStatuses() { function refreshExtensionStatuses() {
sendWithPromise('getExtensionStatuses').then(onGetExtensionStatuses); sendWithPromise('getExtensionStatuses').then(onGetExtensionStatuses);
} }
/** /**
* Handles callback from onGetExtensionStatuses. * Handles callback from onGetExtensionStatuses.
* @param {!Array<!{ * @param {!Array<!{
* extensionName: string, * extensionName: string,
...@@ -26,7 +26,7 @@ import {createElementFromText} from './utils.js'; ...@@ -26,7 +26,7 @@ import {createElementFromText} from './utils.js';
* status: string, * status: string,
* }>} extensionStatuses * }>} extensionStatuses
*/ */
function onGetExtensionStatuses(extensionStatuses) { function onGetExtensionStatuses(extensionStatuses) {
const itemContainer = $('extension-entries'); const itemContainer = $('extension-entries');
itemContainer.textContent = ''; itemContainer.textContent = '';
...@@ -38,12 +38,12 @@ import {createElementFromText} from './utils.js'; ...@@ -38,12 +38,12 @@ import {createElementFromText} from './utils.js';
tr.appendChild(createElementFromText('td', originEntry.status)); tr.appendChild(createElementFromText('td', originEntry.status));
itemContainer.appendChild(tr); itemContainer.appendChild(tr);
} }
} }
function main() { function main() {
refreshExtensionStatuses(); refreshExtensionStatuses();
$('refresh-extensions-statuses') $('refresh-extensions-statuses')
.addEventListener('click', refreshExtensionStatuses); .addEventListener('click', refreshExtensionStatuses);
} }
document.addEventListener('DOMContentLoaded', main); document.addEventListener('DOMContentLoaded', main);
...@@ -12,14 +12,14 @@ import {$} from 'chrome://resources/js/util.m.js'; ...@@ -12,14 +12,14 @@ import {$} from 'chrome://resources/js/util.m.js';
import {createElementFromDictionary, createElementFromText} from './utils.js'; import {createElementFromDictionary, createElementFromText} from './utils.js';
/** /**
* Gets extension data so the select drop down can be filled. * Gets extension data so the select drop down can be filled.
*/ */
function refreshExtensions() { function refreshExtensions() {
sendWithPromise('getExtensions').then(onGetExtensions); sendWithPromise('getExtensions').then(onGetExtensions);
} }
/** /**
* Renders result of getFileMetadata as a table. * Renders result of getFileMetadata as a table.
* @param {!Array<!{ * @param {!Array<!{
* extensionName: string, * extensionName: string,
...@@ -28,7 +28,7 @@ import {createElementFromDictionary, createElementFromText} from './utils.js'; ...@@ -28,7 +28,7 @@ import {createElementFromDictionary, createElementFromText} from './utils.js';
* }>} extensionStatuses of dictionaries containing 'extensionName', * }>} extensionStatuses of dictionaries containing 'extensionName',
* 'extensionID', 'status'. * 'extensionID', 'status'.
*/ */
function onGetExtensions(extensionStatuses) { function onGetExtensions(extensionStatuses) {
const select = $('extensions-select'); const select = $('extensions-select');
// Record existing drop down extension ID. If it's still there after the // Record existing drop down extension ID. If it's still there after the
...@@ -51,25 +51,25 @@ import {createElementFromDictionary, createElementFromText} from './utils.js'; ...@@ -51,25 +51,25 @@ import {createElementFromDictionary, createElementFromText} from './utils.js';
// After drop down has been loaded with options, file metadata can be loaded // After drop down has been loaded with options, file metadata can be loaded
refreshFileMetadata(); refreshFileMetadata();
} }
/** /**
* @return {?string} extension ID that's currently selected in drop down box. * @return {?string} extension ID that's currently selected in drop down box.
*/ */
function getSelectedExtensionId() { function getSelectedExtensionId() {
const dropDown = $('extensions-select').options; const dropDown = $('extensions-select').options;
if (dropDown.selectedIndex >= 0) { if (dropDown.selectedIndex >= 0) {
return dropDown[dropDown.selectedIndex].value; return dropDown[dropDown.selectedIndex].value;
} }
return null; return null;
} }
/** /**
* Get File Metadata depending on which extension is selected from the drop * Get File Metadata depending on which extension is selected from the drop
* down if any. * down if any.
*/ */
function refreshFileMetadata() { function refreshFileMetadata() {
const dropDown = $('extensions-select'); const dropDown = $('extensions-select');
if (dropDown.options.length === 0) { if (dropDown.options.length === 0) {
$('file-metadata-header').textContent = ''; $('file-metadata-header').textContent = '';
...@@ -80,12 +80,12 @@ import {createElementFromDictionary, createElementFromText} from './utils.js'; ...@@ -80,12 +80,12 @@ import {createElementFromDictionary, createElementFromText} from './utils.js';
const selectedExtensionId = getSelectedExtensionId(); const selectedExtensionId = getSelectedExtensionId();
sendWithPromise('getFileMetadata', selectedExtensionId) sendWithPromise('getFileMetadata', selectedExtensionId)
.then(onGetFileMetadata); .then(onGetFileMetadata);
} }
/** /**
* Renders result of getFileMetadata as a table. * Renders result of getFileMetadata as a table.
*/ */
function onGetFileMetadata(fileMetadataMap) { function onGetFileMetadata(fileMetadataMap) {
const header = $('file-metadata-header'); const header = $('file-metadata-header');
// Only draw the header if it hasn't been drawn yet // Only draw the header if it hasn't been drawn yet
if (header.children.length === 0) { if (header.children.length === 0) {
...@@ -109,13 +109,13 @@ import {createElementFromDictionary, createElementFromText} from './utils.js'; ...@@ -109,13 +109,13 @@ import {createElementFromDictionary, createElementFromText} from './utils.js';
tr.appendChild(createElementFromDictionary('td', metadatEntry.details)); tr.appendChild(createElementFromDictionary('td', metadatEntry.details));
itemContainer.appendChild(tr); itemContainer.appendChild(tr);
} }
} }
/** /**
* @param {string} type file type string. * @param {string} type file type string.
* @return {!HTMLElement} TD with file or folder icon depending on type. * @return {!HTMLElement} TD with file or folder icon depending on type.
*/ */
function createFileIconCell(type) { function createFileIconCell(type) {
const img = document.createElement('div'); const img = document.createElement('div');
const lowerType = type.toLowerCase(); const lowerType = type.toLowerCase();
if (lowerType == 'file') { if (lowerType == 'file') {
...@@ -133,12 +133,12 @@ import {createElementFromDictionary, createElementFromText} from './utils.js'; ...@@ -133,12 +133,12 @@ import {createElementFromDictionary, createElementFromText} from './utils.js';
td.appendChild(imgWrapper); td.appendChild(imgWrapper);
td.appendChild(document.createTextNode(type)); td.appendChild(document.createTextNode(type));
return td; return td;
} }
function main() { function main() {
refreshExtensions(); refreshExtensions();
$('refresh-metadata-button').addEventListener('click', refreshExtensions); $('refresh-metadata-button').addEventListener('click', refreshExtensions);
$('extensions-select').addEventListener('change', refreshFileMetadata); $('extensions-select').addEventListener('change', refreshFileMetadata);
} }
document.addEventListener('DOMContentLoaded', main); document.addEventListener('DOMContentLoaded', main);
...@@ -13,55 +13,55 @@ import {$} from 'chrome://resources/js/util.m.js'; ...@@ -13,55 +13,55 @@ import {$} from 'chrome://resources/js/util.m.js';
import {createElementFromText} from './utils.js'; import {createElementFromText} from './utils.js';
/** /**
* Request Sync Service Status. * Request Sync Service Status.
*/ */
function refreshServiceStatus() { function refreshServiceStatus() {
sendWithPromise('getServiceStatus').then(onGetServiceStatus); sendWithPromise('getServiceStatus').then(onGetServiceStatus);
} }
/** /**
* Called when service status is initially retrieved or updated via events. * Called when service status is initially retrieved or updated via events.
* @param {string} statusString Service status enum as a string. * @param {string} statusString Service status enum as a string.
*/ */
function onGetServiceStatus(statusString) { function onGetServiceStatus(statusString) {
$('service-status').textContent = statusString; $('service-status').textContent = statusString;
} }
/** /**
* Request Google Drive Notification Source. e.g. XMPP or polling. * Request Google Drive Notification Source. e.g. XMPP or polling.
*/ */
function refreshNotificationSource() { function refreshNotificationSource() {
sendWithPromise('getNotificationSource').then(onGetNotificationSource); sendWithPromise('getNotificationSource').then(onGetNotificationSource);
} }
/** /**
* Handles callback from getNotificationSource. * Handles callback from getNotificationSource.
* @param {string} sourceString Notification source as a string. * @param {string} sourceString Notification source as a string.
*/ */
function onGetNotificationSource(sourceString) { function onGetNotificationSource(sourceString) {
$('notification-source').textContent = sourceString; $('notification-source').textContent = sourceString;
} }
// Keeps track of the last log event seen so it's not reprinted. // Keeps track of the last log event seen so it's not reprinted.
let lastLogEventId = -1; let lastLogEventId = -1;
/** /**
* Request debug log. * Request debug log.
*/ */
function refreshLog() { function refreshLog() {
sendWithPromise('getLog', lastLogEventId).then(onGetLog); sendWithPromise('getLog', lastLogEventId).then(onGetLog);
} }
/** /**
* Clear old logs. * Clear old logs.
*/ */
function clearLogs() { function clearLogs() {
chrome.send('clearLogs'); chrome.send('clearLogs');
$('log-entries').innerHTML = trustedTypes.emptyHTML; $('log-entries').innerHTML = trustedTypes.emptyHTML;
} }
/** /**
* Handles callback from getUpdateLog. * Handles callback from getUpdateLog.
* @param {!Array<!{ * @param {!Array<!{
* id: number, * id: number,
...@@ -69,7 +69,7 @@ import {createElementFromText} from './utils.js'; ...@@ -69,7 +69,7 @@ import {createElementFromText} from './utils.js';
* time: string, * time: string,
* }>} logEntries List of dictionaries containing 'id', 'time', 'logEvent'. * }>} logEntries List of dictionaries containing 'id', 'time', 'logEvent'.
*/ */
function onGetLog(logEntries) { function onGetLog(logEntries) {
const itemContainer = $('log-entries'); const itemContainer = $('log-entries');
for (let i = 0; i < logEntries.length; i++) { for (let i = 0; i < logEntries.length; i++) {
const logEntry = logEntries[i]; const logEntry = logEntries[i];
...@@ -83,12 +83,12 @@ import {createElementFromText} from './utils.js'; ...@@ -83,12 +83,12 @@ import {createElementFromText} from './utils.js';
lastLogEventId = logEntry.id; lastLogEventId = logEntry.id;
} }
} }
/** /**
* Get initial sync service values and set listeners to get updated values. * Get initial sync service values and set listeners to get updated values.
*/ */
function main() { function main() {
decorate('tabbox', TabBox); decorate('tabbox', TabBox);
$('clear-log-button').addEventListener('click', clearLogs); $('clear-log-button').addEventListener('click', clearLogs);
refreshServiceStatus(); refreshServiceStatus();
...@@ -98,6 +98,6 @@ import {createElementFromText} from './utils.js'; ...@@ -98,6 +98,6 @@ import {createElementFromText} from './utils.js';
// TODO: Look for a way to push entries to the page when necessary. // TODO: Look for a way to push entries to the page when necessary.
window.setInterval(refreshLog, 1000); window.setInterval(refreshLog, 1000);
} }
document.addEventListener('DOMContentLoaded', main); document.addEventListener('DOMContentLoaded', main);
...@@ -6,9 +6,9 @@ import {addWebUIListener} from 'chrome://resources/js/cr.m.js'; ...@@ -6,9 +6,9 @@ import {addWebUIListener} from 'chrome://resources/js/cr.m.js';
import {$} from 'chrome://resources/js/util.m.js'; import {$} from 'chrome://resources/js/util.m.js';
import {createElementFromText} from './utils.js'; import {createElementFromText} from './utils.js';
const nextTaskLogSeq = 1; const nextTaskLogSeq = 1;
/** /**
* Handles per-task log event. * Handles per-task log event.
* @param {!{ * @param {!{
* duration: number, * duration: number,
...@@ -17,7 +17,7 @@ import {createElementFromText} from './utils.js'; ...@@ -17,7 +17,7 @@ import {createElementFromText} from './utils.js';
* details: !Array, * details: !Array,
* }} taskLog * }} taskLog
*/ */
function onTaskLogRecorded(taskLog) { function onTaskLogRecorded(taskLog) {
const details = document.createElement('td'); const details = document.createElement('td');
details.classList.add('task-log-details'); details.classList.add('task-log-details');
...@@ -45,14 +45,14 @@ import {createElementFromText} from './utils.js'; ...@@ -45,14 +45,14 @@ import {createElementFromText} from './utils.js';
tr.appendChild(details); tr.appendChild(details);
$('task-log-entries').appendChild(tr); $('task-log-entries').appendChild(tr);
} }
/** /**
* Get initial sync service values and set listeners to get updated values. * Get initial sync service values and set listeners to get updated values.
*/ */
function main() { function main() {
addWebUIListener('task-log-recorded', onTaskLogRecorded); addWebUIListener('task-log-recorded', onTaskLogRecorded);
chrome.send('observeTaskLog'); chrome.send('observeTaskLog');
} }
document.addEventListener('DOMContentLoaded', main); document.addEventListener('DOMContentLoaded', main);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment