Bug 22718 - Implement WindowTimers interface in Workers
Summary: Implement WindowTimers interface in Workers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Dmitry Titov
URL:
Keywords: InRadar
: 22328 (view as bug list)
Depends on: 22755 23207 23223 23312 23373 23374 23488 23560
Blocks:
  Show dependency treegraph
 
Reported: 2008-12-07 03:13 PST by Alexey Proskuryakov
Modified: 2009-02-03 02:33 PST (History)
1 user (show)

See Also:


Attachments
Proposed patch (15.20 KB, patch)
2009-02-02 18:49 PST, Dmitry Titov
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2008-12-07 03:13:26 PST
We need to make timers function in Workers.

[NoInterfaceObject] interface WindowTimers {
  // timers
  long setTimeout(in TimeoutHandler handler, in long timeout);
  long setTimeout(in TimeoutHandler handler, in long timeout, arguments...);
  long setTimeout(in DOMString code, in long timeout);
  long setTimeout(in DOMString code, in long timeout, in DOMString language);
  void clearTimeout(in long handle);
  long setInterval(in TimeoutHandler handler, in long timeout);
  long setInterval(in TimeoutHandler handler, in long timeout, arguments...);
  long setInterval(in DOMString code, in long timeout);
  long setInterval(in DOMString code, in long timeout, in DOMString language);
  void clearInterval(in long handle);
};

interface TimeoutHandler {
  void handleEvent([Variadic] in any args);
};
Comment 1 Alexey Proskuryakov 2008-12-07 03:57:24 PST
<rdar://problem/6425804>
Comment 2 Dmitry Titov 2008-12-08 00:49:27 PST
*** Bug 22328 has been marked as a duplicate of this bug. ***
Comment 3 Dmitry Titov 2009-01-10 13:39:10 PST
Adding timers to Workers (setTimeout,setInterval,clearTimeout,clearInterval) happened to be a big enough work to split it into multiple patches. So I keep this bug as a "root" and make small patches in separate bugs that refer to this one for context.

Here is a rough plan of this work. The main changes are related to sharing timer functionality between Document/DOMWindow and a new WorkerContext, making TimerBase to be threading-aware and changing Worker thread's run loop to support timers.

More detailed list (likely to change somewhat as a result of reviews and feedback of others):

1. Move timer-related code from JSDOMWindowBase where it currently lives into a new DOMTimer object, abstract JS engine - related parts into ScheduledAction class. This will allow to use timer functionality from both DOMWindow and WorkerContext.

2. Create a new RunLoop class to encapsulate the worker thread's run loop which has to deal with message queue and timers. This includes changes to WTF::MessageQueue (to add timedWait), TimeBase (to make it able to work on worker threads too) and other threading-related changes.

3. Expose timer functions on WorkerContext/JSWorkerContext.

Comment 4 Dmitry Titov 2009-02-02 18:49:44 PST
Created attachment 27273 [details]
Proposed patch

Final patch - enables JS API, adds a test.
Comment 5 Dmitry Titov 2009-02-02 19:00:21 PST
This patch depends on a relatively simple patch in bug 23560 for timers to actually fire. But otherwise it doesn't depend on it so it can be reviewed separately. If patch for the bug 23560 will be further modified, it won't affect this one.

Comment 6 Alexey Proskuryakov 2009-02-03 01:48:18 PST
Comment on attachment 27273 [details]
Proposed patch

r=me
Comment 7 Alexey Proskuryakov 2009-02-03 02:33:31 PST
Committed revision 40534.

Nice test case!