Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/action_platform.js

Issue 10233013: Crawler, second version (Closed)
Patch Set: Created April 12, 2013, 1:38 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/action.js ('k') | lib/application.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /**
2 * @fileOverview A platform-specific primitive set for the module action.js. Thi s version is for Firefox extensions.
3 */
4
5 /**
6 * @namespace
7 */
8 Action_Platform = {};
9
10 /**
11 * An instance of the NS thread manager.
12 * @type {nsIThreadManager}
13 */
14 Action_Platform.thread_manager = Cc["@mozilla.org/thread-manager;1"].createInsta nce( Ci.nsIThreadManager );
15
16 /**
17 * Dispatch a function into the next JavaScript thread.
18 * @param {function} f
19 */
20 Action_Platform.dispatch = function( f )
21 {
22 Action_Platform.thread_manager.currentThread.dispatch(
23 {run: f},
24 Ci.nsIEventTarget.DISPATCH_NORMAL
25 );
26 };
27
28 /**
29 * Timer class for the NS timer.
30 * @constructor
31 */
32 Action_Platform.Timer = function()
33 {
34 /**
35 * An instance of the NS timer, which
36 * @type {*}
37 */
38 this.timer = Cc["@mozilla.org/timer;1"].createInstance( Ci.nsITimer )
39 };
40
41 /**
42 * @param {function} f
43 * @param {number} duration
44 */
45 Action_Platform.Timer.prototype.set = function( f, duration )
46 {
47 this.timer.initWithCallback( f, duration, Ci.nsITimer.TYPE_ONE_SHOT )
48 };
49
50 Action_Platform.Timer.prototype.clear = function()
51 {
52 this.timer.cancel();
53 };
54
55 /**
56 * Set the timer.
57 * @param {function} f
58 * @param {number} duration
59 * @return {Action_Platform.Timer}
60 */
61 Action_Platform.set_timer = function( f, duration )
62 {
63 var t = new Action_Platform.Timer();
64 t.set( f, duration );
65 return t;
66 };
67
68 /**
69 * Clear the timer.
70 * @param {Action_Platform.Timer} id
71 */
72 Action_Platform.clear_timer = function( id )
73 {
74 id.clear();
75 };
76
77 exports.Action_Platform = Action_Platform;
OLDNEW
« no previous file with comments | « lib/action.js ('k') | lib/application.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld