OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "core/frame/DOMWindowTimers.h" | 43 #include "core/frame/DOMWindowTimers.h" |
44 #include "core/workers/WorkerGlobalScope.h" | 44 #include "core/workers/WorkerGlobalScope.h" |
45 #include "modules/websockets/WebSocket.h" | 45 #include "modules/websockets/WebSocket.h" |
46 #include "wtf/OwnPtr.h" | 46 #include "wtf/OwnPtr.h" |
47 | 47 |
48 namespace WebCore { | 48 namespace WebCore { |
49 | 49 |
50 void SetTimeoutOrInterval(const v8::FunctionCallbackInfo<v8::Value>& info, bool
singleShot) | 50 void SetTimeoutOrInterval(const v8::FunctionCallbackInfo<v8::Value>& info, bool
singleShot) |
51 { | 51 { |
52 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(info.Ho
lder()); | 52 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(info.Ho
lder()); |
| 53 ASSERT(workerGlobalScope); |
53 | 54 |
54 int argumentCount = info.Length(); | 55 int argumentCount = info.Length(); |
55 if (argumentCount < 1) | 56 if (argumentCount < 1) |
56 return; | 57 return; |
57 | 58 |
58 v8::Handle<v8::Value> function = info[0]; | 59 v8::Handle<v8::Value> function = info[0]; |
59 | 60 |
60 WorkerScriptController* script = workerGlobalScope->script(); | 61 WorkerScriptController* script = workerGlobalScope->script(); |
61 if (!script) | 62 if (!script) |
62 return; | 63 return; |
(...skipping 17 matching lines...) Expand all Loading... |
80 params[i] = info[i+2]; | 81 params[i] = info[i+2]; |
81 } | 82 } |
82 // ScheduledAction takes ownership of actual params and releases them in
its destructor. | 83 // ScheduledAction takes ownership of actual params and releases them in
its destructor. |
83 action = adoptPtr(new ScheduledAction(v8Context, v8::Handle<v8::Function
>::Cast(function), paramCount, params.get(), info.GetIsolate())); | 84 action = adoptPtr(new ScheduledAction(v8Context, v8::Handle<v8::Function
>::Cast(function), paramCount, params.get(), info.GetIsolate())); |
84 } else | 85 } else |
85 return; | 86 return; |
86 | 87 |
87 int32_t timeout = argumentCount >= 2 ? info[1]->Int32Value() : 0; | 88 int32_t timeout = argumentCount >= 2 ? info[1]->Int32Value() : 0; |
88 int timerId; | 89 int timerId; |
89 if (singleShot) | 90 if (singleShot) |
90 timerId = DOMWindowTimers::setTimeout(workerGlobalScope, action.release(
), timeout); | 91 timerId = DOMWindowTimers::setTimeout(*workerGlobalScope, action.release
(), timeout); |
91 else | 92 else |
92 timerId = DOMWindowTimers::setInterval(workerGlobalScope, action.release
(), timeout); | 93 timerId = DOMWindowTimers::setInterval(*workerGlobalScope, action.releas
e(), timeout); |
93 | 94 |
94 v8SetReturnValue(info, timerId); | 95 v8SetReturnValue(info, timerId); |
95 } | 96 } |
96 | 97 |
97 void V8WorkerGlobalScope::setTimeoutMethodCustom(const v8::FunctionCallbackInfo<
v8::Value>& info) | 98 void V8WorkerGlobalScope::setTimeoutMethodCustom(const v8::FunctionCallbackInfo<
v8::Value>& info) |
98 { | 99 { |
99 return SetTimeoutOrInterval(info, true); | 100 return SetTimeoutOrInterval(info, true); |
100 } | 101 } |
101 | 102 |
102 void V8WorkerGlobalScope::setIntervalMethodCustom(const v8::FunctionCallbackInfo
<v8::Value>& info) | 103 void V8WorkerGlobalScope::setIntervalMethodCustom(const v8::FunctionCallbackInfo
<v8::Value>& info) |
(...skipping 11 matching lines...) Expand all Loading... |
114 WorkerScriptController* script = impl->script(); | 115 WorkerScriptController* script = impl->script(); |
115 if (!script) | 116 if (!script) |
116 return v8::Null(isolate); | 117 return v8::Null(isolate); |
117 | 118 |
118 v8::Handle<v8::Object> global = script->context()->Global(); | 119 v8::Handle<v8::Object> global = script->context()->Global(); |
119 ASSERT(!global.IsEmpty()); | 120 ASSERT(!global.IsEmpty()); |
120 return global; | 121 return global; |
121 } | 122 } |
122 | 123 |
123 } // namespace WebCore | 124 } // namespace WebCore |
OLD | NEW |