Backed out changeset 5037343f92fc on CLOSED TREE
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 10 Aug 2010 00:15:50 +0200
changeset 49241 4916598cf7d9c7e4aa657c96f62e4d7d1f176da7
parent 49212 5037343f92fced1f3d839de6a9b7778b9a994628
child 49242 34c42da84827087df90afde763cf57b1f76f499a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b4pre
backs out5037343f92fced1f3d839de6a9b7778b9a994628
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 5037343f92fc on CLOSED TREE
toolkit/components/places/src/nsNavBookmarks.cpp
toolkit/components/places/src/nsNavBookmarks.h
toolkit/components/places/tests/bookmarks/test_keywords.js
--- a/toolkit/components/places/src/nsNavBookmarks.cpp
+++ b/toolkit/components/places/src/nsNavBookmarks.cpp
@@ -56,18 +56,16 @@
 #include "nsPlacesTriggers.h"
 #include "nsPlacesTables.h"
 #include "nsPlacesIndexes.h"
 #include "nsPlacesMacros.h"
 #include "Helpers.h"
 
 #include "mozilla/FunctionTimer.h"
 
-#define BOOKMARKS_TO_KEYWORDS_INITIAL_CACHE_SIZE 64
-
 const PRInt32 nsNavBookmarks::kFindBookmarksIndex_ID = 0;
 const PRInt32 nsNavBookmarks::kFindBookmarksIndex_Type = 1;
 const PRInt32 nsNavBookmarks::kFindBookmarksIndex_PlaceID = 2;
 const PRInt32 nsNavBookmarks::kFindBookmarksIndex_Parent = 3;
 const PRInt32 nsNavBookmarks::kFindBookmarksIndex_Position = 4;
 const PRInt32 nsNavBookmarks::kFindBookmarksIndex_Title = 5;
 
 // These columns sit to the right of the kGetInfoIndex_* columns.
@@ -91,41 +89,16 @@ using namespace mozilla::places;
 
 PLACES_FACTORY_SINGLETON_IMPLEMENTATION(nsNavBookmarks, gBookmarksService)
 
 #define BOOKMARKS_ANNO_PREFIX "bookmarks/"
 #define BOOKMARKS_TOOLBAR_FOLDER_ANNO NS_LITERAL_CSTRING(BOOKMARKS_ANNO_PREFIX "toolbarFolder")
 #define GUID_ANNO NS_LITERAL_CSTRING("placesInternal/GUID")
 #define READ_ONLY_ANNO NS_LITERAL_CSTRING("placesInternal/READ_ONLY")
 
-
-namespace {
-
-struct keywordSearchData
-{
-  PRInt64 itemId;
-  nsString keyword;
-};
-
-PLDHashOperator
-SearchBookmarkForKeyword(nsTrimInt64HashKey::KeyType aKey,
-                         const nsString aValue,
-                         void* aUserArg)
-{
-  keywordSearchData* data = reinterpret_cast<keywordSearchData*>(aUserArg);
-  if (data->keyword.Equals(aValue)) {
-    data->itemId = aKey;
-    return PL_DHASH_STOP;
-  }
-  return PL_DHASH_NEXT;
-}
-
-} // Anonymous namespace.
-
-
 nsNavBookmarks::nsNavBookmarks() : mItemCount(0)
                                  , mRoot(0)
                                  , mBookmarksRoot(0)
                                  , mTagRoot(0)
                                  , mToolbarFolder(0)
                                  , mBatchLevel(0)
                                  , mBatchDBTransaction(nsnull)
                                  , mCanNotify(false)
@@ -358,30 +331,49 @@ nsNavBookmarks::GetStatement(const nsCOM
     "WHERE id = :item_id"));
 
   RETURN_IF_STMT(mDBSetItemLastModified, NS_LITERAL_CSTRING(
     "UPDATE moz_bookmarks SET lastModified = :date WHERE id = :item_id"));
 
   RETURN_IF_STMT(mDBSetItemIndex, NS_LITERAL_CSTRING(
     "UPDATE moz_bookmarks SET position = :item_index WHERE id = :item_id"));
 
