Bug 1590692 - Make Geckoview history a static component. r=lina
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 24 Oct 2019 17:17:24 +0000
changeset 498888 12353ac49ff9c15b67ca32a470974aacb81740ff
parent 498887 54471d01065b459d156c6a4e1a241bc8f40daf0c
child 498889 12a024047dbda41934dd9ec9894d28d621b4a911
push id36730
push userbtara@mozilla.com
push dateFri, 25 Oct 2019 03:46:30 +0000
treeherdermozilla-central@11b08c1b0061 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslina
bugs1590692
milestone72.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 1590692 - Make Geckoview history a static component. r=lina Now that there's only one android history implementation we can make it a static component. So do the same as toolkit/components/places/components.conf. Differential Revision: https://phabricator.services.mozilla.com/D50180
mobile/android/components/build/nsBrowserModule.cpp
mobile/android/components/geckoview/GeckoViewHistory.h
mobile/android/components/geckoview/components.conf
mobile/android/components/geckoview/moz.build
toolkit/components/places/History.cpp
toolkit/components/places/History.h
--- a/mobile/android/components/build/nsBrowserModule.cpp
+++ b/mobile/android/components/build/nsBrowserModule.cpp
@@ -2,46 +2,21 @@
 /* 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 "mozilla/ModuleUtils.h"
 
 #include "nsShellService.h"
 
-#ifdef MOZ_ANDROID_HISTORY
-#  include "GeckoViewHistory.h"
-#  include "nsDocShellCID.h"
-#  include "mozilla/jni/Utils.h"
-#endif
-
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsShellService)
 NS_DEFINE_NAMED_CID(nsShellService_CID);
 
-#ifdef MOZ_ANDROID_HISTORY
-#  define NS_ANDROIDHISTORY_CID                        \
-    {                                                  \
-      0xCCAA4880, 0x44DD, 0x40A7, {                    \
-        0xA1, 0x3F, 0x61, 0x56, 0xFC, 0x88, 0x2C, 0x0B \
-      }                                                \
-    }
-
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(GeckoViewHistory,
-                                         GeckoViewHistory::GetSingleton)
-NS_DEFINE_NAMED_CID(NS_ANDROIDHISTORY_CID);
-#endif
-
 static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
     {&knsShellService_CID, false, nullptr, nsShellServiceConstructor},
-#ifdef MOZ_ANDROID_HISTORY
-    {&kNS_ANDROIDHISTORY_CID, false, nullptr, GeckoViewHistoryConstructor},
-#endif
     {nullptr}};
 
 static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
     {nsShellService_ContractID, &knsShellService_CID},
-#ifdef MOZ_ANDROID_HISTORY
-    {NS_IHISTORY_CONTRACTID, &kNS_ANDROIDHISTORY_CID},
-#endif
     {nullptr}};
 
 extern const mozilla::Module kBrowserModule = {mozilla::Module::kVersion,
                                                kBrowserCIDs, kBrowserContracts};
--- a/mobile/android/components/geckoview/GeckoViewHistory.h
+++ b/mobile/android/components/geckoview/GeckoViewHistory.h
@@ -1,16 +1,16 @@
 /* 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 GECKOVIEWHISTORY_H
 #define GECKOVIEWHISTORY_H
 
-#include "IHistory.h"
+#include "mozilla/IHistory.h"
 #include "nsDataHashtable.h"
 #include "nsTObserverArray.h"
 #include "nsURIHashKey.h"
 #include "nsINamed.h"
 #include "nsITimer.h"
 #include "nsIURI.h"
 
 #include "mozilla/StaticPtr.h"
new file mode 100644
--- /dev/null
+++ b/mobile/android/components/geckoview/components.conf
@@ -0,0 +1,16 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+Classes = [
+    {
+        'cid': '{0937a705-91a6-417a-8292-b22eb10da86c}',
+        'contract_ids': ['@mozilla.org/browser/history;1'],
+        'singleton': True,
+        'type': 'GeckoViewHistory',
+        'headers': ['GeckoViewHistory.h'],
+        'constructor': 'GeckoViewHistory::GetSingleton',
+    },
+]
--- a/mobile/android/components/geckoview/moz.build
+++ b/mobile/android/components/geckoview/moz.build
@@ -3,24 +3,21 @@
 # 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/.
 
 if CONFIG['MOZ_ANDROID_HISTORY']:
     EXPORTS += [
         'GeckoViewHistory.h',
     ]
-
     SOURCES += [
         'GeckoViewHistory.cpp',
     ]
-
-    LOCAL_INCLUDES += [
-        '/docshell/base',
-        '/dom/base',
+    XPCOM_MANIFESTS += [
+        'components.conf',
     ]
     include('/ipc/chromium/chromium-config.mozbuild')
 
 EXTRA_COMPONENTS += [
     'GeckoView.manifest',
     'GeckoViewExternalAppService.js',
     'GeckoViewPermission.js',
     'GeckoViewPrompt.js',
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -1914,17 +1914,17 @@ size_t History::SizeOfIncludingThis(mozi
 }
 
 /* static */
 History* History::GetService() {
   if (gService) {
     return gService;
   }
 
-  nsCOMPtr<IHistory> service(do_GetService(NS_IHISTORY_CONTRACTID));
+  nsCOMPtr<IHistory> service = services::GetHistoryService();
   if (service) {
     NS_ASSERTION(gService, "Our constructor was not run?!");
   }
 
   return gService;
 }
 
 /* static */
--- a/toolkit/components/places/History.h
+++ b/toolkit/components/places/History.h
@@ -25,23 +25,16 @@
 #include "mozIStorageConnection.h"
 
 namespace mozilla {
 namespace places {
 
 struct VisitData;
 class ConcurrentStatementsHolder;
 
-#define NS_HISTORYSERVICE_CID                        \
-  {                                                  \
-    0x0937a705, 0x91a6, 0x417a, {                    \
-      0x82, 0x92, 0xb2, 0x2e, 0xb1, 0x0d, 0xa8, 0x6c \
-    }                                                \
-  }
-
 // Initial size of mRecentlyVisitedURIs.
 #define RECENTLY_VISITED_URIS_SIZE 64
 // Microseconds after which a visit can be expired from mRecentlyVisitedURIs.
 // When an URI is reloaded we only take into account the first visit to it, and
 // ignore any subsequent visits, if they happen before this time has elapsed.
 // A commonly found case is to reload a page every 5 minutes, so we pick a time
 // larger than that.
 #define RECENTLY_VISITED_URIS_MAX_AGE 6 * 60 * PR_USEC_PER_SEC