Bug 1446951 - 3 - Make AsyncExecuteLegacyQueries singular. r=standard8
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 16 Mar 2018 18:10:09 +0100
changeset 409542 85d301fe0bb082f205f420b9970550ec05fb9563
parent 409541 528c24b35b1a1d0bbc8dd61e240eea066c6cc8f1
child 409543 cae9cbaae29e4a47bfd2b49fb86ac78124db6a11
push id101247
push usernerli@mozilla.com
push dateThu, 22 Mar 2018 23:00:51 +0000
treeherdermozilla-inbound@02e384bdf97d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs1446951
milestone61.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 1446951 - 3 - Make AsyncExecuteLegacyQueries singular. r=standard8 MozReview-Commit-ID: KyYw92tzyN6
browser/modules/WindowsJumpLists.jsm
toolkit/components/places/nsNavHistory.cpp
toolkit/components/places/nsPIPlacesDatabase.idl
toolkit/components/places/tests/unit/test_asyncExecuteLegacyQueries.js
toolkit/modules/NewTabUtils.jsm
--- a/browser/modules/WindowsJumpLists.jsm
+++ b/browser/modules/WindowsJumpLists.jsm
@@ -397,17 +397,17 @@ var WinTaskbarJumpList =
   function WTBLJL__getHistoryResults(aSortingMode, aLimit, aCallback, aScope) {
     var options = PlacesUtils.history.getNewQueryOptions();
     options.maxResults = aLimit;
     options.sortingMode = aSortingMode;
     var query = PlacesUtils.history.getNewQuery();
 
     // Return the pending statement to the caller, to allow cancelation.
     return PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
-                              .asyncExecuteLegacyQueries([query], 1, options, {
+                              .asyncExecuteLegacyQuery(query, options, {
       handleResult(aResultSet) {
         for (let row; (row = aResultSet.getNextRow());) {
           try {
             aCallback.call(aScope,
                            { uri: row.getResultByIndex(1),
                              title: row.getResultByIndex(2)
                            });
           } catch (e) {}
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -2888,35 +2888,31 @@ nsNavHistory::GetConnectionShutdownClien
   if (!client) {
     return NS_ERROR_UNEXPECTED;
   }
   client.forget(_shutdownClient);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNavHistory::AsyncExecuteLegacyQueries(nsINavHistoryQuery** aQueries,
-                                        uint32_t aQueryCount,
-                                        nsINavHistoryQueryOptions* aOptions,
-                                        mozIStorageStatementCallback* aCallback,
-                                        mozIStoragePendingStatement** _stmt)
+nsNavHistory::AsyncExecuteLegacyQuery(nsINavHistoryQuery* aQuery,
+                                      nsINavHistoryQueryOptions* aOptions,
+                                      mozIStorageStatementCallback* aCallback,
+                                      mozIStoragePendingStatement** _stmt)
 {
   NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
-  NS_ENSURE_ARG(aQueries);
+  NS_ENSURE_ARG(aQuery);
   NS_ENSURE_ARG(aOptions);
   NS_ENSURE_ARG(aCallback);
   NS_ENSURE_ARG_POINTER(_stmt);
 
+  nsCOMPtr<nsNavHistoryQuery> query = do_QueryObject(aQuery);
+  NS_ENSURE_STATE(query);
   nsCOMArray<nsNavHistoryQuery> queries;
-  for (uint32_t i = 0; i < aQueryCount; i ++) {
-    nsCOMPtr<nsNavHistoryQuery> query = do_QueryInterface(aQueries[i]);
-    NS_ENSURE_STATE(query);
-    queries.AppendElement(query.forget());
-  }
-  NS_ENSURE_ARG_MIN(queries.Count(), 1);
+  queries.AppendObject(query);
 
   nsCOMPtr<nsNavHistoryQueryOptions> options = do_QueryInterface(aOptions);
   NS_ENSURE_ARG(options);
 
   nsCString queryString;
   bool paramsPresent = false;
   nsNavHistory::StringHash addParams(HISTORY_DATE_CONT_LENGTH);
   nsresult rv = ConstructQueryString(queries, options, queryString,
--- a/toolkit/components/places/nsPIPlacesDatabase.idl
+++ b/toolkit/components/places/nsPIPlacesDatabase.idl
@@ -22,30 +22,29 @@ interface nsIAsyncShutdownClient;
 interface nsPIPlacesDatabase : nsISupports
 {
   /**
    * The database connection used by Places.
    */
   readonly attribute mozIStorageConnection DBConnection;
 
   /**
-   * Asynchronously executes the statement created from queries.
+   * Asynchronously executes the statement created from a query.
    *
-   * @see nsINavHistoryService::executeQueries
+   * @see nsINavHistoryService::executeQuery
    * @note THIS IS A TEMPORARY API.  Don't rely on it, since it will be replaced
    *       in future versions by a real async querying API.
    * @note Results obtained from this method differ from results obtained from
-   *       executeQueries, because there is additional filtering and sorting
-   *       done by the latter.  Thus you should use executeQueries, unless you
+   *       executeQuery, because there is additional filtering and sorting
+   *       done by the latter.  Thus you should use executeQuery, unless you
    *       are absolutely sure that the returned results are fine for
    *       your use-case.
    */
-  mozIStoragePendingStatement asyncExecuteLegacyQueries(
-    [array, size_is(aQueryCount)] in nsINavHistoryQuery aQueries,
-    in unsigned long aQueryCount,
+  mozIStoragePendingStatement asyncExecuteLegacyQuery(
+    in nsINavHistoryQuery aQuery,
     in nsINavHistoryQueryOptions aOptions,
     in mozIStorageStatementCallback aCallback);
 
   /**
    * Hook for clients who need to perform actions during/by the end of
    * the shutdown of the database.
    * May be null if it's too late to get one.
    */
--- a/toolkit/components/places/tests/unit/test_asyncExecuteLegacyQueries.js
+++ b/toolkit/components/places/tests/unit/test_asyncExecuteLegacyQueries.js
@@ -1,26 +1,26 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-// This is a test for asyncExecuteLegacyQueries API.
+// This is a test for asyncExecuteLegacyQuery API.
 
 add_task(async function test_history_query() {
   let uri = "http://test.visit.mozilla.com/";
   let title = "Test visit";
   await PlacesTestUtils.addVisits({ uri, title });
 
   let options = PlacesUtils.history.getNewQueryOptions();
   options.sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING;
   let query = PlacesUtils.history.getNewQuery();
 
   return new Promise(resolve => {
     PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
-                       .asyncExecuteLegacyQueries([query], 1, options, {
+                       .asyncExecuteLegacyQuery(query, options, {
       handleResult(aResultSet) {
         for (let row; (row = aResultSet.getNextRow());) {
           try {
             Assert.equal(row.getResultByIndex(1), uri);
             Assert.equal(row.getResultByIndex(2), title);
           } catch (e) {
             do_throw("Error while fetching page data.");
           }
@@ -47,17 +47,17 @@ add_task(async function test_bookmarks_q
 
   let options = PlacesUtils.history.getNewQueryOptions();
   options.sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_LASMODIFIED_DESCENDING;
   options.queryType = options.QUERY_TYPE_BOOKMARKS;
   let query = PlacesUtils.history.getNewQuery();
 
   return new Promise(resolve => {
     PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
-                       .asyncExecuteLegacyQueries([query], 1, options, {
+                       .asyncExecuteLegacyQuery(query, options, {
       handleResult(aResultSet) {
         for (let row; (row = aResultSet.getNextRow());) {
           try {
             Assert.equal(row.getResultByIndex(1), url);
             Assert.equal(row.getResultByIndex(2), title);
           } catch (e) {
             do_throw("Error while fetching page data.");
           }
--- a/toolkit/modules/NewTabUtils.jsm
+++ b/toolkit/modules/NewTabUtils.jsm
@@ -612,17 +612,17 @@ var PlacesProvider = {
 
         aCallback(links);
       }
     };
 
     // Execute the query.
     let query = PlacesUtils.history.getNewQuery();
     let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase);
-    db.asyncExecuteLegacyQueries([query], 1, options, callback);
+    db.asyncExecuteLegacyQuery(query, options, callback);
   },
 
   /**
    * Registers an object that will be notified when the provider's links change.
    * @param aObserver An object with the following optional properties:
    *        * onLinkChanged: A function that's called when a single link
    *          changes.  It's passed the provider and the link object.  Only the
    *          link's `url` property is guaranteed to be present.  If its `title`