Backout bug 1382923 because History.h doesn't exist on Andoid
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 21 Jul 2017 11:20:58 -0400
changeset 419043 879b737111d925ea97eb1caabf339bdc6fbca36f
parent 419042 8dafae4d09fbfcee866cf8bc3453f569d0e762e5
child 419044 96941e476121567971b29c4b526494b97e883279
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1382923
milestone56.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
Backout bug 1382923 because History.h doesn't exist on Andoid
dom/base/Link.cpp
dom/base/Link.h
toolkit/components/places/moz.build
--- a/dom/base/Link.cpp
+++ b/dom/base/Link.cpp
@@ -4,17 +4,16 @@
  * 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 "Link.h"
 
 #include "mozilla/EventStates.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/Element.h"
-#include "mozilla/places/History.h"
 #include "nsIURL.h"
 #include "nsISizeOf.h"
 #include "nsIDocShell.h"
 #include "nsIPrefetchService.h"
 #include "nsCPrefetchService.h"
 #include "nsStyleLinkElement.h"
 
 #include "nsEscape.h"
@@ -24,38 +23,36 @@
 #include "mozAutoDocUpdate.h"
 
 #include "mozilla/Services.h"
 #include "nsAttrValueInlines.h"
 
 namespace mozilla {
 namespace dom {
 
-using places::History;
-
 Link::Link(Element *aElement)
   : mElement(aElement)
+  , mHistory(services::GetHistoryService())
   , mLinkState(eLinkState_NotLink)
   , mNeedsRegistration(false)
   , mRegistered(false)
   , mHasPendingLinkUpdate(false)
   , mInDNSPrefetch(false)
-  , mHistory(true)
 {
   MOZ_ASSERT(mElement, "Must have an element");
 }
 
 Link::Link()
   : mElement(nullptr)
+  , mHistory(nullptr)
   , mLinkState(eLinkState_NotLink)
   , mNeedsRegistration(false)
   , mRegistered(false)
   , mHasPendingLinkUpdate(false)
   , mInDNSPrefetch(false)
-  , mHistory(false)
 {
 }
 
 Link::~Link()
 {
   // !mElement is for mock_Link.
   MOZ_ASSERT(!mElement || !mElement->IsInComposedDoc());
   if (IsInDNSPrefetch()) {
@@ -378,17 +375,17 @@ Link::LinkState() const
     nsCOMPtr<nsIURI> hrefURI(GetURI());
 
     // Assume that we are not visited until we are told otherwise.
     self->mLinkState = eLinkState_Unvisited;
 
     // Make sure the href attribute has a valid link (bug 23209).
     // If we have a good href, register with History if available.
     if (mHistory && hrefURI) {
-      nsresult rv = History::GetService()->RegisterVisitedCallback(hrefURI, self);
+      nsresult rv = mHistory->RegisterVisitedCallback(hrefURI, self);
       if (NS_SUCCEEDED(rv)) {
         self->mRegistered = true;
 
         // And make sure we are in the document's link map.
         element->GetComposedDoc()->AddStyleRelevantLink(self);
       }
     }
   }
@@ -793,17 +790,17 @@ Link::UnregisterFromHistory()
   if (!mRegistered) {
     return;
   }
 
   NS_ASSERTION(mCachedURI, "mRegistered is true, but we have no cached URI?!");
 
   // And tell History to stop tracking us.
   if (mHistory) {
-    nsresult rv = History::GetService()->UnregisterVisitedCallback(mCachedURI, this);
+    nsresult rv = mHistory->UnregisterVisitedCallback(mCachedURI, this);
     NS_ASSERTION(NS_SUCCEEDED(rv), "This should only fail if we misuse the API!");
     if (NS_SUCCEEDED(rv)) {
       mRegistered = false;
     }
   }
 }
 
 already_AddRefed<nsIURI>
@@ -841,16 +838,17 @@ Link::SizeOfExcludingThis(mozilla::Mallo
     nsCOMPtr<nsISizeOf> iface = do_QueryInterface(mCachedURI);
     if (iface) {
       n += iface->SizeOfIncludingThis(aMallocSizeOf);
     }
   }
 
   // The following members don't need to be measured:
   // - mElement, because it is a pointer-to-self used to avoid QIs
+  // - mHistory, because it is non-owning
 
   return n;
 }
 
 static const nsAttrValue::EnumTable kAsAttributeTable[] = {
   { "",              DESTINATION_INVALID       },
   { "audio",         DESTINATION_AUDIO         },
   { "font",          DESTINATION_FONT          },
--- a/dom/base/Link.h
+++ b/dom/base/Link.h
@@ -6,28 +6,23 @@
 
 /**
  * This is the base class for all link classes.
  */
 
 #ifndef mozilla_dom_Link_h__
 #define mozilla_dom_Link_h__
 
+#include "mozilla/IHistory.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsIContent.h" // for nsLinkState
 #include "nsIContentPolicyBase.h"
 
 namespace mozilla {
 
-namespace places {
-
-class History;
-
-};
-
 class EventStates;
 
 namespace dom {
 
 class Element;
 
 #define MOZILLA_DOM_LINK_IMPLEMENTATION_IID               \
 { 0xb25edee6, 0xdd35, 0x4f8b,                             \
@@ -182,27 +177,29 @@ private:
                                      nsContentPolicyType& aPolicyType,
                                      nsString& aMimeType,
                                      nsAString& aMedia);
 
   mutable nsCOMPtr<nsIURI> mCachedURI;
 
   Element * const mElement;
 
+  // Strong reference to History.  The link has to unregister before History
+  // can disappear.
+  nsCOMPtr<IHistory> mHistory;
+
   uint16_t mLinkState;
 
   bool mNeedsRegistration : 1;
 
   bool mRegistered : 1;
 
   bool mHasPendingLinkUpdate : 1;
 
   bool mInDNSPrefetch : 1;
-
-  bool mHistory: 1;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(Link, MOZILLA_DOM_LINK_IMPLEMENTATION_IID)
 
 enum ASDestination : uint8_t {
   DESTINATION_INVALID,
   DESTINATION_AUDIO,
   DESTINATION_DOCUMENT,
--- a/toolkit/components/places/moz.build
+++ b/toolkit/components/places/moz.build
@@ -27,17 +27,16 @@ if CONFIG['MOZ_PLACES']:
         'nsINavBookmarksService.idl',
         'nsITaggingService.idl',
         'nsPIPlacesDatabase.idl',
     ]
 
     EXPORTS.mozilla.places = [
         'Database.h',
         'History.h',
-        'Shutdown.h',
     ]
 
     UNIFIED_SOURCES += [
         'Database.cpp',
         'FaviconHelpers.cpp',
         'Helpers.cpp',
         'History.cpp',
         'nsAnnoProtocolHandler.cpp',