Bug 1476103 - Remove nsNavHistory::invalidateFrecencies since it's now unused. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D2170

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Drew Willcoxon 2018-07-17 07:59:45 +00:00
Родитель 104efdacd0
Коммит df91e88f35
3 изменённых файлов: 5 добавлений и 91 удалений

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

@ -928,82 +928,6 @@ nsNavHistory::hasHistoryEntries()
}
namespace {
class InvalidateAllFrecenciesCallback : public AsyncStatementCallback
{
public:
InvalidateAllFrecenciesCallback()
{
}
NS_IMETHOD HandleCompletion(uint16_t aReason) override
{
if (aReason == REASON_FINISHED) {
nsNavHistory *navHistory = nsNavHistory::GetHistoryService();
NS_ENSURE_STATE(navHistory);
navHistory->NotifyManyFrecenciesChanged();
}
return NS_OK;
}
};
} // namespace
nsresult
nsNavHistory::invalidateFrecencies(const nsCString& aPlaceIdsQueryString)
{
// Exclude place: queries by setting their frecency to zero.
nsCString invalidFrecenciesSQLFragment(
"UPDATE moz_places SET frecency = "
);
if (!aPlaceIdsQueryString.IsEmpty())
invalidFrecenciesSQLFragment.AppendLiteral("NOTIFY_FRECENCY(");
invalidFrecenciesSQLFragment.AppendLiteral(
"(CASE "
"WHEN url_hash BETWEEN hash('place', 'prefix_lo') AND "
"hash('place', 'prefix_hi') "
"THEN 0 "
"ELSE -1 "
"END) "
);
if (!aPlaceIdsQueryString.IsEmpty()) {
invalidFrecenciesSQLFragment.AppendLiteral(
", url, guid, hidden, last_visit_date) "
);
}
invalidFrecenciesSQLFragment.AppendLiteral(
"WHERE frecency > 0 "
);
if (!aPlaceIdsQueryString.IsEmpty()) {
invalidFrecenciesSQLFragment.AppendLiteral("AND id IN(");
invalidFrecenciesSQLFragment.Append(aPlaceIdsQueryString);
invalidFrecenciesSQLFragment.Append(')');
}
RefPtr<InvalidateAllFrecenciesCallback> cb =
aPlaceIdsQueryString.IsEmpty() ? new InvalidateAllFrecenciesCallback()
: nullptr;
nsCOMPtr<mozIStorageAsyncStatement> stmt = mDB->GetAsyncStatement(
invalidFrecenciesSQLFragment
);
NS_ENSURE_STATE(stmt);
nsCOMPtr<mozIStoragePendingStatement> ps;
nsresult rv = stmt->ExecuteAsync(cb, getter_AddRefs(ps));
NS_ENSURE_SUCCESS(rv, rv);
// Trigger frecency updates for affected origins.
nsCOMPtr<mozIStorageAsyncStatement> updateOriginFrecenciesStmt =
mDB->GetAsyncStatement("DELETE FROM moz_updateoriginsupdate_temp");
NS_ENSURE_STATE(updateOriginFrecenciesStmt);
rv = updateOriginFrecenciesStmt->ExecuteAsync(nullptr, getter_AddRefs(ps));
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
// Call this method before visiting a URL in order to help determine the
// transition type of the visit.
//

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

@ -172,16 +172,6 @@ public:
*/
nsresult UpdateFrecency(int64_t aPlaceId);
/**
* Invalidate the frecencies of a list of places, so they will be recalculated
* at the first idle-daily notification.
*
* @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);
/**
* These functions return non-owning references to the locale-specific
* objects for places components.

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

@ -28,9 +28,9 @@ add_task(async function test_nsNavHistory_UpdateFrecency() {
await promise;
});
// nsNavHistory::invalidateFrecencies for particular pages
add_task(async function test_nsNavHistory_invalidateFrecencies_somePages() {
let url = Services.io.newURI("http://test-nsNavHistory-invalidateFrecencies-somePages.com/");
// History.jsm invalidateFrecencies()
add_task(async function test_invalidateFrecencies() {
let url = Services.io.newURI("http://test-invalidateFrecencies.com/");
// Bookmarking the URI is enough to add it to moz_places, and importantly, it
// means that removeByFilter doesn't remove it from moz_places, so its
// frecency is able to be changed.
@ -44,8 +44,8 @@ add_task(async function test_nsNavHistory_invalidateFrecencies_somePages() {
await promise;
});
// nsNavHistory::invalidateFrecencies for all pages
add_task(async function test_nsNavHistory_invalidateFrecencies_allPages() {
// History.jsm clear()
add_task(async function test_clear() {
await Promise.all([onManyFrecenciesChanged(), PlacesUtils.history.clear()]);
});