Bug 1702415 - Replace aSourceFile with aSourceFilePath; r=dom-storage-reviewers,jstutte,asuth
authorJan Varga <jvarga@mozilla.com>
Fri, 23 Apr 2021 12:02:58 +0000
changeset 577188 2c9d006772dbbe20f81504b7e97128fc4cc20274
parent 577187 410d299dd88e1d7e0a6582e44664c314ee33a5c6
child 577189 8adfd0fb0253e6cbb34b5d66211c8a8ecc138932
push id141817
push userjvarga@mozilla.com
push dateFri, 23 Apr 2021 12:05:27 +0000
treeherderautoland@8adfd0fb0253 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-storage-reviewers, jstutte, asuth
bugs1702415
milestone90.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1702415 - Replace aSourceFile with aSourceFilePath; r=dom-storage-reviewers,jstutte,asuth This patch adjusts other similar names as well: MakeRelativeSourceFileName -> MakeSourceFileRelativePath relativeSourceFile -> sourceFileRelativePath thisFileRelativeSourceFileName -> thisSourceFileRelativePath Differential Revision: https://phabricator.services.mozilla.com/D113076
dom/quota/QuotaCommon.cpp
dom/quota/QuotaCommon.h
dom/quota/test/gtest/TestQuotaCommon.cpp
--- a/dom/quota/QuotaCommon.cpp
+++ b/dom/quota/QuotaCommon.cpp
@@ -307,53 +307,53 @@ void ScopedLogExtraInfo::AddInfo() {
 
   slot->set(&mCurrentValue);
 }
 #endif
 
 namespace detail {
 
 nsDependentCSubstring GetSourceTreeBase() {
-  static constexpr auto thisFileRelativeSourceFileName =
+  static constexpr auto thisSourceFileRelativePath =
       "/dom/quota/QuotaCommon.cpp"_ns;
 
   static constexpr auto path = nsLiteralCString(__FILE__);
 
-  MOZ_ASSERT(StringEndsWith(path, thisFileRelativeSourceFileName));
+  MOZ_ASSERT(StringEndsWith(path, thisSourceFileRelativePath));
   return Substring(path, 0,
-                   path.Length() - thisFileRelativeSourceFileName.Length());
+                   path.Length() - thisSourceFileRelativePath.Length());
 }
 