+  // Get keyword text for bookmark id.
+  RETURN_IF_STMT(mDBGetKeywordForBookmark, NS_LITERAL_CSTRING(
+    "SELECT k.keyword FROM moz_bookmarks b "
+    "JOIN moz_keywords k ON k.id = b.keyword_id "
+    "WHERE b.id = :item_id"));
+
   // Get keyword text for bookmarked URI.
   RETURN_IF_STMT(mDBGetKeywordForURI, NS_LITERAL_CSTRING(
     "SELECT k.keyword "
     "FROM ( "
       "SELECT id FROM moz_places_temp "
       "WHERE url = :page_url "
       "UNION ALL "
       "SELECT id FROM moz_places "
       "WHERE url = :page_url "
       "LIMIT 1 "
     ") AS h "
     "JOIN moz_bookmarks b ON b.fk = h.id "
     "JOIN moz_keywords k ON k.id = b.keyword_id"));
 
+  // Get URI for keyword.
+  RETURN_IF_STMT(mDBGetURIForKeyword, NS_LITERAL_CSTRING(
+    "SELECT url FROM moz_keywords k "
+    "JOIN moz_bookmarks b ON b.keyword_id = k.id "
+    "JOIN moz_places_temp h ON b.fk = h.id "
+    "WHERE k.keyword = :keyword "
+    "UNION ALL "
+    "SELECT url FROM moz_keywords k "
+    "JOIN moz_bookmarks b ON b.keyword_id = k.id "
+    "JOIN moz_places h ON b.fk = h.id "
+    "WHERE k.keyword = :keyword "
+    "LIMIT 1"));
+
   RETURN_IF_STMT(mDBAdjustPosition, NS_LITERAL_CSTRING(
     "UPDATE moz_bookmarks SET position = position + :delta "
     "WHERE parent = :parent "
       "AND position >= :from_index AND position <= :to_index"));
 
   RETURN_IF_STMT(mDBRemoveItem, NS_LITERAL_CSTRING(
     "DELETE FROM moz_bookmarks WHERE id = :item_id"));
 
