Bug 524972 Remove nsTArray from nsINavBookmarksService.idl r=mak
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Wed, 28 Oct 2009 23:52:41 +0000
changeset 34260 17addc6beaed4f1a0c00b9ab311ba6fa06a7a196
parent 34259 efaab8e8f381fa22e5263e3284386d7dd1b2ec22
child 34261 1d95bcb9b00f7d789f6771dbca44b967adad843c
push idunknown
push userunknown
push dateunknown
reviewersmak
bugs524972
milestone1.9.3a1pre
Bug 524972 Remove nsTArray from nsINavBookmarksService.idl r=mak
toolkit/components/places/public/nsINavBookmarksService.idl
toolkit/components/places/src/nsNavBookmarks.cpp
toolkit/components/places/src/nsNavBookmarks.h
--- a/toolkit/components/places/public/nsINavBookmarksService.idl
+++ b/toolkit/components/places/public/nsINavBookmarksService.idl
@@ -36,33 +36,26 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
-%{C++
-#include "nsTArray.h"
-#include "prtypes.h"
-%}
-
 interface nsIFile;
 interface nsIURI;
 interface nsITransaction;
 interface nsINavHistoryBatchCallback;
 
-[ptr] native PRInt64Array(nsTArray<PRInt64>);
-
 /**
  * Observer for bookmark changes.
  */
 
