Bug 911307 - Reflect changes to top sites immediately in about:newtab (part 1, Places patch). r=mak
This commit is contained in:
@@ -749,5 +749,63 @@ namespace places {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Frecency Changed Notification Function
|
||||
|
||||
/* static */
|
||||
nsresult
|
||||
FrecencyNotificationFunction::create(mozIStorageConnection *aDBConn)
|
||||
{
|
||||
nsRefPtr<FrecencyNotificationFunction> function =
|
||||
new FrecencyNotificationFunction();
|
||||
nsresult rv = aDBConn->CreateFunction(
|
||||
NS_LITERAL_CSTRING("notify_frecency"), 5, function
|
||||
);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(
|
||||
FrecencyNotificationFunction,
|
||||
mozIStorageFunction
|
||||
)
|
||||
|
||||
NS_IMETHODIMP
|
||||
FrecencyNotificationFunction::OnFunctionCall(mozIStorageValueArray *aArgs,
|
||||
nsIVariant **_result)
|
||||
{
|
||||
uint32_t numArgs;
|
||||
nsresult rv = aArgs->GetNumEntries(&numArgs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
MOZ_ASSERT(numArgs == 5);
|
||||
|
||||
int32_t newFrecency = aArgs->AsInt32(0);
|
||||
|
||||
nsAutoCString spec;
|
||||
rv = aArgs->GetUTF8String(1, spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString guid;
|
||||
rv = aArgs->GetUTF8String(2, guid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool hidden = static_cast<bool>(aArgs->AsInt32(3));
|
||||
PRTime lastVisitDate = static_cast<PRTime>(aArgs->AsInt64(4));
|
||||
|
||||
const nsNavHistory* navHistory = nsNavHistory::GetConstHistoryService();
|
||||
NS_ENSURE_STATE(navHistory);
|
||||
navHistory->DispatchFrecencyChangedNotification(spec, newFrecency, guid,
|
||||
hidden, lastVisitDate);
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> result =
|
||||
do_CreateInstance("@mozilla.org/variant;1");
|
||||
NS_ENSURE_STATE(result);
|
||||
rv = result->SetAsInt32(newFrecency);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ADDREF(*_result = result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace places
|
||||
} // namespace mozilla
|
||||
|
||||
Reference in New Issue
Block a user