| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (!script) | 63 if (!script) |
| 64 return v8::Undefined(); | 64 return v8::Undefined(); |
| 65 | 65 |
| 66 v8::Handle<v8::Context> v8Context = script->context(); | 66 v8::Handle<v8::Context> v8Context = script->context(); |
| 67 if (function->IsString()) { | 67 if (function->IsString()) { |
| 68 if (ContentSecurityPolicy* policy = workerContext->contentSecurityPolicy
()) { | 68 if (ContentSecurityPolicy* policy = workerContext->contentSecurityPolicy
()) { |
| 69 if (!policy->allowEval()) | 69 if (!policy->allowEval()) |
| 70 return v8Integer(0, args.GetIsolate()); | 70 return v8Integer(0, args.GetIsolate()); |
| 71 } | 71 } |
| 72 WTF::String stringFunction = toWebCoreString(function); | 72 WTF::String stringFunction = toWebCoreString(function); |
| 73 timerId = DOMTimer::install(workerContext, adoptPtr(new ScheduledAction(
v8Context, stringFunction, workerContext->url())), timeout, singleShot); | 73 timerId = DOMTimer::install(workerContext, adoptPtr(new ScheduledAction(
v8Context, stringFunction, workerContext->url(), args.GetIsolate())), timeout, s
ingleShot); |
| 74 } else if (function->IsFunction()) { | 74 } else if (function->IsFunction()) { |
| 75 size_t paramCount = argumentCount >= 2 ? argumentCount - 2 : 0; | 75 size_t paramCount = argumentCount >= 2 ? argumentCount - 2 : 0; |
| 76 v8::Local<v8::Value>* params = 0; | 76 v8::Local<v8::Value>* params = 0; |
| 77 if (paramCount > 0) { | 77 if (paramCount > 0) { |
| 78 params = new v8::Local<v8::Value>[paramCount]; | 78 params = new v8::Local<v8::Value>[paramCount]; |
| 79 for (size_t i = 0; i < paramCount; ++i) | 79 for (size_t i = 0; i < paramCount; ++i) |
| 80 params[i] = args[i+2]; | 80 params[i] = args[i+2]; |
| 81 } | 81 } |
| 82 // ScheduledAction takes ownership of actual params and releases them in
its destructor. | 82 // ScheduledAction takes ownership of actual params and releases them in
its destructor. |
| 83 OwnPtr<ScheduledAction> action = adoptPtr(new ScheduledAction(v8Context,
v8::Handle<v8::Function>::Cast(function), paramCount, params)); | 83 OwnPtr<ScheduledAction> action = adoptPtr(new ScheduledAction(v8Context,
v8::Handle<v8::Function>::Cast(function), paramCount, params, args.GetIsolate()
)); |
| 84 // FIXME: We should use a OwnArrayPtr for params. | 84 // FIXME: We should use a OwnArrayPtr for params. |
| 85 delete [] params; | 85 delete [] params; |
| 86 timerId = DOMTimer::install(workerContext, action.release(), timeout, si
ngleShot); | 86 timerId = DOMTimer::install(workerContext, action.release(), timeout, si
ngleShot); |
| 87 } else | 87 } else |
| 88 return v8::Undefined(); | 88 return v8::Undefined(); |
| 89 | 89 |
| 90 return v8Integer(timerId, args.GetIsolate()); | 90 return v8Integer(timerId, args.GetIsolate()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 v8::Handle<v8::Value> V8WorkerContext::importScriptsCallback(const v8::Arguments
& args) | 93 v8::Handle<v8::Value> V8WorkerContext::importScriptsCallback(const v8::Arguments
& args) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return v8NullWithCheck(isolate); | 136 return v8NullWithCheck(isolate); |
| 137 | 137 |
| 138 v8::Handle<v8::Object> global = script->context()->Global(); | 138 v8::Handle<v8::Object> global = script->context()->Global(); |
| 139 ASSERT(!global.IsEmpty()); | 139 ASSERT(!global.IsEmpty()); |
| 140 return global; | 140 return global; |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace WebCore | 143 } // namespace WebCore |
| 144 | 144 |
| 145 #endif // ENABLE(WORKERS) | 145 #endif // ENABLE(WORKERS) |
| OLD | NEW |