Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: Source/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp

Issue 8806015: Changes to support a second VM. (Closed) Base URL: svn://svn.chromium.org/dash/experimental/chrome/src/webkit-full
Patch Set: . Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32
33 #if ENABLE(WORKERS) 33 #if ENABLE(WORKERS)
34 #include "V8WorkerContext.h" 34 #include "V8WorkerContext.h"
35 35
36 #include "DOMTimer.h" 36 #include "DOMTimer.h"
37 #include "ExceptionCode.h" 37 #include "ExceptionCode.h"
38 #include "ScheduledAction.h"
39 #include "V8Binding.h" 38 #include "V8Binding.h"
40 #include "V8BindingMacros.h" 39 #include "V8BindingMacros.h"
41 #include "V8Proxy.h" 40 #include "V8Proxy.h"
41 #include "V8ScheduledAction.h"
42 #include "V8Utilities.h" 42 #include "V8Utilities.h"
43 #include "V8WorkerContextEventListener.h" 43 #include "V8WorkerContextEventListener.h"
44 #include "WebSocket.h" 44 #include "WebSocket.h"
45 #include "WorkerContext.h" 45 #include "WorkerContext.h"
46 #include "WorkerContextExecutionProxy.h" 46 #include "WorkerContextExecutionProxy.h"
47 47
48 namespace WebCore { 48 namespace WebCore {
49 49
50 v8::Handle<v8::Value> SetTimeoutOrInterval(const v8::Arguments& args, bool singl eShot) 50 v8::Handle<v8::Value> SetTimeoutOrInterval(const v8::Arguments& args, bool singl eShot)
51 { 51 {
52 WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder()); 52 WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());
53 53
54 int argumentCount = args.Length(); 54 int argumentCount = args.Length();
55 if (argumentCount < 1) 55 if (argumentCount < 1)
56 return v8::Undefined(); 56 return v8::Undefined();
57 57
58 v8::Handle<v8::Value> function = args[0]; 58 v8::Handle<v8::Value> function = args[0];
59 int32_t timeout = argumentCount >= 2 ? args[1]->Int32Value() : 0; 59 int32_t timeout = argumentCount >= 2 ? args[1]->Int32Value() : 0;
60 int timerId; 60 int timerId;
61 61
62 WorkerContextExecutionProxy* proxy = workerContext->script()->proxy(); 62 WorkerContextExecutionProxy* proxy = workerContext->script()->proxy();
63 if (!proxy) 63 if (!proxy)
64 return v8::Undefined(); 64 return v8::Undefined();
65 65
66 v8::Handle<v8::Context> v8Context = proxy->context(); 66 v8::Handle<v8::Context> v8Context = proxy->context();
67 if (function->IsString()) { 67 if (function->IsString()) {
68 WTF::String stringFunction = toWebCoreString(function); 68 WTF::String stringFunction = toWebCoreString(function);
69 timerId = DOMTimer::install(workerContext, adoptPtr(new ScheduledAction( v8Context, stringFunction, workerContext->url())), timeout, singleShot); 69 timerId = DOMTimer::install(workerContext, adoptPtr(new V8ScheduledActio n(v8Context, stringFunction, workerContext->url())), timeout, singleShot);
70 } else if (function->IsFunction()) { 70 } else if (function->IsFunction()) {
71 size_t paramCount = argumentCount >= 2 ? argumentCount - 2 : 0; 71 size_t paramCount = argumentCount >= 2 ? argumentCount - 2 : 0;
72 v8::Local<v8::Value>* params = 0; 72 v8::Local<v8::Value>* params = 0;
73 if (paramCount > 0) { 73 if (paramCount > 0) {
74 params = new v8::Local<v8::Value>[paramCount]; 74 params = new v8::Local<v8::Value>[paramCount];
75 for (size_t i = 0; i < paramCount; ++i) 75 for (size_t i = 0; i < paramCount; ++i)
76 params[i] = args[i+2]; 76 params[i] = args[i+2];
77 } 77 }
78 // ScheduledAction takes ownership of actual params and releases them in its destructor. 78 // ScheduledAction takes ownership of actual params and releases them in its destructor.
79 OwnPtr<ScheduledAction> action = adoptPtr(new ScheduledAction(v8Context, v8::Handle<v8::Function>::Cast(function), paramCount, params)); 79 OwnPtr<ScheduledAction> action = adoptPtr(new V8ScheduledAction(v8Contex t, v8::Handle<v8::Function>::Cast(function), paramCount, params));
80 // FIXME: We should use a OwnArrayPtr for params. 80 // FIXME: We should use a OwnArrayPtr for params.
81 delete [] params; 81 delete [] params;
82 timerId = DOMTimer::install(workerContext, action.release(), timeout, si ngleShot); 82 timerId = DOMTimer::install(workerContext, action.release(), timeout, si ngleShot);
83 } else 83 } else
84 return v8::Undefined(); 84 return v8::Undefined();
85 85
86 return v8::Integer::New(timerId); 86 return v8::Integer::New(timerId);
87 } 87 }
88 88
89 v8::Handle<v8::Value> V8WorkerContext::importScriptsCallback(const v8::Arguments & args) 89 v8::Handle<v8::Value> V8WorkerContext::importScriptsCallback(const v8::Arguments & args)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return v8::Null(); 134 return v8::Null();
135 135
136 v8::Handle<v8::Object> global = proxy->context()->Global(); 136 v8::Handle<v8::Object> global = proxy->context()->Global();
137 ASSERT(!global.IsEmpty()); 137 ASSERT(!global.IsEmpty());
138 return global; 138 return global;
139 } 139 }
140 140
141 } // namespace WebCore 141 } // namespace WebCore
142 142
143 #endif // ENABLE(WORKERS) 143 #endif // ENABLE(WORKERS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698