-nsDependentCSubstring MakeRelativeSourceFileName(
-    const nsACString& aSourceFile) {
+nsDependentCSubstring MakeSourceFileRelativePath(
+    const nsACString& aSourceFilePath) {
   static constexpr auto error = "ERROR"_ns;
 
   static const auto sourceTreeBase = GetSourceTreeBase();
 
-  if (MOZ_LIKELY(StringBeginsWith(aSourceFile, sourceTreeBase))) {
-    return Substring(aSourceFile, sourceTreeBase.Length() + 1);
+  if (MOZ_LIKELY(StringBeginsWith(aSourceFilePath, sourceTreeBase))) {
+    return Substring(aSourceFilePath, sourceTreeBase.Length() + 1);
   }
 
   nsCString::const_iterator begin, end;
-  if (RFindInReadable("/"_ns, aSourceFile.BeginReading(begin),
-                      aSourceFile.EndReading(end))) {
+  if (RFindInReadable("/"_ns, aSourceFilePath.BeginReading(begin),
+                      aSourceFilePath.EndReading(end))) {
     // Use the basename as a fallback, to avoid exposing any user parts of the
     // path.
     ++begin;
-    return Substring(begin, aSourceFile.EndReading(end));
+    return Substring(begin, aSourceFilePath.EndReading(end));
   }
 
   return nsDependentCSubstring{static_cast<mozilla::Span<const char>>(
       static_cast<const nsCString&>(error))};
 }
 
 }  // namespace detail
 
 void LogError(const nsACString& aExpr, const Maybe<nsresult> aRv,
-              const nsACString& aSourceFile, const int32_t aSourceLine,
+              const nsACString& aSourceFilePath, const int32_t aSourceLine,
               const Severity aSeverity) {
 #if defined(EARLY_BETA_OR_EARLIER) || defined(DEBUG)
   nsAutoCString extraInfosString;
 
   nsAutoCString rvName;
   if (aRv) {
     if (NS_ERROR_GET_MODULE(*aRv) == NS_ERROR_MODULE_WIN32) {
       // XXX We could also try to get the Win32 error name here.
@@ -363,18 +363,18 @@ void LogError(const nsACString& aExpr, c
     }
     extraInfosString.AppendPrintf(
         " failed with "
         "result 0x%" PRIX32 "%s%s%s",
         static_cast<uint32_t>(*aRv), !rvName.IsEmpty() ? " (" : "",
         !rvName.IsEmpty() ? rvName.get() : "", !rvName.IsEmpty() ? ")" : "");
   }
 
-  const auto relativeSourceFile =
-      detail::MakeRelativeSourceFileName(aSourceFile);
+  const auto sourceFileRelativePath =
+      detail::MakeSourceFileRelativePath(aSourceFilePath);
 
   const auto severityString = [&aSeverity]() -> nsLiteralCString {
     switch (aSeverity) {
       case Severity::Error:
         return "ERROR"_ns;
       case Severity::Warning:
         return "WARNING"_ns;
       case Severity::Note:
@@ -395,26 +395,26 @@ void LogError(const nsACString& aExpr, c
 #ifdef DEBUG
   NS_DebugBreak(
       NS_DEBUG_WARNING,
       nsAutoCString("QM_TRY failure ("_ns + severityString + ")"_ns).get(),
       (extraInfosString.IsEmpty() ? nsPromiseFlatCString(aExpr)
                                   : static_cast<const nsCString&>(nsAutoCString(
                                         aExpr + extraInfosString)))
           .get(),
-      nsPromiseFlatCString(relativeSourceFile).get(), aSourceLine);
+      nsPromiseFlatCString(sourceFileRelativePath).get(), aSourceLine);
 #endif
 
 #if defined(EARLY_BETA_OR_EARLIER) || defined(DEBUG)
   nsCOMPtr<nsIConsoleService> console =
       do_GetService(NS_CONSOLESERVICE_CONTRACTID);
   if (console) {
     NS_ConvertUTF8toUTF16 message("QM_TRY failure ("_ns + severityString +
                                   ")"_ns + ": '"_ns + aExpr + "' at "_ns +
-                                  relativeSourceFile + ":"_ns +
+                                  sourceFileRelativePath + ":"_ns +
                                   IntToCString(aSourceLine) + extraInfosString);
 
     // The concatenation above results in a message like:
     // QM_TRY failure: 'EXPR' failed with result NS_ERROR_FAILURE at
     // dom/quota/Foo.cpp:12345
 
     console->LogStringMessage(message.get());
   }
@@ -426,17 +426,17 @@ void LogError(const nsACString& aExpr, c
     // match locations across versions, but they might be large.
     auto extra = Some([&] {
       auto res = CopyableTArray<EventExtraEntry>{};
       res.SetCapacity(6);
       // TODO We could still fill the module field, based on the source
       // directory, but we probably don't need to.
       // res.AppendElement(EventExtraEntry{"module"_ns, aModule});
       res.AppendElement(
-          EventExtraEntry{"source_file"_ns, nsCString(relativeSourceFile)});
+          EventExtraEntry{"source_file"_ns, nsCString(sourceFileRelativePath)});
       res.AppendElement(
           EventExtraEntry{"source_line"_ns, IntToCString(aSourceLine)});
       res.AppendElement(EventExtraEntry{
           "context"_ns, nsPromiseFlatCString{*contextIt->second}});
       res.AppendElement(EventExtraEntry{"severity"_ns, severityString});
 
       if (!rvName.IsEmpty()) {
         res.AppendElement(EventExtraEntry{"result"_ns, nsCString{rvName}});
@@ -460,17 +460,17 @@ void LogError(const nsACString& aExpr, c
                            Nothing(), extra);
   }
 #  endif
 #endif
 }
 
 #ifdef DEBUG
 Result<bool, nsresult> WarnIfFileIsUnknown(nsIFile& aFile,
-                                           const char* aSourceFile,
+                                           const char* aSourceFilePath,
                                            const int32_t aSourceLine) {
   nsString leafName;
   nsresult rv = aFile.GetLeafName(leafName);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return Err(rv);
   }
 
   bool isDirectory;
@@ -497,15 +497,15 @@ Result<bool, nsresult> WarnIfFileIsUnkno
     }
   }
 
   NS_DebugBreak(
       NS_DEBUG_WARNING,
       nsPrintfCString("Something (%s) in the directory that doesn't belong!",
                       NS_ConvertUTF16toUTF8(leafName).get())
           .get(),
-      nullptr, aSourceFile, aSourceLine);
+      nullptr, aSourceFilePath, aSourceLine);
 
   return true;
 }
 #endif
 
 }  // namespace mozilla::dom::quota
--- a/dom/quota/QuotaCommon.h
+++ b/dom/quota/QuotaCommon.h
@@ -1189,33 +1189,34 @@ template <SingleStepResult ResultHandlin
 Result<SingleStepSuccessType<ResultHandling>, nsresult>
 CreateAndExecuteSingleStepStatement(mozIStorageConnection& aConnection,
                                     const nsACString& aStatementString);
 
 namespace detail {
 
 nsDependentCSubstring GetSourceTreeBase();
 
-nsDependentCSubstring MakeRelativeSourceFileName(const nsACString& aSourceFile);
+nsDependentCSubstring MakeSourceFileRelativePath(
+    const nsACString& aSourceFilePath);
 
 }  // namespace detail
 
 enum class Severity {
   Error,
   Warning,
   Note,
 };
 
 void LogError(const nsACString& aExpr, Maybe<nsresult> aRv,
-              const nsACString& aSourceFile, int32_t aSourceLine,
+              const nsACString& aSourceFilePath, int32_t aSourceLine,
               Severity aSeverity);
 
 #ifdef DEBUG
 Result<bool, nsresult> WarnIfFileIsUnknown(nsIFile& aFile,
-                                           const char* aSourceFile,
+                                           const char* aSourceFilePath,
                                            int32_t aSourceLine);
 #endif
 
 #if defined(EARLY_BETA_OR_EARLIER) || defined(DEBUG)
 #  define QM_ENABLE_SCOPED_LOG_EXTRA_INFO
 #endif
 
 struct MOZ_STACK_CLASS ScopedLogExtraInfo {
@@ -1279,51 +1280,52 @@ struct MOZ_STACK_CLASS ScopedLogExtraInf
 // deliberately de-optimizes runtime performance, which is uncritical during
 // error handling.
 //
 // This functions are not intended to be called
 // directly, they should only be called from the QM_* macros.
 #if defined(EARLY_BETA_OR_EARLIER) || defined(DEBUG)
 template <typename T>
 MOZ_COLD void HandleError(const char* aExpr, const T& aRv,
-                          const char* aSourceFile, int32_t aSourceLine,
+                          const char* aSourceFilePath, int32_t aSourceLine,
                           const Severity aSeverity) {
   if constexpr (std::is_same_v<T, nsresult>) {
     mozilla::dom::quota::LogError(nsDependentCString(aExpr), Some(aRv),
-                                  nsDependentCString(aSourceFile), aSourceLine,
-                                  aSeverity);
+                                  nsDependentCString(aSourceFilePath),
+                                  aSourceLine, aSeverity);
   } else {
     mozilla::dom::quota::LogError(nsDependentCString(aExpr), Nothing{},
-                                  nsDependentCString(aSourceFile), aSourceLine,
-                                  aSeverity);
+                                  nsDependentCString(aSourceFilePath),
+                                  aSourceLine, aSeverity);
   }
 }
 #else
 template <typename T>
 MOZ_ALWAYS_INLINE constexpr void HandleError(const char* aExpr, const T& aRv,
-                                             const char* aSourceFile,
+                                             const char* aSourceFilePath,
                                              int32_t aSourceLine,
                                              const Severity aSeverity) {}
 #endif
 
 template <typename T>
 Nothing HandleErrorReturnNothing(const char* aExpr, const T& aRv,
-                                 const char* aSourceFile, int32_t aSourceLine,
+                                 const char* aSourceFilePath,
+                                 int32_t aSourceLine,
                                  const Severity aSeverity) {
-  HandleError(aExpr, aRv, aSourceFile, aSourceLine, aSeverity);
+  HandleError(aExpr, aRv, aSourceFilePath, aSourceLine, aSeverity);
   return Nothing();
 }
 
 template <typename T, typename CleanupFunc>
 Nothing HandleErrorWithCleanupReturnNothing(const char* aExpr, const T& aRv,
-                                            const char* aSourceFile,
+                                            const char* aSourceFilePath,
                                             int32_t aSourceLine,
                                             const Severity aSeverity,
                                             CleanupFunc&& aCleanupFunc) {
-  HandleError(aExpr, aRv, aSourceFile, aSourceLine, aSeverity);
+  HandleError(aExpr, aRv, aSourceFilePath, aSourceLine, aSeverity);
   std::forward<CleanupFunc>(aCleanupFunc)(aRv);
   return Nothing();
 }
 
 template <SingleStepResult ResultHandling = SingleStepResult::AssertHasResult,
           typename BindFunctor>
 Result<SingleStepSuccessType<ResultHandling>, nsresult>
 CreateAndExecuteSingleStepStatement(mozIStorageConnection& aConnection,
--- a/dom/quota/test/gtest/TestQuotaCommon.cpp
+++ b/dom/quota/test/gtest/TestQuotaCommon.cpp
@@ -1753,67 +1753,68 @@ TEST(QuotaCommon_CallWithDelayedRetriesI
         return Err(NS_ERROR_FILE_ACCESS_DENIED);
       },
       10, 2);
 
   EXPECT_EQ(tries, 5u);
   EXPECT_TRUE(res.isOk());
 }
 
