Backed out changeset 0483abbea83d (bug 1627848) for build bustages. CLOSED TREE
authorRazvan Maries <rmaries@mozilla.com>
Tue, 28 Apr 2020 02:53:35 +0300
changeset 526375 f707e3fa32cb45c899eeceff408c81b906333c60
parent 526374 1a51afbff6bf7f93e9fbc5401104737a63bb4e6b
child 526376 b768eb1c3a1e63b162d6b5efee5a8012f3a8ca5b
push id114232
push userrmaries@mozilla.com
push dateMon, 27 Apr 2020 23:54:26 +0000
treeherderautoland@f707e3fa32cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1627848
milestone77.0a1
backs out0483abbea83d442f83363f1cf87659702fd835f7
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
Backed out changeset 0483abbea83d (bug 1627848) for build bustages. CLOSED TREE
toolkit/components/places/History.cpp
toolkit/components/places/nsNavHistory.cpp
toolkit/components/places/nsNavHistory.h
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -1824,38 +1824,30 @@ History::VisitURI(nsIWidget* aWidget, ns
                   uint32_t aFlags) {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_ARG(aURI);
 
   if (mShuttingDown) {
     return NS_OK;
   }
 
-  nsresult rv;
   if (XRE_IsContentProcess()) {
-    bool canAddURI = false;
-    rv = nsNavHistory::CanAddURIToHistory(aURI, &canAddURI);
-    NS_ENSURE_SUCCESS(rv, rv);
-    if (!canAddURI) {
-      return NS_OK;
-    }
-
     NS_ENSURE_ARG(aWidget);
     BrowserChild* browserChild = aWidget->GetOwningBrowserChild();
     NS_ENSURE_TRUE(browserChild, NS_ERROR_FAILURE);
     (void)browserChild->SendVisitURI(aURI, aLastVisitedURI, aFlags);
     return NS_OK;
   }
 
   nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
   NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY);
 
   // Silently return if URI is something we shouldn't add to DB.
   bool canAdd;
