Closed
Bug 748464
Opened 13 years ago
Closed 13 years ago
refactor nsGlobalWindow::RunTimeout a bit
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla16
People
(Reporter: froydnj, Assigned: froydnj)
References
Details
Attachments
(2 files, 2 obsolete files)
16.56 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
7.40 KB,
patch
|
Details | Diff | Splinter Review |
For bug 715376, I *think* I need the ability to run timeouts outside of RunTimeout. (I haven't totally figured out where everything goes yet, though.) Some moving things around is helpful for doing that.
Independent of those concerns, though, RunTimeout is a pretty big function and breaking it up is helpful.
![]() |
Assignee | |
Comment 1•13 years ago
|
||
I think the new RescheduleTimeout function is especially helpful at clarifying the logic for interval timeouts.
Asking for feedback, rather than review, to see if this sort of thing is even desirable to start with.
Attachment #617956 -
Flags: feedback?(bzbarsky)
![]() |
||
Comment 2•13 years ago
|
||
Comment on attachment 617956 [details] [diff] [review]
patch
>+nsGlobalWindow::RescheduleTimeout(nsTimeout *aTimeout, const TimeStamp &now)
>+ if (aTimeout->mTimer) {
>+ // The timeout still has an OS timer, and it's not an
>+ // interval, that means that the OS timer could still fire (if
>+ // it didn't already, i.e. aTimeout == timeout), cancel the OS
There is no |timeout| in this method. Just take out the parenthetical? And fix the indent on the comment, please.
>+ // If we're running pending timeouts because they've been temporarily
>+ // disabled (!aTimeout), set the next interval to be relative to "now",
>+ // and not to when the timeout that was pending should have fired.
>+ TimeStamp firingTime;
>+ if (!aTimeout)
No, this is wrong. In the caller, where the code and comment came from, aTimeout is the thing passed to RunTimeout; that's what was being null-checked originally. But in this method, aTimeout is the |timeout| from RunTimeout, which in particular is never null here. So this code is no longer doing what it should. Please fix that.
>+ bool RescheduleTimeout(nsTimeout *aTimeout, const TimeStamp &now);
Please document the meaning of the return value.
Sorry for the lag here; apart from the above nits and firingTime issue, this looks good!
Attachment #617956 -
Flags: feedback?(bzbarsky) → feedback+
![]() |
Assignee | |
Comment 3•13 years ago
|
||
Think I fixed everything bz pointed out; bouncing r? to someone different for a second pair of eyes.
Attachment #617956 -
Attachment is obsolete: true
Attachment #625759 -
Flags: review?(mounir)
Updated•13 years ago
|
Assignee: nobody → nfroyd
Comment 4•13 years ago
|
||
Comment on attachment 625759 [details] [diff] [review]
patch
Review of attachment 625759 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/base/nsGlobalWindow.cpp
@@ +8801,5 @@
> }
>
> +void
> +nsGlobalWindow::RunTimeoutHandler(nsTimeout *aTimeout,
> + nsIScriptContext *aScx)
* on the left
@@ +8803,5 @@
> +void
> +nsGlobalWindow::RunTimeoutHandler(nsTimeout *aTimeout,
> + nsIScriptContext *aScx)
> +{
> + nsTimeout *last_running_timeout = mRunningTimeout;
Same
@@ +8819,5 @@
> + aTimeout->mPopupState = openAbused;
> +
> + // Hold on to the timeout in case mExpr or mFunObj releases its
> + // doc.
> + aTimeout->AddRef();
Manual AddRefs are bad. Please use a smart pointer
@@ +8909,5 @@
> + TimeStamp firingTime;
> + if (aRunningPendingTimeouts)
> + firingTime = now + nextInterval;
> + else
> + firingTime = aTimeout->mWhen + nextInterval;
2 × {}
@@ +9115,5 @@
> // |timeout| may be the last reference to the timeout so check if
> // it was cleared before releasing it.
> bool timeout_was_cleared = timeout->mCleared;
>
> timeout->Release();
This release should move into the helper
![]() |
Assignee | |
Comment 5•13 years ago
|
||
Updated with Ms2ger's concerns. I guess local style for dom/ is aspirational, rather than what one finds in nearby code?
Attachment #625759 -
Attachment is obsolete: true
Attachment #625759 -
Flags: review?(mounir)
Attachment #626002 -
Flags: review?(mounir)
Comment 6•13 years ago
|
||
Comment on attachment 626002 [details] [diff] [review]
patch
Review of attachment 626002 [details] [diff] [review]:
-----------------------------------------------------------------
Redirecting this to bz because I've never touched nor read that code before.
Attachment #626002 -
Flags: review?(mounir) → review?(bzbarsky)
![]() |
||
Comment 7•13 years ago
|
||
Any chance of an interdiff from the last thing I reviewed?
![]() |
||
Comment 8•13 years ago
|
||
> I guess local style for dom/ is aspirational
More precisely, it's a matter of some recent disagreement... ;)
![]() |
Assignee | |
Comment 9•13 years ago
|
||
![]() |
||
Comment 10•13 years ago
|
||
Comment on attachment 626002 [details] [diff] [review]
patch
The "timeout->AddRef();" in RunTimeoutHandler should go away. Otherwise this leaks.
r=me with that. Thanks for the interdiff!
Attachment #626002 -
Flags: review?(bzbarsky) → review+
![]() |
Assignee | |
Comment 11•13 years ago
|
||
Status: NEW → ASSIGNED
Comment 12•13 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla16
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•