-static constexpr auto thisFileRelativeSourceFileName =
+static constexpr auto thisSourceFileRelativePath =
     "dom/quota/test/gtest/TestQuotaCommon.cpp"_ns;
 
-TEST(QuotaCommon_MakeRelativeSourceFileName, ThisDomQuotaFile)
+TEST(QuotaCommon_MakeSourceFileRelativePath, ThisSourceFile)
 {
-  const nsCString relativeSourceFilePath{
-      mozilla::dom::quota::detail::MakeRelativeSourceFileName(
+  const nsCString sourceFileRelativePath{
+      mozilla::dom::quota::detail::MakeSourceFileRelativePath(
           nsLiteralCString(__FILE__))};
 
-  EXPECT_STREQ(relativeSourceFilePath.get(),
-               thisFileRelativeSourceFileName.get());
+  EXPECT_STREQ(sourceFileRelativePath.get(), thisSourceFileRelativePath.get());
 }
 
 static nsCString MakeFullPath(const nsACString& aRelativePath) {
   nsCString path{mozilla::dom::quota::detail::GetSourceTreeBase()};
 
   path.Append("/");
   path.Append(aRelativePath);
 
   return path;
 }
 
-TEST(QuotaCommon_MakeRelativeSourceFileName, DomIndexedDBFile)
+TEST(QuotaCommon_MakeSourceFileRelativePath, DomIndexedDBSourceFile)
 {
-  static constexpr auto domIndexedDBFileRelativePath =
+  static constexpr auto domIndexedDBSourceFileRelativePath =
       "dom/indexedDB/ActorsParent.cpp"_ns;
 
-  const nsCString relativeSourceFilePath{
-      mozilla::dom::quota::detail::MakeRelativeSourceFileName(
-          MakeFullPath(domIndexedDBFileRelativePath))};
+  const nsCString sourceFileRelativePath{
+      mozilla::dom::quota::detail::MakeSourceFileRelativePath(
+          MakeFullPath(domIndexedDBSourceFileRelativePath))};
 
-  EXPECT_STREQ(relativeSourceFilePath.get(),
-               domIndexedDBFileRelativePath.get());
+  EXPECT_STREQ(sourceFileRelativePath.get(),
+               domIndexedDBSourceFileRelativePath.get());
 }
 
-TEST(QuotaCommon_MakeRelativeSourceFileName, NonDomFile)
+TEST(QuotaCommon_MakeSourceFileRelativePath, NonDomSourceFile)
 {
-  static constexpr auto nonDomFileRelativePath =
+  static constexpr auto nonDomSourceFileRelativePath =
       "storage/mozStorageService.cpp"_ns;
 
-  const nsCString relativeSourceFilePath{
-      mozilla::dom::quota::detail::MakeRelativeSourceFileName(
-          MakeFullPath(nonDomFileRelativePath))};
+  const nsCString sourceFileRelativePath{
+      mozilla::dom::quota::detail::MakeSourceFileRelativePath(
+          MakeFullPath(nonDomSourceFileRelativePath))};
 
-  EXPECT_STREQ(relativeSourceFilePath.get(), nonDomFileRelativePath.get());
+  EXPECT_STREQ(sourceFileRelativePath.get(),
+               nonDomSourceFileRelativePath.get());
 }
 
-TEST(QuotaCommon_MakeRelativeSourceFileName, OtherFile)
+TEST(QuotaCommon_MakeSourceFileRelativePath, OtherSourceFile)
 {
-  constexpr auto otherName = "/foo/bar/Test.cpp"_ns;
-  const nsCString relativeSourceFilePath{
-      mozilla::dom::quota::detail::MakeRelativeSourceFileName(otherName)};
+  constexpr auto otherSourceFilePath = "/foo/bar/Test.cpp"_ns;
+  const nsCString sourceFileRelativePath{
+      mozilla::dom::quota::detail::MakeSourceFileRelativePath(
+          otherSourceFilePath)};
 
-  EXPECT_STREQ(relativeSourceFilePath.get(), "Test.cpp");
+  EXPECT_STREQ(sourceFileRelativePath.get(), "Test.cpp");
 }
 
 #ifdef __clang__
 #  pragma clang diagnostic pop
 #endif