-[scriptable, uuid(1f7e9032-b2c0-4561-b35b-94ba3f8344e2)]
+[scriptable, uuid(4270ae71-d92c-4a6f-81c7-0d7f76f01c06)]
 interface nsINavBookmarkObserver : nsISupports
 {
   /**
    * Notify this observer that a batch transaction has started.
    * Other notifications will be sent during the batch change,
    * but the observer is guaranteed that onEndUpdateBatch() will be called
    * at the completion of changes.
    */
@@ -519,28 +512,20 @@ interface nsINavBookmarksService : nsISu
   /**
    * Get the parent folder's id for an item.
    */
   long long getFolderIdForItem(in long long aItemId);
 
   /**
    * Returns the list of bookmark ids that contain the given URI.
    */
-  void getBookmarkIdsForURI(in nsIURI aURI, out unsigned long count,
+  void getBookmarkIdsForURI(in nsIURI aURI, [optional] out unsigned long count,
                             [array, retval, size_is(count)] out long long bookmarks);
 
   /**
-   * TArray version of getBookmarksIdForURI for ease of use in C++ code.
-   * Pass in a reference to a TArray; it will get cleared and filled with
-   * the resulting list of folder IDs.
-   */
-  [noscript] void getBookmarkIdsForURITArray(in nsIURI aURI,
-                                           in PRInt64Array aResult);
-
-  /**
    * Associates the given keyword with the given bookmark.
    *
    * Use an empty keyword to clear the keyword associated with the URI.
    * In both of these cases, succeeds but does nothing if the URL/keyword is not found.
    */
   void setKeywordForBookmark(in long long aItemId, in AString aKeyword);
 
   /**
--- a/toolkit/components/places/src/nsNavBookmarks.cpp
+++ b/toolkit/components/places/src/nsNavBookmarks.cpp
@@ -1203,17 +1203,17 @@ nsNavBookmarks::InsertBookmark(PRInt64 a
   // bookmark's url
   PRInt64 grandParentId;
   rv = GetFolderIdForItem(aFolder, &grandParentId);
   NS_ENSURE_SUCCESS(rv, rv);
   if (grandParentId == mTagRoot) {
     // query for all bookmarks for that URI, notify for each
     nsTArray<PRInt64> bookmarks;
 
-    rv = GetBookmarkIdsForURITArray(aURI, &bookmarks);
+    rv = GetBookmarkIdsForURITArray(aURI, bookmarks);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (bookmarks.Length()) {
       for (PRUint32 i = 0; i < bookmarks.Length(); i++) {
         ENUMERATE_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver,
                             OnItemChanged(bookmarks[i],
                                           NS_LITERAL_CSTRING("tags"),
                                           PR_FALSE,
@@ -1315,17 +1315,17 @@ nsNavBookmarks::RemoveItem(PRInt64 aItem
     rv = GetFolderIdForItem(folderId, &grandParentId);
     NS_ENSURE_SUCCESS(rv, rv);
     if (grandParentId == mTagRoot) {
       nsCOMPtr<nsIURI> uri;
       rv = NS_NewURI(getter_AddRefs(uri), spec);
       NS_ENSURE_SUCCESS(rv, rv);
       nsTArray<PRInt64> bookmarks;
 
-      rv = GetBookmarkIdsForURITArray(uri, &bookmarks);
+      rv = GetBookmarkIdsForURITArray(uri, bookmarks);
       NS_ENSURE_SUCCESS(rv, rv);
 
       if (bookmarks.Length()) {
         for (PRUint32 i = 0; i < bookmarks.Length(); i++) {
           ENUMERATE_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver,
                               OnItemChanged(bookmarks[i],
                                             NS_LITERAL_CSTRING("tags"),
                                             PR_FALSE,
@@ -1859,17 +1859,17 @@ nsNavBookmarks::RemoveFolderChildren(PRI
       // bookmark's url.
 
       if (child.grandParentId == mTagRoot) {
         nsCOMPtr<nsIURI> uri;
         rv = NS_NewURI(getter_AddRefs(uri), child.url);
         NS_ENSURE_SUCCESS(rv, rv);
 
         nsTArray<PRInt64> bookmarks;
-        rv = GetBookmarkIdsForURITArray(uri, &bookmarks);
+        rv = GetBookmarkIdsForURITArray(uri, bookmarks);
         NS_ENSURE_SUCCESS(rv, rv);
 
         if (bookmarks.Length()) {
           for (PRUint32 i = 0; i < bookmarks.Length(); i++) {
             ENUMERATE_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver,
                                 OnItemChanged(bookmarks[i],
                                               NS_LITERAL_CSTRING("tags"),
                                               PR_FALSE,
@@ -2687,33 +2687,33 @@ nsNavBookmarks::GetFolderIdForItem(PRInt
   rv = mDBGetItemProperties->GetInt64(kGetItemPropertiesIndex_Parent, aFolderId);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // this should not happen, but see bug #400448 for details
   NS_ENSURE_TRUE(aItemId != *aFolderId, NS_ERROR_UNEXPECTED);
   return NS_OK;
 }
 
-NS_IMETHODIMP
+nsresult
 nsNavBookmarks::GetBookmarkIdsForURITArray(nsIURI *aURI,
-                                         nsTArray<PRInt64> *aResult) 
+                                           nsTArray<PRInt64> &aResult)
 {
+  NS_PRECONDITION(aURI, "Should not be null");
   NS_ENSURE_ARG(aURI);
-  NS_ENSURE_ARG_POINTER(aResult);
 
   mozStorageStatementScoper scope(mDBFindURIBookmarks);
 
   nsresult rv = BindStatementURI(mDBFindURIBookmarks, 0, aURI);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = mDBFindURIBookmarks->BindInt32Parameter(1, TYPE_BOOKMARK);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRBool more;
   while (NS_SUCCEEDED((rv = mDBFindURIBookmarks->ExecuteStep(&more))) && more) {
-    if (! aResult->AppendElement(
+    if (!aResult.AppendElement(
         mDBFindURIBookmarks->AsInt64(kFindBookmarksIndex_ID)))
       return NS_ERROR_OUT_OF_MEMORY;
   }
 
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
@@ -2725,17 +2725,17 @@ nsNavBookmarks::GetBookmarkIdsForURI(nsI
   NS_ENSURE_ARG_POINTER(aCount);
   NS_ENSURE_ARG_POINTER(aBookmarks);
 
   *aCount = 0;
   *aBookmarks = nsnull;
   nsTArray<PRInt64> bookmarks;
 
   // Get the information from the DB as a TArray
-  nsresult rv = GetBookmarkIdsForURITArray(aURI, &bookmarks);
+  nsresult rv = GetBookmarkIdsForURITArray(aURI, bookmarks);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Copy the results into a new array for output
   if (bookmarks.Length()) {
     *aBookmarks = static_cast<PRInt64*>
                              (nsMemory::Alloc(sizeof(PRInt64) * bookmarks.Length()));
     if (! *aBookmarks)
       return NS_ERROR_OUT_OF_MEMORY;
@@ -3055,17 +3055,17 @@ nsNavBookmarks::OnVisit(nsIURI *aURI, PR
 {
   // If the page is bookmarked, we need to notify observers
   PRBool bookmarked = PR_FALSE;
   IsBookmarked(aURI, &bookmarked);
   if (bookmarked) {
     // query for all bookmarks for that URI, notify for each
     nsTArray<PRInt64> bookmarks;
 
-    nsresult rv = GetBookmarkIdsForURITArray(aURI, &bookmarks);
+    nsresult rv = GetBookmarkIdsForURITArray(aURI, bookmarks);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (bookmarks.Length()) {
       for (PRUint32 i = 0; i < bookmarks.Length(); i++)
         ENUMERATE_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver,
                             OnItemVisited(bookmarks[i], aVisitID, aTime))
     }
   }
@@ -3083,17 +3083,17 @@ nsNavBookmarks::OnDeleteURI(nsIURI *aURI
 {
   // If the page is bookmarked, we need to notify observers
   PRBool bookmarked = PR_FALSE;
   IsBookmarked(aURI, &bookmarked);
   if (bookmarked) {
     // query for all bookmarks for that URI, notify for each 
     nsTArray<PRInt64> bookmarks;
 
-    nsresult rv = GetBookmarkIdsForURITArray(aURI, &bookmarks);
+    nsresult rv = GetBookmarkIdsForURITArray(aURI, bookmarks);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (bookmarks.Length()) {
       for (PRUint32 i = 0; i < bookmarks.Length(); i ++)
         ENUMERATE_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver,
                             OnItemChanged(bookmarks[i],
                                           NS_LITERAL_CSTRING("cleartime"),
                                           PR_FALSE,
@@ -3152,17 +3152,17 @@ nsNavBookmarks::OnPageChanged(nsIURI *aU
                                         PR_FALSE,
                                         NS_ConvertUTF16toUTF8(aValue),
                                         0,
                                         TYPE_BOOKMARK));
     }
     else {
       // query for all bookmarks for that URI, notify for each 
       nsTArray<PRInt64> bookmarks;
-      rv = GetBookmarkIdsForURITArray(aURI, &bookmarks);
+      rv = GetBookmarkIdsForURITArray(aURI, bookmarks);
       NS_ENSURE_SUCCESS(rv, rv);
 
       if (bookmarks.Length()) {
         for (PRUint32 i = 0; i < bookmarks.Length(); i ++)
           ENUMERATE_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver,
                               OnItemChanged(bookmarks[i],
                                             NS_LITERAL_CSTRING("favicon"),
                                             PR_FALSE,
--- a/toolkit/components/places/src/nsNavBookmarks.h
+++ b/toolkit/components/places/src/nsNavBookmarks.h
@@ -254,16 +254,24 @@ private:
                               PRInt64 aParentId,
                               PRInt32 aIndex,
                               const nsACString &aTitle,
                               PRTime aDateAdded,
                               PRTime aLastModified,
                               const nsAString &aServiceContractId,
                               PRInt64 *_retval);
 
+  /**
+   * TArray version of getBookmarksIdForURI for ease of use in C++ code.
+   * Pass in a reference to a TArray; it will get filled with the
+   * resulting list of bookmark IDs.
+   */
+  nsresult GetBookmarkIdsForURITArray(nsIURI *aURI,
+                                      nsTArray<PRInt64> &aResult);
+
   // kGetInfoIndex_* results + kGetChildrenIndex_* results
   nsCOMPtr<mozIStorageStatement> mDBGetChildren;
   static const PRInt32 kGetChildrenIndex_Position;
   static const PRInt32 kGetChildrenIndex_Type;
   static const PRInt32 kGetChildrenIndex_PlaceID;
   static const PRInt32 kGetChildrenIndex_FolderTitle;
   static const PRInt32 kGetChildrenIndex_ServiceContractId;