зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551779 part 3. Stop using [array] for nsINavHistoryService.getObservers and nsINavBookmarksService.getObservers. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D31239 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b9db505a9a
Коммит
91cc06de23
|
@ -456,6 +456,5 @@ interface nsINavBookmarksService : nsISupports
|
|||
/**
|
||||
* Gets an array of registered nsINavBookmarkObserver objects.
|
||||
*/
|
||||
void getObservers([optional] out unsigned long count,
|
||||
[retval, array, size_is(count)] out nsINavBookmarkObserver observers);
|
||||
Array<nsINavBookmarkObserver> getObservers();
|
||||
};
|
||||
|
|
|
@ -1261,8 +1261,7 @@ interface nsINavHistoryService : nsISupports
|
|||
/**
|
||||
* Gets an array of registered nsINavHistoryObserver objects.
|
||||
*/
|
||||
void getObservers([optional] out unsigned long count,
|
||||
[retval, array, size_is(count)] out nsINavHistoryObserver observers);
|
||||
Array<nsINavHistoryObserver> getObservers();
|
||||
|
||||
/**
|
||||
* True if history is disabled. currently,
|
||||
|
|
|
@ -1763,29 +1763,19 @@ nsNavBookmarks::RemoveObserver(nsINavBookmarkObserver* aObserver) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavBookmarks::GetObservers(uint32_t* _count,
|
||||
nsINavBookmarkObserver*** _observers) {
|
||||
NS_ENSURE_ARG_POINTER(_count);
|
||||
NS_ENSURE_ARG_POINTER(_observers);
|
||||
|
||||
*_count = 0;
|
||||
*_observers = nullptr;
|
||||
nsNavBookmarks::GetObservers(nsTArray<RefPtr<nsINavBookmarkObserver>>& aObservers) {
|
||||
aObservers.Clear();
|
||||
|
||||
if (!mCanNotify) return NS_OK;
|
||||
|
||||
nsCOMArray<nsINavBookmarkObserver> observers;
|
||||
|
||||
for (uint32_t i = 0; i < mObservers.Length(); ++i) {
|
||||
const nsCOMPtr<nsINavBookmarkObserver>& observer =
|
||||
nsCOMPtr<nsINavBookmarkObserver> observer =
|
||||
mObservers.ElementAt(i).GetValue();
|
||||
// Skip nullified weak observers.
|
||||
if (observer) observers.AppendElement(observer);
|
||||
if (observer) {
|
||||
aObservers.AppendElement(observer.forget());
|
||||
}
|
||||
}
|
||||
|
||||
if (observers.Count() == 0) return NS_OK;
|
||||
|
||||
*_count = observers.Count();
|
||||
observers.Forget(_observers);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -2025,13 +2025,8 @@ nsNavHistory::RemoveObserver(nsINavHistoryObserver* aObserver) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavHistory::GetObservers(uint32_t* _count,
|
||||
nsINavHistoryObserver*** _observers) {
|
||||
NS_ENSURE_ARG_POINTER(_count);
|
||||
NS_ENSURE_ARG_POINTER(_observers);
|
||||
|
||||
*_count = 0;
|
||||
*_observers = nullptr;
|
||||
nsNavHistory::GetObservers(nsTArray<RefPtr<nsINavHistoryObserver>>& aObservers) {
|
||||
aObservers.Clear();
|
||||
|
||||
// Clear any cached value, cause it's very likely the consumer has made
|
||||
// changes to history and is now trying to notify them.
|
||||
|
@ -2039,20 +2034,15 @@ nsNavHistory::GetObservers(uint32_t* _count,
|
|||
|
||||
if (!mCanNotify) return NS_OK;
|
||||
|
||||
nsCOMArray<nsINavHistoryObserver> observers;
|
||||
|
||||
// Then add the other observers.
|
||||
for (uint32_t i = 0; i < mObservers.Length(); ++i) {
|
||||
const nsCOMPtr<nsINavHistoryObserver>& observer =
|
||||
nsCOMPtr<nsINavHistoryObserver> observer =
|
||||
mObservers.ElementAt(i).GetValue();
|
||||
// Skip nullified weak observers.
|
||||
if (observer) observers.AppendElement(observer);
|
||||
if (observer) {
|
||||
aObservers.AppendElement(observer.forget());
|
||||
}
|
||||
}
|
||||
|
||||
if (observers.Count() == 0) return NS_OK;
|
||||
|
||||
*_count = observers.Count();
|
||||
observers.Forget(_observers);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче