author | Mark Banner <standard8@mozilla.com> |
Wed, 11 Jul 2018 18:10:22 +0000 | |
changeset 425817 | 4e729ca38f8c420ed39eec6294e3fcd4b6316526 |
parent 425816 | 43dc237c33f34532c76b9736860d7cd4c1c66ca2 |
child 425818 | 03a018872c480ac6a43675a88c58439fdaf808e6 |
child 426264 | 3aca103e49150145dbff910be15e7886b7c4495a |
push id | 66235 |
push user | mbanner@mozilla.com |
push date | Wed, 11 Jul 2018 18:11:59 +0000 |
treeherder | autoland@4e729ca38f8c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mak |
bugs | 1474638 |
milestone | 63.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
|
--- a/docshell/base/nsIDownloadHistory.idl +++ b/docshell/base/nsIDownloadHistory.idl @@ -39,20 +39,9 @@ interface nsIDownloadHistory : nsISuppor * the actual addition to the underlying history implementation. If you * need to observe the completion of the addition, use the underlying * history implementation's notifications system (e.g. nsINavHistoryObserver * for toolkit's implementation of this interface). */ void addDownload(in nsIURI aSource, [optional] in nsIURI aReferrer, [optional] in PRTime aStartTime, [optional] in nsIURI aDestination); - - /** - * Remove all downloads from history. - * - * @note This removal is not guaranteed to be synchronous, since it delegates - * the actual removal to the underlying history implementation. If you - * need to observe the completion of the removal, use the underlying - * history implementation's notifications system (e.g. nsINavHistoryObserver - * for toolkit's implementation of this interface). - */ - void removeAllDownloads(); };
--- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -1,15 +1,14 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/ArrayUtils.h" #include "mozilla/Attributes.h" #include "mozilla/DebugOnly.h" #include "mozilla/MemoryReporting.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentParent.h" #include "nsXULAppAPI.h" @@ -41,19 +40,16 @@ #include "mozilla/dom/PlacesObservers.h" #include "mozilla/dom/PlacesVisit.h" #include "mozilla/dom/ProcessGlobal.h" #include "mozilla/dom/ScriptSettings.h" // Initial size for the cache holding visited status observers. #define VISIT_OBSERVERS_INITIAL_CACHE_LENGTH 64 -// Initial length for the visits removal hash. -#define VISITS_REMOVAL_INITIAL_HASH_LENGTH 64 - using namespace mozilla::dom; using namespace mozilla::ipc; using mozilla::Unused; namespace mozilla { namespace places { //////////////////////////////////////////////////////////////////////////////// @@ -169,101 +165,16 @@ struct VisitData { bool shouldUpdateFrecency; // Whether to override the visit type bonus with a redirect bonus when // calculating frecency on the most recent visit. bool useFrecencyRedirectBonus; }; //////////////////////////////////////////////////////////////////////////////// -//// RemoveVisitsFilter - -/** - * Used to store visit filters for RemoveVisits. - */ -struct RemoveVisitsFilter { - RemoveVisitsFilter() - : transitionType(UINT32_MAX) - { - } - - uint32_t transitionType; -}; - -//////////////////////////////////////////////////////////////////////////////// -//// PlaceHashKey - -class PlaceHashKey : public nsCStringHashKey -{ -public: - explicit PlaceHashKey(const nsACString& aSpec) - : nsCStringHashKey(&aSpec) - , mVisitCount(0) - , mBookmarked(false) -#ifdef DEBUG - , mIsInitialized(false) -#endif - { - } - - explicit PlaceHashKey(const nsACString* aSpec) - : nsCStringHashKey(aSpec) - , mVisitCount(0) - , mBookmarked(false) -#ifdef DEBUG - , mIsInitialized(false) -#endif - { - } - - PlaceHashKey(const PlaceHashKey& aOther) - : nsCStringHashKey(&aOther.GetKey()) - { - MOZ_ASSERT(false, "Do not call me!"); - } - - void SetProperties(uint32_t aVisitCount, bool aBookmarked) - { - mVisitCount = aVisitCount; - mBookmarked = aBookmarked; -#ifdef DEBUG - mIsInitialized = true; -#endif - } - - uint32_t VisitCount() const - { -#ifdef DEBUG - MOZ_ASSERT(mIsInitialized, "PlaceHashKey::mVisitCount not set"); -#endif - return mVisitCount; - } - - bool IsBookmarked() const - { -#ifdef DEBUG - MOZ_ASSERT(mIsInitialized, "PlaceHashKey::mBookmarked not set"); -#endif - return mBookmarked; - } - - // Array of VisitData objects. - nsTArray<VisitData> mVisits; -private: - // Visit count for this place. - uint32_t mVisitCount; - // Whether this place is bookmarked. - bool mBookmarked; -#ifdef DEBUG - // Whether previous attributes are set. - bool mIsInitialized; -#endif -}; - -//////////////////////////////////////////////////////////////////////////////// //// Anonymous Helpers namespace { /** * Convert the given js value to a js array. * * @param [in] aValue @@ -1659,347 +1570,16 @@ private: RefPtr<History> mHistory; }; NS_IMPL_ISUPPORTS( SetDownloadAnnotations, mozIVisitInfoCallback ) /** - * Notify removed visits to observers. - */ -class NotifyRemoveVisits : public Runnable -{ -public: - explicit NotifyRemoveVisits(nsTHashtable<PlaceHashKey>& aPlaces) - : Runnable("places::NotifyRemoveVisits") - , mPlaces(VISITS_REMOVAL_INITIAL_HASH_LENGTH) - , mHistory(History::GetService()) - { - MOZ_ASSERT(!NS_IsMainThread(), - "This should not be called on the main thread"); - for (auto iter = aPlaces.Iter(); !iter.Done(); iter.Next()) { - PlaceHashKey* entry = iter.Get(); - PlaceHashKey* copy = mPlaces.PutEntry(entry->GetKey()); - copy->SetProperties(entry->VisitCount(), entry->IsBookmarked()); - entry->mVisits.SwapElements(copy->mVisits); - } - } - - NS_IMETHOD Run() override - { - MOZ_ASSERT(NS_IsMainThread(), "This should be called on the main thread"); - - // We are in the main thread, no need to lock. - if (mHistory->IsShuttingDown()) { - // If we are shutting down, we cannot notify the observers. - return NS_OK; - } - - nsNavHistory* navHistory = nsNavHistory::GetHistoryService(); - if (!navHistory) { - NS_WARNING("Cannot notify without the history service!"); - return NS_OK; - } - - // Wrap all notifications in a batch, so the view can handle changes in a - // more performant way, by initiating a refresh after a limited number of - // single changes. - (void)navHistory->BeginUpdateBatch(); - for (auto iter = mPlaces.Iter(); !iter.Done(); iter.Next()) { - PlaceHashKey* entry = iter.Get(); - const nsTArray<VisitData>& visits = entry->mVisits; - nsCOMPtr<nsIURI> uri; - MOZ_ALWAYS_SUCCEEDS(NS_NewURI(getter_AddRefs(uri), visits[0].spec)); - // Notify an expiration only if we have a valid uri, otherwise - // the observer couldn't gather any useful data from the notification. - // This should be false only if there's a bug in the code preceding us. - if (uri) { - bool removingPage = visits.Length() == entry->VisitCount() && - !entry->IsBookmarked(); - - // FindRemovableVisits only sets the transition type on the VisitData - // objects it collects if the visits were filtered by transition type. - // RemoveVisitsFilter currently only supports filtering by transition - // type, so FindRemovableVisits will either find all visits, or all - // visits of a given type. Therefore, if transitionType is set on this - // visit, we pass the transition type to NotifyOnPageExpired which in - // turns passes it to OnDeleteVisits to indicate that all visits of a - // given type were removed. - uint32_t transition = visits[0].transitionType < UINT32_MAX - ? visits[0].transitionType - : 0; - navHistory->NotifyOnPageExpired(uri, visits[0].visitTime, removingPage, - visits[0].guid, - nsINavHistoryObserver::REASON_DELETED, - transition); - } - } - (void)navHistory->EndUpdateBatch(); - - return NS_OK; - } - -private: - nsTHashtable<PlaceHashKey> mPlaces; - - /** - * Strong reference to the History object because we do not want it to - * disappear out from under us. - */ - RefPtr<History> mHistory; -}; - -/** - * Remove visits from history. - */ -class RemoveVisits : public Runnable -{ -public: - /** - * Asynchronously removes visits from history. - * - * @param aConnection - * The database connection to use for these operations. - * @param aFilter - * Filter to remove visits. - */ - static nsresult Start(mozIStorageConnection* aConnection, - RemoveVisitsFilter& aFilter) - { - MOZ_ASSERT(NS_IsMainThread(), "This should be called on the main thread"); - - RefPtr<RemoveVisits> event = new RemoveVisits(aConnection, aFilter); - - // Get the target thread, and then start the work! - nsCOMPtr<nsIEventTarget> target = do_GetInterface(aConnection); - NS_ENSURE_TRUE(target, NS_ERROR_UNEXPECTED); - nsresult rv = target->Dispatch(event, NS_DISPATCH_NORMAL); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; - } - - NS_IMETHOD Run() override - { - MOZ_ASSERT(!NS_IsMainThread(), - "This should not be called on the main thread"); - - // Prevent the main thread from shutting down while this is running. - MutexAutoLock lockedScope(mHistory->GetShutdownMutex()); - if (mHistory->IsShuttingDown()) { - // If we were already shutting down, we cannot remove the visits. - return NS_OK; - } - - // Find all the visits relative to the current filters and whether their - // pages will be removed or not. - nsTHashtable<PlaceHashKey> places(VISITS_REMOVAL_INITIAL_HASH_LENGTH); - nsresult rv = FindRemovableVisits(places); - NS_ENSURE_SUCCESS(rv, rv); - - if (places.Count() == 0) - return NS_OK; - - mozStorageTransaction transaction(mDBConn, false, - mozIStorageConnection::TRANSACTION_IMMEDIATE); - - rv = RemoveVisitsFromDatabase(); - NS_ENSURE_SUCCESS(rv, rv); - rv = RemovePagesFromDatabase(places); - NS_ENSURE_SUCCESS(rv, rv); - - rv = transaction.Commit(); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsIRunnable> event = new NotifyRemoveVisits(places); - rv = NS_DispatchToMainThread(event); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; - } - -private: - RemoveVisits(mozIStorageConnection* aConnection, RemoveVisitsFilter& aFilter) - : Runnable("places::RemoveVisits") - , mDBConn(aConnection) - , mHasTransitionType(false) - , mHistory(History::GetService()) - { - MOZ_ASSERT(NS_IsMainThread(), "This should be called on the main thread"); - - // Build query conditions. - nsTArray<nsCString> conditions; - // TODO: add support for binding params when adding further stuff here. - if (aFilter.transitionType < UINT32_MAX) { - conditions.AppendElement(nsPrintfCString("visit_type = %d", aFilter.transitionType)); - mHasTransitionType = true; - } - if (conditions.Length() > 0) { - mWhereClause.AppendLiteral (" WHERE "); - for (uint32_t i = 0; i < conditions.Length(); ++i) { - if (i > 0) - mWhereClause.AppendLiteral(" AND "); - mWhereClause.Append(conditions[i]); - } - } - } - - /** - * Find the list of entries that may be removed from `moz_places`. - * - * Calling this method makes sense only if we are not clearing the entire history. - */ - nsresult - FindRemovableVisits(nsTHashtable<PlaceHashKey>& aPlaces) - { - MOZ_ASSERT(!NS_IsMainThread(), - "This should not be called on the main thread"); - - nsCString query("SELECT h.id, url, guid, visit_date, visit_type, " - "(SELECT count(*) FROM moz_historyvisits WHERE place_id = h.id) as full_visit_count, " - "EXISTS(SELECT 1 FROM moz_bookmarks WHERE fk = h.id) as bookmarked " - "FROM moz_historyvisits " - "JOIN moz_places h ON place_id = h.id"); - query.Append(mWhereClause); - - nsCOMPtr<mozIStorageStatement> stmt = mHistory->GetStatement(query); - NS_ENSURE_STATE(stmt); - mozStorageStatementScoper scoper(stmt); - - bool hasResult; - nsresult rv; - while (NS_SUCCEEDED((rv = stmt->ExecuteStep(&hasResult))) && hasResult) { - VisitData visit; - rv = stmt->GetInt64(0, &visit.placeId); - NS_ENSURE_SUCCESS(rv, rv); - rv = stmt->GetUTF8String(1, visit.spec); - NS_ENSURE_SUCCESS(rv, rv); - rv = stmt->GetUTF8String(2, visit.guid); - NS_ENSURE_SUCCESS(rv, rv); - rv = stmt->GetInt64(3, &visit.visitTime); - NS_ENSURE_SUCCESS(rv, rv); - if (mHasTransitionType) { - int32_t transition; - rv = stmt->GetInt32(4, &transition); - NS_ENSURE_SUCCESS(rv, rv); - visit.transitionType = static_cast<uint32_t>(transition); - } - int32_t visitCount, bookmarked; - rv = stmt->GetInt32(5, &visitCount); - NS_ENSURE_SUCCESS(rv, rv); - rv = stmt->GetInt32(6, &bookmarked); - NS_ENSURE_SUCCESS(rv, rv); - - PlaceHashKey* entry = aPlaces.GetEntry(visit.spec); - if (!entry) { - entry = aPlaces.PutEntry(visit.spec); - } - entry->SetProperties(static_cast<uint32_t>(visitCount), static_cast<bool>(bookmarked)); - entry->mVisits.AppendElement(visit); - } - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; - } - - nsresult - RemoveVisitsFromDatabase() - { - MOZ_ASSERT(!NS_IsMainThread(), - "This should not be called on the main thread"); - - nsCString query("DELETE FROM moz_historyvisits"); - query.Append(mWhereClause); - - nsCOMPtr<mozIStorageStatement> stmt = mHistory->GetStatement(query); - NS_ENSURE_STATE(stmt); - mozStorageStatementScoper scoper(stmt); - nsresult rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; - } - - nsresult - RemovePagesFromDatabase(nsTHashtable<PlaceHashKey>& aPlaces) - { - MOZ_ASSERT(!NS_IsMainThread(), - "This should not be called on the main thread"); - - nsCString placeIdsToRemove; - for (auto iter = aPlaces.Iter(); !iter.Done(); iter.Next()) { - PlaceHashKey* entry = iter.Get(); - const nsTArray<VisitData>& visits = entry->mVisits; - // Only orphan ids should be listed. - if (visits.Length() == entry->VisitCount() && !entry->IsBookmarked()) { - if (!placeIdsToRemove.IsEmpty()) - placeIdsToRemove.Append(','); - placeIdsToRemove.AppendInt(visits[0].placeId); - } - } - -#ifdef DEBUG - { - // Ensure that we are not removing any problematic entry. - nsCString query("SELECT id FROM moz_places h WHERE id IN ("); - query.Append(placeIdsToRemove); - query.AppendLiteral(") AND (" - "EXISTS(SELECT 1 FROM moz_bookmarks WHERE fk = h.id) OR " - "EXISTS(SELECT 1 FROM moz_historyvisits WHERE place_id = h.id) OR " - "SUBSTR(h.url, 1, 6) = 'place:' " - ")"); - nsCOMPtr<mozIStorageStatement> stmt = mHistory->GetStatement(query); - NS_ENSURE_STATE(stmt); - mozStorageStatementScoper scoper(stmt); - bool hasResult; - MOZ_ASSERT(NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)) && !hasResult, - "Trying to remove a non-oprhan place from the database"); - } -#endif - - { - nsCString query("DELETE FROM moz_places " - "WHERE id IN ("); - query.Append(placeIdsToRemove); - query.Append(')'); - - nsCOMPtr<mozIStorageStatement> stmt = mHistory->GetStatement(query); - NS_ENSURE_STATE(stmt); - mozStorageStatementScoper scoper(stmt); - nsresult rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, rv); - } - - { - // Hosts accumulated during the places delete are updated through a trigger - // (see nsPlacesTriggers.h). - nsAutoCString query("DELETE FROM moz_updateoriginsdelete_temp"); - nsCOMPtr<mozIStorageStatement> stmt = mHistory->GetStatement(query); - NS_ENSURE_STATE(stmt); - mozStorageStatementScoper scoper(stmt); - nsresult rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, rv); - } - - return NS_OK; - } - - mozIStorageConnection* mDBConn; - bool mHasTransitionType; - nsCString mWhereClause; - - /** - * Strong reference to the History object because we do not want it to - * disappear out from under us. - */ - RefPtr<History> mHistory; -}; - -/** * Stores an embed visit, and notifies observers. * * @param aPlace * The VisitData of the visit to store as an embed visit. * @param [optional] aCallback * The mozIVisitInfoCallback to notify, if provided. */ void @@ -2989,45 +2569,16 @@ History::AddDownload(nsIURI* aSource, ns } rv = InsertVisitedURIs::Start(dbConn, placeArray, callback); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } -NS_IMETHODIMP -History::RemoveAllDownloads() -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (mShuttingDown) { - return NS_OK; - } - - if (XRE_IsContentProcess()) { - NS_ERROR("Cannot remove downloads to history from content process!"); - return NS_ERROR_NOT_AVAILABLE; - } - - // Ensure navHistory is initialized. - nsNavHistory* navHistory = nsNavHistory::GetHistoryService(); - NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY); - mozIStorageConnection* dbConn = GetDBConn(); - NS_ENSURE_STATE(dbConn); - - RemoveVisitsFilter filter; - filter.transitionType = nsINavHistoryService::TRANSITION_DOWNLOAD; - - nsresult rv = RemoveVisits::Start(dbConn, filter); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; -} - //////////////////////////////////////////////////////////////////////////////// //// mozIAsyncHistory NS_IMETHODIMP History::UpdatePlaces(JS::Handle<JS::Value> aPlaceInfos, mozIVisitInfoCallback* aCallback, bool aGroupNotifications, JSContext* aCtx)
--- a/toolkit/components/places/History.h +++ b/toolkit/components/places/History.h @@ -15,17 +15,16 @@ #include "Database.h" #include "mozilla/dom/Link.h" #include "mozilla/ipc/URIParams.h" #include "nsTHashtable.h" #include "nsString.h" #include "nsURIHashKey.h" #include "nsTObserverArray.h" -#include "nsDeque.h" #include "nsIMemoryReporter.h" #include "nsIObserver.h" #include "mozIStorageConnection.h" namespace mozilla { namespace places { struct VisitData;
--- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -215,35 +215,16 @@ void GetTagsSqlFragment(int64_t aTagsFol nsPrintfCString("%" PRId64, aTagsFolder) + NS_LITERAL_CSTRING(" " ")")); } _sqlFragment.AppendLiteral(" AS tags "); } /** - * This class sets begin/end of batch updates to correspond to C++ scopes so - * we can be sure end always gets called. - */ -class UpdateBatchScoper -{ -public: - explicit UpdateBatchScoper(nsNavHistory& aNavHistory) : mNavHistory(aNavHistory) - { - mNavHistory.BeginUpdateBatch(); - } - ~UpdateBatchScoper() - { - mNavHistory.EndUpdateBatch(); - } -protected: - nsNavHistory& mNavHistory; -}; - -/** * Recalculates invalid frecencies in chunks on the storage thread, optionally * decays frecencies, and notifies history observers on the main thread. */ class FixAndDecayFrecencyRunnable final : public Runnable { public: explicit FixAndDecayFrecencyRunnable(Database* aDB, float aDecayRate) : Runnable("places::FixAndDecayFrecencyRunnable") @@ -401,19 +382,17 @@ const int32_t nsNavHistory::kGetInfoInde // nsNavBookmarks::kGetChildrenIndex_Position = 19; // nsNavBookmarks::kGetChildrenIndex_Type = 20; // nsNavBookmarks::kGetChildrenIndex_PlaceID = 21; PLACES_FACTORY_SINGLETON_IMPLEMENTATION(nsNavHistory, gHistoryService) nsNavHistory::nsNavHistory() - : mBatchLevel(0) - , mBatchDBTransaction(nullptr) - , mCachedNow(0) + : mCachedNow(0) , mRecentTyped(RECENT_EVENTS_INITIAL_CACHE_LENGTH) , mRecentLink(RECENT_EVENTS_INITIAL_CACHE_LENGTH) , mRecentBookmark(RECENT_EVENTS_INITIAL_CACHE_LENGTH) , mEmbedVisits(EMBED_VISITS_INITIAL_CACHE_LENGTH) , mHistoryEnabled(true) , mNumVisitsForFrecency(10) , mDecayFrecencyPendingCount(0) , mTagsFolder(-1) @@ -1198,18 +1177,17 @@ nsNavHistory::ExecuteQuery(nsINavHistory nsresult rv = QueryToQueryString(query, options, queryUri); NS_ENSURE_SUCCESS(rv, rv); rootNode = new nsNavHistoryQueryResultNode(EmptyCString(), 0, queryUri, query, options); } // Create the result that will hold nodes. Inject batching status into it. RefPtr<nsNavHistoryResult> result = new nsNavHistoryResult(rootNode, - query, options, - isBatching()); + query, options); result.forget(_retval); return NS_OK; } // determine from our nsNavHistoryQuery array and nsNavHistoryQueryOptions // if this is the place query from the history menu. // from browser-menubar.inc, our history menu query is: // place:sort=4&maxResults=10 @@ -2290,48 +2268,16 @@ nsNavHistory::GetObservers(uint32_t* _co return NS_OK; *_count = observers.Count(); observers.Forget(_observers); return NS_OK; } -// See RunInBatchMode -nsresult -nsNavHistory::BeginUpdateBatch() -{ - if (mBatchLevel++ == 0) { - mBatchDBTransaction = new mozStorageTransaction(mDB->MainConn(), false, - mozIStorageConnection::TRANSACTION_DEFAULT, - true); - - NOTIFY_OBSERVERS(mCanNotify, mObservers, nsINavHistoryObserver, OnBeginUpdateBatch()); - } - return NS_OK; -} - -// nsNavHistory::EndUpdateBatch -nsresult -nsNavHistory::EndUpdateBatch() -{ - if (--mBatchLevel == 0) { - if (mBatchDBTransaction) { - DebugOnly<nsresult> rv = mBatchDBTransaction->Commit(); - NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), - "Batch failed to commit transaction"); - delete mBatchDBTransaction; - mBatchDBTransaction = nullptr; - } - - NOTIFY_OBSERVERS(mCanNotify, mObservers, nsINavHistoryObserver, OnEndUpdateBatch()); - } - return NS_OK; -} - NS_IMETHODIMP nsNavHistory::GetHistoryDisabled(bool *_retval) { NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread"); NS_ENSURE_ARG_POINTER(_retval); *_retval = IsHistoryDisabled(); return NS_OK; @@ -2519,41 +2465,16 @@ nsNavHistory::AsyncExecuteLegacyQuery(ns } rv = statement->ExecuteAsync(aCallback, _stmt); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } - -nsresult -nsNavHistory::NotifyOnPageExpired(nsIURI *aURI, PRTime aVisitTime, - bool aWholeEntry, const nsACString& aGUID, - uint16_t aReason, uint32_t aTransitionType) -{ - // Invalidate the cached value for whether there's history or not. - mDaysOfHistory = -1; - - MOZ_ASSERT(!aGUID.IsEmpty()); - if (aWholeEntry) { - // Notify our observers that the page has been removed. - NOTIFY_OBSERVERS(mCanNotify, mObservers, nsINavHistoryObserver, - OnDeleteURI(aURI, aGUID, aReason)); - } - else { - // Notify our observers that some visits for the page have been removed. - NOTIFY_OBSERVERS(mCanNotify, mObservers, nsINavHistoryObserver, - OnDeleteVisits(aURI, aVisitTime, aGUID, aReason, - aTransitionType)); - } - - return NS_OK; -} - //////////////////////////////////////////////////////////////////////////////// //// nsIObserver NS_IMETHODIMP nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) { NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
--- a/toolkit/components/places/nsNavHistory.h +++ b/toolkit/components/places/nsNavHistory.h @@ -178,39 +178,16 @@ public: * * @param aPlacesIdsQueryString * Query string containing list of places to be invalidated. If it's * an empty string all places will be invalidated. */ nsresult invalidateFrecencies(const nsCString& aPlaceIdsQueryString); /** - * Calls onDeleteVisits and onDeleteURI notifications on registered listeners - * with the history service. - * - * @param aURI - * The nsIURI object representing the URI of the page being expired. - * @param aVisitTime - * The time, in microseconds, that the page being expired was visited. - * @param aWholeEntry - * Indicates if this is the last visit for this URI. - * @param aGUID - * The unique ID associated with the page. - * @param aReason - * Indicates the reason for the removal. - * See nsINavHistoryObserver::REASON_* constants. - * @param aTransitionType - * If it's a valid TRANSITION_* value, all visits of the specified type - * have been removed. - */ - nsresult NotifyOnPageExpired(nsIURI *aURI, PRTime aVisitTime, - bool aWholeEntry, const nsACString& aGUID, - uint16_t aReason, uint32_t aTransitionType); - - /** * These functions return non-owning references to the locale-specific * objects for places components. */ nsIStringBundle* GetBundle(); nsICollation* GetCollation(); void GetStringFromName(const char* aName, nsACString& aResult); void GetAgeInDaysString(int32_t aInt, const char* aName, nsACString& aResult); static void GetMonthName(const PRExplodedTime& aTime, nsACString& aResult); @@ -284,26 +261,16 @@ public: * Returns current number of days stored in history. */ int32_t GetDaysOfHistory(); void DomainNameFromURI(nsIURI* aURI, nsACString& aDomainName); static PRTime NormalizeTime(uint32_t aRelative, PRTime aOffset); - // Don't use these directly, inside nsNavHistory use UpdateBatchScoper, - // else use nsINavHistoryService::RunInBatchMode - nsresult BeginUpdateBatch(); - nsresult EndUpdateBatch(); - - // The level of batches' nesting, 0 when no batches are open. - int32_t mBatchLevel; - // Current active transaction for a batch. - mozStorageTransaction* mBatchDBTransaction; - typedef nsDataHashtable<nsCStringHashKey, nsCString> StringHash; /** * Indicates if it is OK to notify history observers or not. * * @return true if it is OK to notify, false otherwise. */ bool canNotify() { return mCanNotify; } @@ -466,20 +433,16 @@ public: * Store last insterted id for a table. */ static mozilla::Atomic<int64_t> sLastInsertedPlaceId; static mozilla::Atomic<int64_t> sLastInsertedVisitId; static void StoreLastInsertedId(const nsACString& aTable, const int64_t aLastInsertedId); - bool isBatching() { - return mBatchLevel > 0; - } - #ifdef XP_WIN /** * Get the cached HCRYPTPROV initialized in the nsNavHistory constructor. */ nsresult GetCryptoProvider(HCRYPTPROV& aCryptoProvider) const { NS_ENSURE_STATE(mCryptoProviderInitialized); aCryptoProvider = mCryptoProvider; return NS_OK;
--- a/toolkit/components/places/nsNavHistoryResult.cpp +++ b/toolkit/components/places/nsNavHistoryResult.cpp @@ -3941,28 +3941,27 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION( NS_INTERFACE_MAP_ENTRY(nsINavHistoryResult) NS_INTERFACE_MAP_ENTRY(nsINavBookmarkObserver) NS_INTERFACE_MAP_ENTRY(nsINavHistoryObserver) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_END nsNavHistoryResult::nsNavHistoryResult(nsNavHistoryContainerResultNode* aRoot, const RefPtr<nsNavHistoryQuery>& aQuery, - const RefPtr<nsNavHistoryQueryOptions>& aOptions, - bool aBatchInProgress + const RefPtr<nsNavHistoryQueryOptions>& aOptions ) : mRootNode(aRoot) , mQuery(aQuery) , mOptions(aOptions) , mNeedsToApplySortingMode(false) , mIsHistoryObserver(false) , mIsBookmarkFolderObserver(false) , mIsAllBookmarksObserver(false) , mIsMobilePrefObserver(false) , mBookmarkFolderObservers(64) - , mBatchInProgress(aBatchInProgress) + , mBatchInProgress(false) , mSuppressNotifications(false) { mSortingMode = aOptions->SortingMode(); mRootNode->mResult = this; MOZ_ASSERT(mRootNode->mIndentLevel == -1, "Root node's indent level initialized wrong"); mRootNode->FillStats();
--- a/toolkit/components/places/nsNavHistoryResult.h +++ b/toolkit/components/places/nsNavHistoryResult.h @@ -123,18 +123,17 @@ public: nsresult OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime, uint32_t aTransitionType, const nsACString& aGUID, bool aHidden, uint32_t aVisitCount, const nsAString& aLastKnownTitle); public: explicit nsNavHistoryResult(nsNavHistoryContainerResultNode* mRoot, const RefPtr<nsNavHistoryQuery>& aQuery, - const RefPtr<nsNavHistoryQueryOptions>& aOptions, - bool aBatchInProgress); + const RefPtr<nsNavHistoryQueryOptions>& aOptions); RefPtr<nsNavHistoryContainerResultNode> mRootNode; RefPtr<nsNavHistoryQuery> mQuery; RefPtr<nsNavHistoryQueryOptions> mOptions; // One of nsNavHistoryQueryOptions.SORY_BY_* This is initialized to mOptions.sortingMode, // but may be overridden if the user clicks on one of the columns.