OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 44 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
45 V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate); | 45 V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate); |
46 ASSERT(isolateData); | 46 ASSERT(isolateData); |
47 if (isolateData->recursionLevel() || isolateData->performingMicrotaskCheckpo
int()) | 47 if (isolateData->recursionLevel() || isolateData->performingMicrotaskCheckpo
int()) |
48 return; | 48 return; |
49 isolateData->setPerformingMicrotaskCheckpoint(true); | 49 isolateData->setPerformingMicrotaskCheckpoint(true); |
50 isolate->RunMicrotasks(); | 50 isolate->RunMicrotasks(); |
51 isolateData->setPerformingMicrotaskCheckpoint(false); | 51 isolateData->setPerformingMicrotaskCheckpoint(false); |
52 } | 52 } |
53 | 53 |
54 static void microtaskFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&
info) | 54 static void microtaskFunctionCallback(void* data) |
55 { | 55 { |
56 OwnPtr<blink::WebThread::Task> task = adoptPtr(static_cast<blink::WebThread:
:Task*>(info.Data().As<v8::External>()->Value())); | 56 OwnPtr<blink::WebThread::Task> task = adoptPtr(static_cast<blink::WebThread:
:Task*>(data)); |
57 task->run(); | 57 task->run(); |
58 } | 58 } |
59 | 59 |
60 void Microtask::enqueueMicrotask(PassOwnPtr<blink::WebThread::Task> callback) | 60 void Microtask::enqueueMicrotask(PassOwnPtr<blink::WebThread::Task> callback) |
61 { | 61 { |
62 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 62 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
63 V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate); | 63 isolate->EnqueueMicrotask(µtaskFunctionCallback, callback.leakPtr()); |
64 v8::HandleScope handleScope(isolate); | |
65 v8::Local<v8::Context> context = isolateData->ensureDomInJSContext(); | |
66 ASSERT(!context.IsEmpty()); | |
67 v8::Context::Scope scope(context); | |
68 v8::Local<v8::External> handler = v8::External::New(isolate, callback.leakPt
r()); | |
69 isolate->EnqueueMicrotask(v8::Function::New(isolate, µtaskFunctionCallb
ack, handler)); | |
70 } | 64 } |
71 | 65 |
72 void Microtask::enqueueMicrotask(const Closure& callback) | 66 void Microtask::enqueueMicrotask(const Closure& callback) |
73 { | 67 { |
74 enqueueMicrotask(adoptPtr(new Task(callback))); | 68 enqueueMicrotask(adoptPtr(new Task(callback))); |
75 } | 69 } |
76 | 70 |
77 } // namespace WebCore | 71 } // namespace WebCore |
OLD | NEW |