Bug 1772617: Unify OPFS Logging r=dom-storage-reviewers,jari,janv

Differential Revision: https://phabricator.services.mozilla.com/D148318
This commit is contained in:
Jari Jalkanen 2022-11-10 17:13:40 +00:00
Родитель 1ee90cf9ed
Коммит 61e273f1ff
20 изменённых файлов: 79 добавлений и 109 удалений

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/FileSystemDirectoryHandleBinding.h"
#include "mozilla/dom/FileSystemHandleBinding.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManager.h"
#include "mozilla/dom/PFileSystemManager.h"
#include "mozilla/dom/Promise.h"
@ -58,6 +59,7 @@ void FileSystemDirectoryHandle::InitAsyncIteratorData(
already_AddRefed<Promise> FileSystemDirectoryHandle::GetNextIterationResult(
FileSystemDirectoryHandle::iterator_t* aIterator, ErrorResult& aError) {
LOG_VERBOSE(("GetNextIterationResult"));
return aIterator->Data().mImpl->Next(mGlobal, mManager, aError);
}
@ -132,6 +134,8 @@ already_AddRefed<Promise> FileSystemDirectoryHandle::Resolve(
return nullptr;
}
LOG_VERBOSE(("Resolve"));
fs::FileSystemEntryPair pair(mMetadata.entryId(),
aPossibleDescendant.GetId());
mRequestHandler->Resolve(mManager, pair, promise, aError);

Просмотреть файл

@ -12,6 +12,7 @@
#include "js/StructuredClone.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/FileSystemHandleBinding.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManager.h"
#include "mozilla/dom/Promise-inl.h"
#include "mozilla/dom/Promise.h"

Просмотреть файл

@ -7,32 +7,15 @@
#ifndef DOM_FS_FILESYSTEMHANDLE_H_
#define DOM_FS_FILESYSTEMHANDLE_H_
#include "mozilla/Logging.h"
#include "mozilla/dom/PFileSystemManager.h"
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
class nsIGlobalObject;
namespace mozilla {
extern LazyLogModule gOPFSLog;
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
class ErrorResult;
namespace dom {

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/MozPromise.h"
#include "mozilla/dom/FileSystemAccessHandleChild.h"
#include "mozilla/dom/FileSystemHandleBinding.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManager.h"
#include "mozilla/dom/FileSystemSyncAccessHandleBinding.h"
#include "mozilla/dom/Promise.h"
@ -25,16 +26,6 @@
#include "nsStreamUtils.h"
#include "nsStringStream.h"
namespace mozilla {
LazyLogModule gOPFSLog("OPFS");
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
namespace mozilla::dom {
namespace {
@ -209,7 +200,7 @@ already_AddRefed<Promise> FileSystemSyncAccessHandle::Truncate(
return promise.forget();
};
LOG_DEBUG(("%p: Truncate to %" PRIu64, mStream.get(), aSize));
LOG(("%p: Truncate to %" PRIu64, mStream.get(), aSize));
QM_TRY(MOZ_TO_RESULT(mStream->Seek(nsISeekableStream::NS_SEEK_SET, aSize)),
rejectAndReturn);
@ -247,7 +238,7 @@ already_AddRefed<Promise> FileSystemSyncAccessHandle::GetSize(
MOZ_TO_RESULT_INVOKE_MEMBER(fileMetadata, GetSize),
rejectAndReturn);
LOG_DEBUG(("%p: GetSize %" PRIu64, mStream.get(), size));
LOG(("%p: GetSize %" PRIu64, mStream.get(), size));
promise->MaybeResolve(size);
return promise.forget();
@ -270,7 +261,7 @@ already_AddRefed<Promise> FileSystemSyncAccessHandle::Flush(
return promise.forget();
};
LOG_DEBUG(("%p: Flush", mStream.get()));
LOG(("%p: Flush", mStream.get()));
QM_TRY(MOZ_TO_RESULT(mStream->OutputStream()->Flush()), rejectAndReturn);
@ -317,7 +308,7 @@ uint64_t FileSystemSyncAccessHandle::ReadOrWrite(
const auto offset = CheckedInt<int64_t>(at);
QM_TRY(MOZ_TO_RESULT(offset.isValid()), throwAndReturn);
LOG(("%p: Seeking to %" PRIu64, mStream.get(), offset.value()));
LOG_VERBOSE(("%p: Seeking to %" PRIu64, mStream.get(), offset.value()));
QM_TRY(MOZ_TO_RESULT(
mStream->Seek(nsISeekableStream::NS_SEEK_SET, offset.value())),
@ -339,13 +330,13 @@ uint64_t FileSystemSyncAccessHandle::ReadOrWrite(
nsCOMPtr<nsIOutputStream> outputStream;
if (aRead) {
LOG(("%p: Reading %zu bytes", mStream.get(), dataSpan.Length()));
LOG_VERBOSE(("%p: Reading %zu bytes", mStream.get(), dataSpan.Length()));
inputStream = mStream->InputStream();
outputStream = FixedBufferOutputStream::Create(AsWritableChars(dataSpan));
} else {
LOG(("%p: Writing %zu bytes", mStream.get(), dataSpan.Length()));
LOG_VERBOSE(("%p: Writing %zu bytes", mStream.get(), dataSpan.Length()));
QM_TRY(MOZ_TO_RESULT(NS_NewByteInputStream(getter_AddRefs(inputStream),
AsChars(dataSpan),

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef DOM_FS_FILESYSTEMSYNCACCESSHANDLE_H_
#define DOM_FS_FILESYSTEMSYNCACCESSHANDLE_H_
#include "mozilla/Logging.h"
#include "mozilla/dom/PFileSystemManager.h"
#include "nsCOMPtr.h"
#include "nsISupports.h"
@ -16,7 +15,6 @@
class nsIGlobalObject;
namespace mozilla {
extern LazyLogModule gOPFSLog;
class ErrorResult;

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/Blob.h"
#include "mozilla/dom/FileSystemHandle.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManager.h"
#include "mozilla/dom/FileSystemWritableFileStreamBinding.h"
#include "mozilla/dom/FileSystemWritableFileStreamChild.h"
@ -21,18 +22,6 @@
#include "nsNetUtil.h"
#include "private/pprio.h"
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_VERBOSE(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
namespace mozilla::dom {
namespace {
@ -396,6 +385,7 @@ void FileSystemWritableFileStream::Write(const T& aData,
WriteBuffer(maybeBuffer.extract(), aPosition),
rejectAndReturn);
LOG_VERBOSE(("WritableFileStream: Wrote %" PRId64, written));
aPromise->MaybeResolve(written);
return;
}
@ -415,6 +405,7 @@ void FileSystemWritableFileStream::Write(const T& aData,
QM_TRY_INSPECT(const auto& written,
WriteStream(std::move(stream), aPosition), rejectAndReturn);
LOG_VERBOSE(("WritableFileStream: Wrote %" PRId64, written));
aPromise->MaybeResolve(written);
return;
}
@ -435,6 +426,7 @@ void FileSystemWritableFileStream::Write(const T& aData,
QM_TRY_INSPECT(const auto& written, WriteBuffer(std::move(buffer), aPosition),
rejectAndReturn);
LOG_VERBOSE(("WritableFileStream: Wrote %" PRId64, written));
aPromise->MaybeResolve(written);
}
@ -467,7 +459,7 @@ void FileSystemWritableFileStream::Truncate(uint64_t aSize,
// Spec issues raised.
// truncate filehandle (can extend with 0's)
LOG(("%p: Truncate to %" PRIu64, mFileDesc, aSize));
LOG_VERBOSE(("%p: Truncate to %" PRIu64, mFileDesc, aSize));
if (NS_WARN_IF(NS_FAILED(TruncFile(mFileDesc, aSize)))) {
aPromise->MaybeReject(NS_ErrorAccordingToNSPR());
return;

Просмотреть файл

@ -7,14 +7,12 @@
#ifndef DOM_FS_FILESYSTEMWRITABLEFILESTREAM_H_
#define DOM_FS_FILESYSTEMWRITABLEFILESTREAM_H_
#include "mozilla/Logging.h"
#include "mozilla/dom/PFileSystemManager.h"
#include "mozilla/dom/WritableStream.h"
class nsIGlobalObject;
namespace mozilla {
extern LazyLogModule gOPFSLog;
template <typename T>
class Buffer;

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/dom/FileSystemDirectoryIterator.h"
#include "mozilla/dom/FileSystemFileHandle.h"
#include "mozilla/dom/FileSystemHandle.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManager.h"
#include "mozilla/dom/IterableIterator.h"
#include "mozilla/dom/Promise.h"
@ -121,6 +122,7 @@ class DoubleBufferQueueImpl
protected:
void next(nsIGlobalObject* aGlobal, RefPtr<FileSystemManager>& aManager,
RefPtr<Promise> aResult, ErrorResult& aError) {
LOG_VERBOSE(("next"));
MOZ_ASSERT(aResult);
Maybe<DataType> rawValue;

Просмотреть файл

@ -17,6 +17,7 @@
#include "mozilla/dom/FileSystemFileHandle.h"
#include "mozilla/dom/FileSystemHandle.h"
#include "mozilla/dom/FileSystemHelpers.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManager.h"
#include "mozilla/dom/FileSystemManagerChild.h"
#include "mozilla/dom/FileSystemSyncAccessHandle.h"
@ -27,15 +28,6 @@
#include "mozilla/dom/quota/QuotaCommon.h"
#include "mozilla/ipc/RandomAccessStreamUtils.h"
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
namespace mozilla::dom::fs {
using mozilla::ipc::RejectCallback;
@ -535,6 +527,7 @@ void FileSystemRequestHandler::GetEntries(
MOZ_ASSERT(aManager);
MOZ_ASSERT(!aDirectory.IsEmpty());
MOZ_ASSERT(aPromise);
LOG(("GetEntries, page %u", aPage));
if (aManager->IsShutdown()) {
aError.Throw(NS_ERROR_ILLEGAL_DURING_SHUTDOWN);
@ -662,6 +655,7 @@ void FileSystemRequestHandler::Resolve(
MOZ_ASSERT(!aEndpoints.parentId().IsEmpty());
MOZ_ASSERT(!aEndpoints.childId().IsEmpty());
MOZ_ASSERT(aPromise);
LOG(("Resolve"));
if (aManager->IsShutdown()) {
aError.Throw(NS_ERROR_ILLEGAL_DURING_SHUTDOWN);

Просмотреть файл

@ -6,17 +6,9 @@
#include "FileSystemWritableFileStreamChild.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemWritableFileStream.h"
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
namespace mozilla::dom {
FileSystemWritableFileStreamChild::FileSystemWritableFileStreamChild()

Просмотреть файл

@ -7,6 +7,7 @@
#include "FileSystemAccessHandleParent.h"
#include "FileSystemDataManager.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManagerParent.h"
namespace mozilla::dom {

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/dom/FileBlobImpl.h"
#include "mozilla/dom/FileSystemAccessHandleParent.h"
#include "mozilla/dom/FileSystemDataManager.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemTypes.h"
#include "mozilla/dom/FileSystemWritableFileStreamParent.h"
#include "mozilla/dom/IPCBlobUtils.h"
@ -27,15 +28,6 @@
using IPCResult = mozilla::ipc::IPCResult;
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
namespace mozilla::dom {
FileSystemManagerParent::FileSystemManagerParent(
@ -142,7 +134,7 @@ mozilla::ipc::IPCResult FileSystemManagerParent::RecvGetAccessHandle(
aRequest.entryId(), type, lastModifiedMilliSeconds, path, file)),
IPC_OK(), reportError);
if (MOZ_LOG_TEST(gOPFSLog, mozilla::LogLevel::Debug)) {
if (LOG_ENABLED()) {
nsAutoString path;
if (NS_SUCCEEDED(file->GetPath(path))) {
LOG(("Opening SyncAccessHandle %s", NS_ConvertUTF16toUTF8(path).get()));
@ -200,7 +192,7 @@ mozilla::ipc::IPCResult FileSystemManagerParent::RecvGetWritable(
aRequest.entryId(), type, lastModifiedMilliSeconds, path, file)),
IPC_OK(), reportError);
if (MOZ_LOG_TEST(gOPFSLog, mozilla::LogLevel::Debug)) {
if (LOG_ENABLED()) {
nsAutoString path;
if (NS_SUCCEEDED(file->GetPath(path))) {
LOG(("Opening Writable %s", NS_ConvertUTF16toUTF8(path).get()));
@ -263,7 +255,7 @@ IPCResult FileSystemManagerParent::RecvGetFile(
fileObject)),
IPC_OK(), reportError);
if (MOZ_LOG_TEST(gOPFSLog, mozilla::LogLevel::Debug)) {
if (LOG_ENABLED()) {
nsAutoString path;
if (NS_SUCCEEDED(fileObject->GetPath(path))) {
LOG(("Opening File as blob: %s", NS_ConvertUTF16toUTF8(path).get()));
@ -306,6 +298,14 @@ IPCResult FileSystemManagerParent::RecvResolve(
mDataManager->MutableDatabaseManagerPtr()->Resolve(aRequest.endpoints()),
IPC_OK(), reportError);
if (LOG_ENABLED()) {
nsString path;
for (auto& entry : filePath) {
path.Append(entry);
}
LOG(("Resolve path: %s", NS_ConvertUTF16toUTF8(path).get()));
}
if (filePath.IsEmpty()) {
FileSystemResolveResponse response(Nothing{});
aResolver(response);

Просмотреть файл

@ -12,15 +12,6 @@
#include "mozilla/dom/PFileSystemManagerParent.h"
#include "nsISupports.h"
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
namespace mozilla::dom {
namespace fs::data {

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/dom/FileSystemDataManager.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManagerParent.h"
#include "mozilla/dom/FileSystemTypes.h"
#include "mozilla/dom/quota/QuotaCommon.h"
@ -17,15 +18,6 @@
#include "nsIScriptObjectPrincipal.h"
#include "nsString.h"
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
namespace mozilla::dom {
mozilla::ipc::IPCResult CreateFileSystemManagerParent(
const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
@ -70,6 +62,7 @@ mozilla::ipc::IPCResult CreateFileSystemManagerParent(
new FileSystemManagerParent(std::move(dataManager),
rootId);
LOG(("Binding parent endpoint"));
if (!parentEndpoint.Bind(parent)) {
return CreateActorPromise::CreateAndReject(NS_ERROR_FAILURE,
__func__);

Просмотреть файл

@ -7,6 +7,7 @@
#include "FileSystemWritableFileStreamParent.h"
#include "FileSystemDataManager.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManagerParent.h"
namespace mozilla::dom {

Просмотреть файл

@ -17,6 +17,7 @@
#include "mozStorageCID.h"
#include "mozilla/Result.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemManagerParent.h"
#include "mozilla/dom/quota/ClientImpl.h"
#include "mozilla/dom/quota/DirectoryLock.h"
@ -34,17 +35,6 @@
#include "nsString.h"
#include "nsThreadUtils.h"
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_DEBUG(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
#define LOG_VERBOSE(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
namespace mozilla::dom::fs::data {
namespace {

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozStorageHelper.h"
#include "mozilla/dom/FileSystemDataManager.h"
#include "mozilla/dom/FileSystemHandle.h"
#include "mozilla/dom/FileSystemLog.h"
#include "mozilla/dom/FileSystemTypes.h"
#include "mozilla/dom/PFileSystemManager.h"
#include "mozilla/dom/quota/QuotaCommon.h"

Просмотреть файл

@ -0,0 +1,13 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FileSystemLog.h"
namespace mozilla {
LazyLogModule gOPFSLog("OPFS");
}

Просмотреть файл

@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_FS_SHARED_FILESYSTEMLOG_H_
#define DOM_FS_SHARED_FILESYSTEMLOG_H_
#include "mozilla/Logging.h"
namespace mozilla {
extern LazyLogModule gOPFSLog;
}
#define LOG(args) MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Debug, args)
#define LOG_VERBOSE(args) \
MOZ_LOG(mozilla::gOPFSLog, mozilla::LogLevel::Verbose, args)
#define LOG_ENABLED() MOZ_LOG_TEST(mozilla::gOPFSLog, mozilla::LogLevel::Debug)
#endif // DOM_FS_SHARED_FILESYSTEMLOG_H

Просмотреть файл

@ -6,11 +6,13 @@
EXPORTS.mozilla.dom += [
"FileSystemHelpers.h",
"FileSystemLog.h",
"FileSystemTypes.h",
]
UNIFIED_SOURCES += [
"FileSystemHelpers.cpp",
"FileSystemLog.cpp",
]
FINAL_LIBRARY = "xul"