-  rv = navHistory->CanAddURI(aURI, &canAdd);
+  nsresult rv = navHistory->CanAddURI(aURI, &canAdd);
   NS_ENSURE_SUCCESS(rv, rv);
   if (!canAdd) {
     return NS_OK;
   }
 
   bool reload = false;
   if (aLastVisitedURI) {
     rv = aURI->Equals(aLastVisitedURI, &reload);
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -878,82 +878,60 @@ nsNavHistory::MarkPageAsFollowedBookmark
 //    we don't bail go on and allow it in.
 
 NS_IMETHODIMP
 nsNavHistory::CanAddURI(nsIURI* aURI, bool* canAdd) {
   NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
   NS_ENSURE_ARG(aURI);
   NS_ENSURE_ARG_POINTER(canAdd);
 
+  // Default to false.
+  *canAdd = false;
+
   // If history is disabled, don't add any entry.
   if (IsHistoryDisabled()) {
-    *canAdd = false;
     return NS_OK;
   }
 
-  return CanAddURIToHistory(aURI, canAdd);
-}
-
-// nsNavHistory::CanAddURIToHistory
-//
-//    Helper for nsNavHistory::CanAddURI to be callable from a child process
-
-// static
-NS_IMETHODIMP
-nsNavHistory::CanAddURIToHistory(nsIURI* aURI, bool* aCanAdd) {
-  // Default to false.
-  *aCanAdd = false;
-
   // If the url length is over a threshold, don't add it.
   nsCString spec;
   nsresult rv = aURI->GetSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
-  if (spec.Length() > MaxURILength()) {
+  if (!mDB || spec.Length() > mDB->MaxUrlLength()) {
     return NS_OK;
   }
 
   nsAutoCString scheme;
   rv = aURI->GetScheme(scheme);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // first check the most common cases
-  if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("https")) {
-    *aCanAdd = true;
+  // first check the most common cases (HTTP, HTTPS) to allow in to avoid most
+  // of the work
+  if (scheme.EqualsLiteral("http")) {
+    *canAdd = true;
+    return NS_OK;
+  }
+  if (scheme.EqualsLiteral("https")) {
+    *canAdd = true;
     return NS_OK;
   }
 
   // now check for all bad things
-  *aCanAdd =
-      !scheme.EqualsLiteral("about") && !scheme.EqualsLiteral("blob") &&
-      !scheme.EqualsLiteral("chrome") && !scheme.EqualsLiteral("data") &&
-      !scheme.EqualsLiteral("imap") && !scheme.EqualsLiteral("javascript") &&
-      !scheme.EqualsLiteral("mailbox") && !scheme.EqualsLiteral("moz-anno") &&
-      !scheme.EqualsLiteral("news") && !scheme.EqualsLiteral("page-icon") &&
-      !scheme.EqualsLiteral("resource") && !scheme.EqualsLiteral("view-source");
-
+  if (scheme.EqualsLiteral("about") || scheme.EqualsLiteral("blob") ||
+      scheme.EqualsLiteral("chrome") || scheme.EqualsLiteral("data") ||
+      scheme.EqualsLiteral("imap") || scheme.EqualsLiteral("javascript") ||
+      scheme.EqualsLiteral("mailbox") || scheme.EqualsLiteral("moz-anno") ||
+      scheme.EqualsLiteral("news") || scheme.EqualsLiteral("page-icon") ||
+      scheme.EqualsLiteral("resource") || scheme.EqualsLiteral("view-source")) {
+    return NS_OK;
+  }
+  *canAdd = true;
   return NS_OK;
 }
 
-// nsNavHistory::MaxURILength
-
-// static
-uint32_t nsNavHistory::MaxURILength() {
-  // Duplicates Database::MaxUrlLength() for use in
-  // child processes without a database instance.
-  static uint32_t maxSpecLength = 0;
-  if (!maxSpecLength) {
-    maxSpecLength = Preferences::GetInt(PREF_HISTORY_MAXURLLEN,
-                                        PREF_HISTORY_MAXURLLEN_DEFAULT);
-    if (maxSpecLength < 255 || maxSpecLength > INT32_MAX) {
-      maxSpecLength = PREF_HISTORY_MAXURLLEN_DEFAULT;
-    }
-  }
-  return maxSpecLength;
-}
-
 // nsNavHistory::GetNewQuery
 
 NS_IMETHODIMP
 nsNavHistory::GetNewQuery(nsINavHistoryQuery** _retval) {
   NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
   NS_ENSURE_ARG_POINTER(_retval);
 
   RefPtr<nsNavHistoryQuery> query = new nsNavHistoryQuery();
--- a/toolkit/components/places/nsNavHistory.h
+++ b/toolkit/components/places/nsNavHistory.h
@@ -168,22 +168,16 @@ class nsNavHistory final : public nsSupp
    */
   nsIStringBundle* GetBundle();
   nsICollation* GetCollation();
   void GetStringFromName(const char* aName, nsACString& aResult);
   void GetAgeInDaysString(int32_t aInt, const char* aName, nsACString& aResult);
   static void GetMonthName(const PRExplodedTime& aTime, nsACString& aResult);
   static void GetMonthYear(const PRExplodedTime& aTime, nsACString& aResult);
 
-  // Returns true if the provided URI spec and scheme is allowed in history
-  static nsresult CanAddURIToHistory(nsIURI* aURI, bool* aCanAdd);
-
-  // The max URI spec length allowed for a URI to be added to history
-  static uint32_t MaxURILength();
-
   // Returns whether history is enabled or not.
   bool IsHistoryDisabled() { return !mHistoryEnabled; }
 
   // Returns whether or not diacritics must match in history text searches.
   bool MatchDiacritics() const { return mMatchDiacritics; }
 
   // Constants for the columns returned by the above statement.
   static const int32_t kGetInfoIndex_PageID;