Bug 555218 - 2: (History.cpp) Fix Places usage of deprecated Storage APIs. r=dietrich

This commit is contained in:
Marco Bonardo 2010-04-27 13:24:56 +02:00
Родитель a7bc315ba8
Коммит ac87ae779f
3 изменённых файлов: 10 добавлений и 8 удалений

Просмотреть файл

@ -39,11 +39,13 @@
#include "History.h" #include "History.h"
#include "nsNavHistory.h" #include "nsNavHistory.h"
#include "Helpers.h"
#include "mozilla/storage.h" #include "mozilla/storage.h"
#include "mozilla/dom/Link.h" #include "mozilla/dom/Link.h"
#include "nsDocShellCID.h" #include "nsDocShellCID.h"
#include "nsIEventStateManager.h" #include "nsIEventStateManager.h"
#include "mozilla/Services.h"
using namespace mozilla::dom; using namespace mozilla::dom;
@ -73,16 +75,14 @@ public:
nsNavHistory* navHist = nsNavHistory::GetHistoryService(); nsNavHistory* navHist = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navHist, NS_ERROR_FAILURE); NS_ENSURE_TRUE(navHist, NS_ERROR_FAILURE);
mozIStorageStatement* stmt = navHist->DBGetIsVisited(); mozIStorageStatement* stmt = navHist->GetStatementById(DB_IS_PAGE_VISITED);
NS_ENSURE_STATE(stmt); NS_ENSURE_STATE(stmt);
// Be sure to reset our statement! // Be sure to reset our statement!
mozStorageStatementScoper scoper(stmt); mozStorageStatementScoper scoper(stmt);
nsCString spec;
nsresult rv = aURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
rv = BindStatementURLCString(stmt, 0, spec); // Bind by index for performance.
nsresult rv = URIBinder::Bind(stmt, 0, aURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<VisitedQuery> callback = new VisitedQuery(aURI); nsRefPtr<VisitedQuery> callback = new VisitedQuery(aURI);
@ -116,7 +116,7 @@ public:
// Notify any observers about that we have resolved the visited state of // Notify any observers about that we have resolved the visited state of
// this URI. // this URI.
nsCOMPtr<nsIObserverService> observerService = nsCOMPtr<nsIObserverService> observerService =
do_GetService(NS_OBSERVERSERVICE_CONTRACTID); mozilla::services::GetObserverService();
if (observerService) { if (observerService) {
nsAutoString status; nsAutoString status;
if (mIsVisited) { if (mIsVisited) {

Просмотреть файл

@ -1148,6 +1148,7 @@ nsNavHistory::InitStatements()
// We are not checking for duplicated ids into the unified table // We are not checking for duplicated ids into the unified table
// for perf reasons, LIMIT 1 will discard duplicates faster since we // for perf reasons, LIMIT 1 will discard duplicates faster since we
// only need to know if a visit exists. // only need to know if a visit exists.
// Use indexed params here for performance.
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING( rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
"SELECT h.id " "SELECT h.id "
"FROM moz_places_temp h " "FROM moz_places_temp h "

Просмотреть файл

@ -107,6 +107,7 @@ namespace places {
enum HistoryStatementId { enum HistoryStatementId {
DB_GET_PAGE_INFO = 0 DB_GET_PAGE_INFO = 0
, DB_GET_TAGS = 1 , DB_GET_TAGS = 1
, DB_IS_PAGE_VISITED = 2
}; };
} // namespace places } // namespace places
@ -261,8 +262,6 @@ public:
PRInt64 GetTagsFolder(); PRInt64 GetTagsFolder();
mozIStorageStatement *DBGetIsVisited() { return mDBIsPageVisited; }
// Constants for the columns returned by the above statement // Constants for the columns returned by the above statement
// (in addition to the ones above). // (in addition to the ones above).
static const PRInt32 kGetInfoIndex_VisitDate; static const PRInt32 kGetInfoIndex_VisitDate;
@ -404,6 +403,8 @@ public:
return mDBGetURLPageInfo; return mDBGetURLPageInfo;
case DB_GET_TAGS: case DB_GET_TAGS:
return mDBGetTags; return mDBGetTags;
case DB_IS_PAGE_VISITED:
return mDBIsPageVisited;
} }
return nsnull; return nsnull;
} }