Bug 1404198: Part 2j - Switch to NS_NewTimer* everywhere else. r=njn

MozReview-Commit-ID: LmGIgfmNSmk
This commit is contained in:
Kris Maglione
2017-09-24 19:57:48 -07:00
parent 7cdbf75d48
commit 4a5ef65402
19 changed files with 117 additions and 148 deletions

View File

@@ -26,6 +26,7 @@
#include "mozilla/LoadInfo.h"
#include "mozilla/HTMLEditor.h"
#include "mozilla/Preferences.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/Services.h"
#include "mozilla/StartupTimeline.h"
#include "mozilla/Telemetry.h"
@@ -456,23 +457,13 @@ nsPingListener::StartTimeout(DocGroup* aDocGroup)
{
NS_ENSURE_ARG(aDocGroup);
nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
timer->SetTarget(aDocGroup->EventTargetFor(TaskCategory::Network));
if (timer) {
nsresult rv =
timer->InitWithNamedFuncCallback(OnPingTimeout,
mLoadGroup,
PING_TIMEOUT,
nsITimer::TYPE_ONE_SHOT,
"nsPingListener::StartTimeout");
if (NS_SUCCEEDED(rv)) {
mTimer = timer;
return NS_OK;
}
}
return NS_ERROR_OUT_OF_MEMORY;
return NS_NewTimerWithFuncCallback(getter_AddRefs(mTimer),
OnPingTimeout,
mLoadGroup,
PING_TIMEOUT,
nsITimer::TYPE_ONE_SHOT,
"nsPingListener::StartTimeout",
aDocGroup->EventTargetFor(TaskCategory::Network));
}
NS_IMETHODIMP
@@ -6858,14 +6849,15 @@ nsDocShell::RefreshURI(nsIURI* aURI, int32_t aDelay, bool aRepeat,
} else {
// There is no page loading going on right now. Create the
// timer and fire it right away.
nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
NS_ENSURE_TRUE(timer, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
nsCOMPtr<nsITimer> timer;
MOZ_TRY_VAR(timer,
NS_NewTimerWithCallback(refreshTimer, aDelay, nsITimer::TYPE_ONE_SHOT,
win->TabGroup()->EventTargetFor(TaskCategory::Network)));
mRefreshURIList->AppendElement(timer, /*weak =*/ false); // owning timer ref
timer->SetTarget(win->TabGroup()->EventTargetFor(TaskCategory::Network));
timer->InitWithCallback(refreshTimer, aDelay, nsITimer::TYPE_ONE_SHOT);
}
return NS_OK;
}
@@ -7345,16 +7337,20 @@ nsDocShell::RefreshURIFromQueue()
uint32_t delay =
static_cast<nsRefreshTimer*>(
static_cast<nsITimerCallback*>(refreshInfo))->GetDelay();
nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
if (timer && win) {
// Replace the nsRefreshTimer element in the queue with
// its corresponding timer object, so that in case another
// load comes through before the timer can go off, the timer will
// get cancelled in CancelRefreshURITimer()
mRefreshURIList->ReplaceElementAt(timer, n, /*weak =*/ false);
timer->SetTarget(win->TabGroup()->EventTargetFor(TaskCategory::Network));
timer->InitWithCallback(refreshInfo, delay, nsITimer::TYPE_ONE_SHOT);
if (win) {
nsCOMPtr<nsITimer> timer;
NS_NewTimerWithCallback(getter_AddRefs(timer),
refreshInfo, delay, nsITimer::TYPE_ONE_SHOT,
win->TabGroup()->EventTargetFor(TaskCategory::Network));
if (timer) {
// Replace the nsRefreshTimer element in the queue with
// its corresponding timer object, so that in case another
// load comes through before the timer can go off, the timer will
// get cancelled in CancelRefreshURITimer()
mRefreshURIList->ReplaceElementAt(timer, n, /*weak =*/ false);
}
}
}
}