зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1660751 - QM: Log failures in the browser console; r=dom-workers-and-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D88004
This commit is contained in:
Родитель
19a5cf747e
Коммит
ebcfb83228
|
@ -6,19 +6,12 @@
|
|||
|
||||
#include "CacheCommon.h"
|
||||
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsXPCOM.h"
|
||||
|
||||
namespace mozilla::dom::cache {
|
||||
|
||||
void HandleError(const nsLiteralCString& aExpr,
|
||||
const nsLiteralCString& aSourceFile, int32_t aSourceLine) {
|
||||
#ifdef DEBUG
|
||||
NS_DebugBreak(NS_DEBUG_WARNING, "Error", aExpr.get(), aSourceFile.get(),
|
||||
aSourceLine);
|
||||
#endif
|
||||
|
||||
// TODO: Report to browser console
|
||||
mozilla::dom::quota::LogError(nsLiteralCString("Cache"), aExpr, aSourceFile,
|
||||
aSourceLine);
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom::cache
|
||||
|
|
|
@ -6,19 +6,12 @@
|
|||
|
||||
#include "IndexedDBCommon.h"
|
||||
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsXPCOM.h"
|
||||
|
||||
namespace mozilla::dom::indexedDB {
|
||||
|
||||
void HandleError(const nsLiteralCString& aExpr,
|
||||
const nsLiteralCString& aSourceFile, int32_t aSourceLine) {
|
||||
#ifdef DEBUG
|
||||
NS_DebugBreak(NS_DEBUG_WARNING, "Error", aExpr.get(), aSourceFile.get(),
|
||||
aSourceLine);
|
||||
#endif
|
||||
|
||||
// TODO: Report to browser console
|
||||
mozilla::dom::quota::LogError(nsLiteralCString("IndexedDB"), aExpr,
|
||||
aSourceFile, aSourceLine);
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom::indexedDB
|
||||
|
|
|
@ -144,13 +144,8 @@ namespace localstorage {
|
|||
|
||||
void HandleError(const nsLiteralCString& aExpr,
|
||||
const nsLiteralCString& aSourceFile, int32_t aSourceLine) {
|
||||
#ifdef DEBUG
|
||||
NS_DebugBreak(NS_DEBUG_WARNING, "Error", aExpr.get(), aSourceFile.get(),
|
||||
aSourceLine);
|
||||
|
||||
#endif
|
||||
|
||||
// TODO: Report to browser console
|
||||
mozilla::dom::quota::LogError(nsLiteralCString("LocalStorage"), aExpr,
|
||||
aSourceFile, aSourceLine);
|
||||
}
|
||||
|
||||
} // namespace localstorage
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "QuotaCommon.h"
|
||||
|
||||
#include "mozilla/Logging.h" // LazyLogModule
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
@ -127,6 +128,57 @@ Result<nsCOMPtr<nsIFile>, nsresult> QM_NewLocalFile(const nsAString& aPath) {
|
|||
return file;
|
||||
}
|
||||
|
||||
nsAutoString GetIntString(const int64_t aInteger) {
|
||||
nsAutoString res;
|
||||
res.AppendInt(aInteger);
|
||||
return res;
|
||||
}
|
||||
|
||||
nsAutoCString GetIntCString(const int64_t aInteger) {
|
||||
nsAutoCString res;
|
||||
res.AppendInt(aInteger);
|
||||
return res;
|
||||
}
|
||||
|
||||
nsDependentCSubstring GetLeafName(const nsACString& aPath) {
|
||||
nsACString::const_iterator start, end;
|
||||
aPath.BeginReading(start);
|
||||
aPath.EndReading(end);
|
||||
|
||||
bool found = RFindInReadable("/"_ns, start, end);
|
||||
if (found) {
|
||||
start = end;
|
||||
}
|
||||
|
||||
aPath.EndReading(end);
|
||||
|
||||
return nsDependentCSubstring(start.get(), end.get());
|
||||
}
|
||||
|
||||
void LogError(const nsLiteralCString& aModule, const nsLiteralCString& aExpr,
|
||||
const nsLiteralCString& aSourceFile, int32_t aSourceLine) {
|
||||
#ifdef DEBUG
|
||||
NS_DebugBreak(NS_DEBUG_WARNING, nsAutoCString(aModule + " failure"_ns).get(),
|
||||
aExpr.get(), nsAutoCString(GetLeafName(aSourceFile)).get(),
|
||||
aSourceLine);
|
||||
#endif
|
||||
|
||||
#if defined(EARLY_BETA_OR_EARLIER) || defined(DEBUG)
|
||||
nsCOMPtr<nsIConsoleService> console =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
if (console) {
|
||||
NS_ConvertUTF8toUTF16 message(aModule + " failure: '"_ns + aExpr +
|
||||
"', file "_ns + GetLeafName(aSourceFile) +
|
||||
", line "_ns + GetIntCString(aSourceLine));
|
||||
|
||||
// The concatenation above results in a message like:
|
||||
// QuotaManager failure: 'EXP', file XYZ, line N)
|
||||
|
||||
console->LogStringMessage(message.get());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Result<bool, nsresult> WarnIfFileIsUnknown(nsIFile& aFile,
|
||||
const char* aSourceFile,
|
||||
|
@ -174,12 +226,7 @@ Result<bool, nsresult> WarnIfFileIsUnknown(nsIFile& aFile,
|
|||
|
||||
void HandleError(const nsLiteralCString& aExpr,
|
||||
const nsLiteralCString& aSourceFile, int32_t aSourceLine) {
|
||||
#ifdef DEBUG
|
||||
NS_DebugBreak(NS_DEBUG_WARNING, "Error", aExpr.get(), aSourceFile.get(),
|
||||
aSourceLine);
|
||||
#endif
|
||||
|
||||
// TODO: Report to browser console
|
||||
LogError(nsLiteralCString("QuotaManager"), aExpr, aSourceFile, aSourceLine);
|
||||
|
||||
// TODO: Report to telemetry
|
||||
}
|
||||
|
|
|
@ -816,16 +816,27 @@ void CacheUseDOSDevicePathSyntaxPrefValue();
|
|||
|
||||
Result<nsCOMPtr<nsIFile>, nsresult> QM_NewLocalFile(const nsAString& aPath);
|
||||
|
||||
// IntString is deprecated, use GetIntString instead.
|
||||
class IntString : public nsAutoString {
|
||||
public:
|
||||
explicit IntString(int64_t aInteger) { AppendInt(aInteger); }
|
||||
};
|
||||
|
||||
// IntCString is deprecated, use GetIntCString instead.
|
||||
class IntCString : public nsAutoCString {
|
||||
public:
|
||||
explicit IntCString(int64_t aInteger) { AppendInt(aInteger); }
|
||||
};
|
||||
|
||||
nsAutoString GetIntString(const int64_t aInteger);
|
||||
|
||||
nsAutoCString GetIntCString(const int64_t aInteger);
|
||||
|
||||
nsDependentCSubstring GetLeafName(const nsACString& aPath);
|
||||
|
||||
void LogError(const nsLiteralCString& aModule, const nsLiteralCString& aExpr,
|
||||
const nsLiteralCString& aSourceFile, int32_t aSourceLine);
|
||||
|
||||
#ifdef DEBUG
|
||||
Result<bool, nsresult> WarnIfFileIsUnknown(nsIFile& aFile,
|
||||
const char* aSourceFile,
|
||||
|
|
|
@ -15,12 +15,8 @@ namespace simpledb {
|
|||
|
||||
void HandleError(const nsLiteralCString& aExpr,
|
||||
const nsLiteralCString& aSourceFile, int32_t aSourceLine) {
|
||||
#ifdef DEBUG
|
||||
NS_DebugBreak(NS_DEBUG_WARNING, "Error", aExpr.get(), aSourceFile.get(),
|
||||
aSourceLine);
|
||||
#endif
|
||||
|
||||
// TODO: Report to browser console
|
||||
mozilla::dom::quota::LogError(nsLiteralCString("SimpleDB"), aExpr,
|
||||
aSourceFile, aSourceLine);
|
||||
}
|
||||
|
||||
} // namespace simpledb
|
||||
|
|
Загрузка…
Ссылка в новой задаче