Commit 63deffe7 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

[Files app] Add logging for every start up

Add logging as warn so it shows up in the logs file.

Add logging for:
- Earliest startup of Files app.
- Before trying to change to the initial directory.
- After finished changing to the initial directory.
- If there is no initial directory.

Change background page logs from debug to warn to have information
about the volumes initialization. We can turn this back to debug once
we figure out this bug.

These cover the bare minimal of the Files app initialization.

Add a util function to return a debug string from a give entry, to use
in the logging during startup.

Bug: 904658
Change-Id: Iaa14b8fe5ac171f4fa2cd070edadaf370e50c5f9
Reviewed-on: https://chromium-review.googlesource.com/c/1480302
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634574}
parent ec633df0
......@@ -130,9 +130,9 @@ VolumeManagerImpl.prototype.addVolumeMetadata_ = function(volumeMetadata) {
VolumeManagerImpl.prototype.initialize_ = function(callback) {
chrome.fileManagerPrivate.onMountCompleted.addListener(
this.onMountCompleted_.bind(this));
console.debug('Requesting volume list.');
console.warn('Requesting volume list.');
chrome.fileManagerPrivate.getVolumeMetadataList(volumeMetadataList => {
console.debug(
console.warn(
'Volume list fetched with: ' + volumeMetadataList.length + ' items.');
// We must subscribe to the mount completed event in the callback of
// getVolumeMetadataList. crbug.com/330061.
......@@ -142,15 +142,15 @@ VolumeManagerImpl.prototype.initialize_ = function(callback) {
// Create VolumeInfo for each volume.
Promise.all(
volumeMetadataList.map(volumeMetadata => {
console.debug(
console.warn(
'Initializing volume: ' + volumeMetadata.volumeId);
return this.addVolumeMetadata_(volumeMetadata).then(
volumeInfo => {
console.debug('Initialized volume: ' + volumeInfo.volumeId);
console.warn('Initialized volume: ' + volumeInfo.volumeId);
});
}))
.then(() => {
console.debug('Initialized all volumes.');
console.warn('Initialized all volumes.');
// Call the callback of the initialize function.
callback();
// Call the callback of AsyncQueue. Maybe it invokes callbacks
......@@ -219,7 +219,7 @@ VolumeManagerImpl.prototype.onMountCompleted_ = function(event) {
if (event.status === 'success') {
this.volumeInfoList.remove(event.volumeMetadata.volumeId);
}
console.debug('unmounted volume: ' + volumeId);
console.warn('unmounted volume: ' + volumeId);
callback();
break;
}
......
......@@ -97,7 +97,7 @@ volumeManagerUtil.createVolumeInfo = volumeMetadata => {
break;
}
console.debug(
console.warn(
'Requesting file system: ' + volumeMetadata.volumeType + ' ' +
volumeMetadata.volumeId);
return util
......@@ -145,7 +145,7 @@ volumeManagerUtil.createVolumeInfo = volumeMetadata => {
.then(
/** @param {!FileSystem} fileSystem */
fileSystem => {
console.debug('File system obtained: ' + volumeMetadata.volumeId);
console.warn('File system obtained: ' + volumeMetadata.volumeId);
if (volumeMetadata.volumeType ===
VolumeManagerCommon.VolumeType.DRIVE) {
// After file system is mounted, we "read" drive grand root
......
......@@ -1502,3 +1502,33 @@ util.isMyFilesVolumeEnabled = () => {
return loadTimeData.valueExists('MY_FILES_VOLUME_ENABLED') &&
loadTimeData.getBoolean('MY_FILES_VOLUME_ENABLED');
};
/**
* Used for logs and debugging. It tries to tell what type is the entry, its
* path and URL.
*
* @param {Entry|FilesAppEntry} entry
* @return {string}
*/
util.entryDebugString = (entry) => {
if (entry === null) {
return 'entry is null';
}
if (entry === undefined) {
return 'entry is undefined';
}
let typeName = '';
if (entry.constructor && entry.constructor.name) {
typeName = entry.constructor.name;
} else {
typeName = Object.prototype.toString.call(entry);
}
let entryDescription = '(' + typeName + ') ';
if (entry.fullPath) {
entryDescription = entryDescription + entry.fullPath + ' ';
}
if (entry.toURL) {
entryDescription = entryDescription + entry.toURL();
}
return entryDescription;
};
......@@ -124,3 +124,58 @@ function testIsDescendantEntry() {
assertTrue(util.isDescendantEntry(volumeEntry, fakeEntry));
assertTrue(util.isDescendantEntry(volumeEntry, folder1));
}
/**
* Tests that it doesn't fail with different types of entries and inputs.
*/
function testEntryDebugString() {
// Check static values.
assertEquals('entry is null', util.entryDebugString(null));
(/**
* @suppress {checkTypes} Closure doesn't allow passing undefined or {} due
* to type constraints nor casting to {Entry}.
*/
function() {
assertEquals('entry is undefined', util.entryDebugString(undefined));
assertEquals('(Object) ', util.entryDebugString({}));
})();
// Construct some types of entries.
const root = fileSystem.root;
const folder = fileSystem.entries['/dir_a'];
const file = fileSystem.entries['/file_a.txt'];
const fakeEntry =
new FakeEntry('fake-entry-label', VolumeManagerCommon.RootType.CROSTINI);
const entryList =
new EntryList('entry-list-label', VolumeManagerCommon.RootType.MY_FILES);
entryList.addEntry(fakeEntry);
const volumeManager = new MockVolumeManager();
// Index 1 is Downloads.
assertEquals(
VolumeManagerCommon.VolumeType.DOWNLOADS,
volumeManager.volumeInfoList.item(1).volumeType);
const downloadsVolumeInfo = volumeManager.volumeInfoList.item(1);
const mockFs = /** @type {MockFileSystem} */ (downloadsVolumeInfo.fileSystem);
mockFs.populate(['/folder1/']);
const volumeEntry = new VolumeEntry(downloadsVolumeInfo);
volumeEntry.addEntry(fakeEntry);
// Mocked values are identified as Object instead of DirectoryEntry and
// FileEntry.
assertEquals(
'(Object) / filesystem:fake-volume/', util.entryDebugString(root));
assertEquals(
'(Object) /dir_a filesystem:fake-volume/dir_a',
util.entryDebugString(folder));
assertEquals(
'(Object) /file_a.txt filesystem:fake-volume/file_a.txt',
util.entryDebugString(file));
// FilesAppEntry types:
assertEquals(
'(FakeEntry) fake-entry://crostini', util.entryDebugString(fakeEntry));
assertEquals(
'(EntryList) entry-list://my_files', util.entryDebugString(entryList));
assertEquals(
'(VolumeEntry) / filesystem:downloads/',
util.entryDebugString(volumeEntry));
}
......@@ -684,6 +684,7 @@ FileManager.prototype = /** @struct */ {
this.enableTouchMode_ = true;
}
}.bind(this));
console.warn('Files app sync startup finished.');
};
/**
......@@ -842,6 +843,7 @@ FileManager.prototype = /** @struct */ {
FileManager.prototype.initGeneral_ = function() {
// Initialize the application state.
// TODO(mtomasz): Unify window.appState with location.search format.
console.warn('Files app starting up.');
if (window.appState) {
var params = {};
for (var name in window.appState) {
......@@ -1477,14 +1479,20 @@ FileManager.prototype = /** @struct */ {
directoryEntry, opt_selectionEntry, opt_suggestedName) {
// Open the directory, and select the selection (if passed).
if (directoryEntry) {
const entryDescription = util.entryDebugString(directoryEntry);
console.warn(
'Files app start up: changing to directory: ' + entryDescription);
this.directoryModel_.changeDirectoryEntry(directoryEntry, function() {
if (opt_selectionEntry) {
this.directoryModel_.selectEntry(opt_selectionEntry);
}
console.warn(
'Files app start up: finished changing to directory: ' +
entryDescription);
this.ui_.addLoadedAttribute();
}.bind(this));
} else {
console.warn('No entry for finishSetupCurrentDirectory_');
this.ui_.addLoadedAttribute();
}
......
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