@@ -498,16 +490,18 @@ nsNavBookmarks::FinalizeStatements() {
     mDBInsertBookmark,
     mDBIsBookmarkedInDatabase,
     mDBIsRealBookmark,
     mDBGetLastBookmarkID,
     mDBSetItemDateAdded,
     mDBSetItemLastModified,
     mDBSetItemIndex,
     mDBGetKeywordForURI,
+    mDBGetKeywordForBookmark,
+    mDBGetURIForKeyword,
     mDBAdjustPosition,
     mDBRemoveItem,
     mDBGetLastChildId,
     mDBMoveItem,
     mDBSetItemTitle,
     mDBChangeBookmarkURI,
     mDBIsURIBookmarkedInDatabase,
     mDBFindRedirectedBookmark,
@@ -1121,19 +1115,16 @@ nsNavBookmarks::RemoveItem(PRInt64 aItem
   if (itemType == TYPE_BOOKMARK) {
     // UpdateFrecency needs to know whether placeId is still bookmarked.
     // Although we removed aItemId, placeId may still be bookmarked elsewhere;
     // IsRealBookmark will know.
     nsNavHistory* history = nsNavHistory::GetHistoryService();
     NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
     rv = history->UpdateFrecency(placeId, IsRealBookmark(placeId));
     NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = UpdateKeywordsHashForRemovedBookmark(aItemId);
-    NS_ENSURE_SUCCESS(rv, rv);
   }
 
   NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
                    nsINavBookmarkObserver,
                    OnItemRemoved(aItemId, folderId, childIndex, itemType));
 
   if (itemType == TYPE_BOOKMARK) {
     // If the removed bookmark was a child of a tag container, notify all
@@ -1692,19 +1683,16 @@ nsNavBookmarks::RemoveFolderChildren(PRI
 
       // UpdateFrecency needs to know whether placeId is still bookmarked.
       // Although we removed a child of aFolderId that bookmarked it, it may
       // still be bookmarked elsewhere; IsRealBookmark will know.
       nsNavHistory* history = nsNavHistory::GetHistoryService();
       NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
       rv = history->UpdateFrecency(placeId, IsRealBookmark(placeId));
       NS_ENSURE_SUCCESS(rv, rv);
-
-      rv = UpdateKeywordsHashForRemovedBookmark(child.itemId);
-      NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   rv = transaction.Commit();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Call observers in reverse order to serve children before their parent.
   for (PRInt32 i = folderChildrenArray.Length() - 1; i >= 0 ; i--) {
@@ -2753,105 +2741,106 @@ nsNavBookmarks::SetItemIndex(PRInt64 aIt
                    nsINavBookmarkObserver,
                    OnItemMoved(aItemId, parent, oldIndex, parent, aNewIndex,
                                itemType));
 
   return NS_OK;
 }
 
 
-nsresult
-nsNavBookmarks::UpdateKeywordsHashForRemovedBookmark(PRInt64 aItemId)
-{
-  nsAutoString kw;
-  if (NS_SUCCEEDED(GetKeywordForBookmark(aItemId, kw)) && !kw.IsEmpty()) {
-    nsresult rv = EnsureKeywordsHash();
-    NS_ENSURE_SUCCESS(rv, rv);
-    mBookmarkToKeywordHash.Remove(aItemId);
-  }
-  return NS_OK;
-}
-
-
 NS_IMETHODIMP
 nsNavBookmarks::SetKeywordForBookmark(PRInt64 aBookmarkId,
                                       const nsAString& aKeyword)
 {
   NS_ENSURE_ARG_MIN(aBookmarkId, 1);
 
-  nsresult rv = EnsureKeywordsHash();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Shortcuts are always lowercased internally.
-  nsAutoString keyword(aKeyword);
-  ToLowerCase(keyword);
-
-  // Check if bookmark was already associated to a keyword.
-  nsAutoString oldKeyword;
-  rv = GetKeywordForBookmark(aBookmarkId, oldKeyword);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Trying to set the same value or to remove a nonexistent keyword is a no-op.
-  if (keyword.Equals(oldKeyword) || (keyword.IsEmpty() && oldKeyword.IsEmpty()))
-    return NS_OK;
-
   mozStorageTransaction transaction(mDBConn, PR_FALSE);
-
-  nsCOMPtr<mozIStorageStatement> updateBookmarkStmt;
+  nsresult rv;
+  PRInt64 keywordId = 0;
+  if (!aKeyword.IsEmpty()) {
+    // Shortcuts are always lowercased internally.
+    nsAutoString kwd(aKeyword);
+    ToLowerCase(kwd);
+
+    //  Attempt to find a pre-existing keyword record.
+    nsCOMPtr<mozIStorageStatement> getKeywordStmnt;
+    rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
+        "SELECT id from moz_keywords WHERE keyword = :keyword"),
+      getter_AddRefs(getKeywordStmnt));
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = getKeywordStmnt->BindStringByName(NS_LITERAL_CSTRING("keyword"), kwd);
+    NS_ENSURE_SUCCESS(rv, rv);
+    PRBool hasResult;
+    rv = getKeywordStmnt->ExecuteStep(&hasResult);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    if (hasResult) {
+      rv = getKeywordStmnt->GetInt64(0, &keywordId);
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
+    else {
+      // Create a new keyword record.
+      nsCOMPtr<mozIStorageStatement> addKeywordStmnt;
+      rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
+          "INSERT INTO moz_keywords (keyword) VALUES (:keyword)"),
+        getter_AddRefs(addKeywordStmnt));
+      NS_ENSURE_SUCCESS(rv, rv);
+      rv = addKeywordStmnt->BindStringByName(NS_LITERAL_CSTRING("keyword"), kwd);
+      NS_ENSURE_SUCCESS(rv, rv);
+      rv = addKeywordStmnt->Execute();
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      nsCOMPtr<mozIStorageStatement> idStmt;
+      rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
+          "SELECT id "
+          "FROM moz_keywords "
+          "ORDER BY ROWID DESC "
+          "LIMIT 1"),
+        getter_AddRefs(idStmt));
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      rv = idStmt->ExecuteStep(&hasResult);
+      NS_ENSURE_SUCCESS(rv, rv);
+      NS_ASSERTION(hasResult, "hasResult is false but the call succeeded?");
+      rv = idStmt->GetInt64(0, &keywordId);
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
+  }
+
+  // Update bookmark record w/ the keyword's id or null.
+  nsCOMPtr<mozIStorageStatement> updateKeywordStmnt;
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
-    "UPDATE moz_bookmarks "
-    "SET keyword_id = (SELECT id FROM moz_keywords WHERE keyword = :keyword), "
-        "lastModified = :date "
-    "WHERE id = :item_id "
-  ), getter_AddRefs(updateBookmarkStmt));
+      "UPDATE moz_bookmarks SET keyword_id = :keyword_id, lastModified = :date "
+      "WHERE id = :item_id"),
+    getter_AddRefs(updateKeywordStmnt));
   NS_ENSURE_SUCCESS(rv, rv);
-
-  if (keyword.IsEmpty()) {
-    // Remove keyword association from the hash.
-    mBookmarkToKeywordHash.Remove(aBookmarkId);
-    rv = updateBookmarkStmt->BindNullByName(NS_LITERAL_CSTRING("keyword"));
+  if (keywordId > 0) {
+    rv = updateKeywordStmnt->BindInt64ByName(NS_LITERAL_CSTRING("keyword_id"),
+                                             keywordId);
   }
-   else {
-    // We are associating bookmark to a new keyword. Create a new keyword
-    // record if needed.
-    nsCOMPtr<mozIStorageStatement> newKeywordStmt;
-    rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
-      "INSERT OR IGNORE INTO moz_keywords (keyword) VALUES (:keyword)"
-    ), getter_AddRefs(newKeywordStmt));
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = newKeywordStmt->BindStringByName(NS_LITERAL_CSTRING("keyword"),
-                                          keyword);
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = newKeywordStmt->Execute();
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // Add new keyword association to the hash, removing the old one if needed.
-    if (!oldKeyword.IsEmpty())
-      mBookmarkToKeywordHash.Remove(aBookmarkId);
-    mBookmarkToKeywordHash.Put(aBookmarkId, keyword);
-    rv = updateBookmarkStmt->BindStringByName(NS_LITERAL_CSTRING("keyword"), keyword);
+  else {
+    rv = updateKeywordStmnt->BindNullByName(NS_LITERAL_CSTRING("keyword_id"));
   }
   NS_ENSURE_SUCCESS(rv, rv);
   PRTime lastModified = PR_Now();
-  rv = updateBookmarkStmt->BindInt64ByName(NS_LITERAL_CSTRING("date"),
-                                           lastModified);
+  rv = updateKeywordStmnt->BindInt64ByName(NS_LITERAL_CSTRING("date"), lastModified);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = updateBookmarkStmt->BindInt64ByName(NS_LITERAL_CSTRING("item_id"),
-                                           aBookmarkId);
+  rv = updateKeywordStmnt->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), aBookmarkId);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = updateBookmarkStmt->Execute();
+  rv = updateKeywordStmnt->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = transaction.Commit();
   NS_ENSURE_SUCCESS(rv, rv);
 
+  // Pass the new keyword to OnItemChanged.
   NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
                    nsINavBookmarkObserver,
                    OnItemChanged(aBookmarkId, NS_LITERAL_CSTRING("keyword"),
-                                 PR_FALSE, NS_ConvertUTF16toUTF8(keyword),
+                                 PR_FALSE, NS_ConvertUTF16toUTF8(aKeyword),
                                  lastModified, TYPE_BOOKMARK));
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsNavBookmarks::GetKeywordForURI(nsIURI* aURI, nsAString& aKeyword)
@@ -2878,90 +2867,61 @@ nsNavBookmarks::GetKeywordForURI(nsIURI*
 
 
 NS_IMETHODIMP
 nsNavBookmarks::GetKeywordForBookmark(PRInt64 aBookmarkId, nsAString& aKeyword)
 {
   NS_ENSURE_ARG_MIN(aBookmarkId, 1);
   aKeyword.Truncate(0);
 
-  nsresult rv = EnsureKeywordsHash();
+  DECLARE_AND_ASSIGN_SCOPED_LAZY_STMT(stmt, mDBGetKeywordForBookmark);
+  nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("item_id"),
+                                      aBookmarkId);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsAutoString keyword;
-  if (!mBookmarkToKeywordHash.Get(aBookmarkId, &keyword)) {
+  PRBool hasMore = PR_FALSE;
+  rv = stmt->ExecuteStep(&hasMore);
+  if (NS_FAILED(rv) || ! hasMore) {
     aKeyword.SetIsVoid(PR_TRUE);
+    return NS_OK; // not found: return void keyword string
   }
-  else {
-    aKeyword.Assign(keyword);
-  }
-
+
+  // found, get the keyword
+  rv = stmt->GetString(0, aKeyword);
+  NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsNavBookmarks::GetURIForKeyword(const nsAString& aKeyword, nsIURI** aURI)
 {
   NS_ENSURE_ARG_POINTER(aURI);
   NS_ENSURE_TRUE(!aKeyword.IsEmpty(), NS_ERROR_INVALID_ARG);
   *aURI = nsnull;
 
   // Shortcuts are always lowercased internally.
-  nsAutoString keyword(aKeyword);
-  ToLowerCase(keyword);
-
-  nsresult rv = EnsureKeywordsHash();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  keywordSearchData searchData;
-  searchData.keyword.Assign(aKeyword);
-  searchData.itemId = -1;
-  mBookmarkToKeywordHash.EnumerateRead(SearchBookmarkForKeyword, &searchData);
-
-  if (searchData.itemId == -1) {
-    // Not found.
-    return NS_OK;
-  }
-
-  rv = GetBookmarkURI(searchData.itemId, aURI);
+  nsAutoString kwd(aKeyword);
+  ToLowerCase(kwd);
+
+  DECLARE_AND_ASSIGN_SCOPED_LAZY_STMT(stmt, mDBGetURIForKeyword);
+  nsresult rv = stmt->BindStringByName(NS_LITERAL_CSTRING("keyword"), kwd);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return NS_OK;
-}
-
-
-nsresult
-nsNavBookmarks::EnsureKeywordsHash() {
-  if (mBookmarkToKeywordHash.IsInitialized())
-    return NS_OK;
-
-  mBookmarkToKeywordHash.Init(BOOKMARKS_TO_KEYWORDS_INITIAL_CACHE_SIZE);
-
-  nsCOMPtr<mozIStorageStatement> stmt;
-  nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
-    "SELECT b.id, k.keyword "
-    "FROM moz_bookmarks b "
-    "JOIN moz_keywords k ON k.id = b.keyword_id "
-  ), getter_AddRefs(stmt));
+  PRBool hasMore = PR_FALSE;
+  rv = stmt->ExecuteStep(&hasMore);
+  if (NS_FAILED(rv) || ! hasMore)
+    return NS_OK; // not found: leave URI null
+
+  // found, get the URI
+  nsCAutoString spec;
+  rv = stmt->GetUTF8String(0, spec);
   NS_ENSURE_SUCCESS(rv, rv);
-
-  PRBool hasMore;
-  while (NS_SUCCEEDED(stmt->ExecuteStep(&hasMore)) && hasMore) {
-    PRInt64 itemId;
-    rv = stmt->GetInt64(0, &itemId);
-    NS_ENSURE_SUCCESS(rv, rv);
-    nsAutoString keyword;
-    rv = stmt->GetString(1, keyword);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = mBookmarkToKeywordHash.Put(itemId, keyword);
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-
+  rv = NS_NewURI(aURI, spec);
+  NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
 
 // See RunInBatchMode
 nsresult
 nsNavBookmarks::BeginUpdateBatch()
 {
--- a/toolkit/components/places/src/nsNavBookmarks.h
+++ b/toolkit/components/places/src/nsNavBookmarks.h
@@ -376,17 +376,18 @@ private:
   nsCOMPtr<mozIStorageStatement> mDBIsBookmarkedInDatabase;
   nsCOMPtr<mozIStorageStatement> mDBIsURIBookmarkedInDatabase;
   nsCOMPtr<mozIStorageStatement> mDBIsRealBookmark;
   nsCOMPtr<mozIStorageStatement> mDBGetLastBookmarkID;
   nsCOMPtr<mozIStorageStatement> mDBSetItemDateAdded;
   nsCOMPtr<mozIStorageStatement> mDBSetItemLastModified;
   nsCOMPtr<mozIStorageStatement> mDBSetItemIndex;
   nsCOMPtr<mozIStorageStatement> mDBGetKeywordForURI;
-  nsCOMPtr<mozIStorageStatement> mDBGetBookmarksToKeywords;
+  nsCOMPtr<mozIStorageStatement> mDBGetKeywordForBookmark;
+  nsCOMPtr<mozIStorageStatement> mDBGetURIForKeyword;
   nsCOMPtr<mozIStorageStatement> mDBAdjustPosition;
   nsCOMPtr<mozIStorageStatement> mDBRemoveItem;
   nsCOMPtr<mozIStorageStatement> mDBGetLastChildId;
   nsCOMPtr<mozIStorageStatement> mDBMoveItem;
   nsCOMPtr<mozIStorageStatement> mDBSetItemTitle;
   nsCOMPtr<mozIStorageStatement> mDBChangeBookmarkURI;
   nsCOMPtr<mozIStorageStatement> mDBFindRedirectedBookmark;
 
@@ -443,31 +444,16 @@ private:
     PRInt32 mIndex;
   };
 
   // Used to enable and disable the observer notifications.
   bool mCanNotify;
   nsCategoryCache<nsINavBookmarkObserver> mCacheObservers;
 
   bool mShuttingDown;
-
-  /**
-   * Always call EnsureKeywordsHash() and check it for errors before actually
-   * using the hash.  Internal keyword methods are already doing that.
-   */
-  nsresult EnsureKeywordsHash();
-  nsDataHashtable<nsTrimInt64HashKey, nsString> mBookmarkToKeywordHash;
-
-  /**
-   * This function must be called every time a bookmark is removed.
-   *
-   * @param aURI
-   *        Uri to test.
-   */
-  nsresult UpdateKeywordsHashForRemovedBookmark(PRInt64 aItemId);
 };
 
 struct nsBookmarksUpdateBatcher
 {
   nsBookmarksUpdateBatcher()
   {
     nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
     if (bookmarks)
deleted file mode 100644
--- a/toolkit/components/places/tests/bookmarks/test_keywords.js
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Places Test Code.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Marco Bonardo <mak77@bonardo.net> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * 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 ***** */
-
-let bs = PlacesUtils.bookmarks;
-let db = DBConn();
-
-function check_keyword(aItemId, aExpectedBookmarkKeyword, aExpectedURIKeyword) {
-  if (aItemId) {
-    print("Check keyword for bookmark");
-    do_check_eq(bs.getKeywordForBookmark(aItemId), aExpectedBookmarkKeyword);
-
-    print("Check keyword for uri");
-    let uri = bs.getBookmarkURI(aItemId);
-    do_check_eq(bs.getKeywordForURI(uri), aExpectedURIKeyword);
-
-    print("Check uri for keyword");
-    // This API can't tell which uri the user wants, so it returns a random one.
-    if (aExpectedURIKeyword)
-      do_check_true(/http:\/\/test[0-9]\.mozilla\.org/.test(bs.getURIForKeyword(aExpectedURIKeyword).spec));
-  }
-  else {
-    stmt = db.createStatement(
-      "SELECT id FROM moz_keywords WHERE keyword = :keyword"
-    );
-    stmt.params.keyword = aExpectedBookmarkKeyword;
-    try {
-      do_check_false(stmt.executeStep());
-    } finally {
-      stmt.finalize();
-    }
-  }
-
-  print("Check there are no orphan database entries");
-  let stmt = db.createStatement(
-    "SELECT b.id FROM moz_bookmarks b "
-  + "LEFT JOIN moz_keywords k ON b.keyword_id = k.id "
-  + "WHERE keyword_id NOTNULL AND k.id ISNULL"
-  );
-  try {
-    do_check_false(stmt.executeStep());
-  } finally {
-    stmt.finalize();
-  }
-}
-
-function run_test() {
-  print("Check that leyword does not exist");
-  do_check_eq(bs.getURIForKeyword("keyword"), null);
-
-  let folderId = bs.createFolder(PlacesUtils.unfiledBookmarksFolderId,
-                                 "folder", bs.DEFAULT_INDEX);
-
-  print("Add a bookmark with a keyword");
-  let itemId1 = bs.insertBookmark(folderId,
-                                  uri("http://test1.mozilla.org/"),
-                                  bs.DEFAULT_INDEX,
-                                  "test1");
-  check_keyword(itemId1, null, null);
-  bs.setKeywordForBookmark(itemId1, "keyword");
-  check_keyword(itemId1, "keyword", "keyword");
-
-  print("Add another bookmark with the same uri, should not inherit keyword.");
-  let itemId1_bis = bs.insertBookmark(folderId,
-                                      uri("http://test1.mozilla.org/"),
-                                      bs.DEFAULT_INDEX,
-                                      "test1_bis");
-
-  check_keyword(itemId1_bis, null, "keyword");
-
-  print("Set same keyword on another bookmark with a different uri.");
-  let itemId2 = bs.insertBookmark(folderId,
-                                  uri("http://test2.mozilla.org/"),
-                                  bs.DEFAULT_INDEX,
-                                  "test2");
-  check_keyword(itemId2, null, null);
-  bs.setKeywordForBookmark(itemId2, "keyword");
-  check_keyword(itemId1, "keyword", "keyword");
-  check_keyword(itemId1_bis, null, "keyword");
-  check_keyword(itemId2, "keyword", "keyword");
-
-  print("Remove a bookmark with a keyword, it should not be removed from others");
-  bs.removeItem(itemId2);
-  check_keyword(itemId1, "keyword", "keyword");
-
-  print("Remove a folder containing bookmarks with keywords");
-  // Keyword should be removed as well.
-  bs.removeItem(folderId);
-  check_keyword(null, "keyword");
-}
-