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 22 matching lines...) Expand all Loading... |
33 #include "bindings/core/v8/V8PerIsolateData.h" | 33 #include "bindings/core/v8/V8PerIsolateData.h" |
34 #include "platform/ScriptForbiddenScope.h" | 34 #include "platform/ScriptForbiddenScope.h" |
35 #include "platform/Task.h" | 35 #include "platform/Task.h" |
36 #include "public/platform/WebTaskRunner.h" | 36 #include "public/platform/WebTaskRunner.h" |
37 #include <v8.h> | 37 #include <v8.h> |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 void Microtask::performCheckpoint(v8::Isolate* isolate) | 41 void Microtask::performCheckpoint(v8::Isolate* isolate) |
42 { | 42 { |
43 if (ScriptForbiddenScope::isScriptForbidden()) | 43 V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate); |
| 44 ASSERT(isolateData); |
| 45 if (isolateData->recursionLevel() || isolateData->performingMicrotaskCheckpo
int() || isolateData->destructionPending() || ScriptForbiddenScope::isScriptForb
idden()) |
44 return; | 46 return; |
45 v8::MicrotasksScope::PerformCheckpoint(isolate); | 47 isolateData->setPerformingMicrotaskCheckpoint(true); |
| 48 isolate->RunMicrotasks(); |
| 49 isolateData->setPerformingMicrotaskCheckpoint(false); |
46 } | 50 } |
47 | 51 |
48 static void microtaskFunctionCallback(void* data) | 52 static void microtaskFunctionCallback(void* data) |
49 { | 53 { |
50 OwnPtr<WebTaskRunner::Task> task = adoptPtr(static_cast<WebTaskRunner::Task*
>(data)); | 54 OwnPtr<WebTaskRunner::Task> task = adoptPtr(static_cast<WebTaskRunner::Task*
>(data)); |
51 task->run(); | 55 task->run(); |
52 } | 56 } |
53 | 57 |
54 void Microtask::enqueueMicrotask(PassOwnPtr<WebTaskRunner::Task> callback) | 58 void Microtask::enqueueMicrotask(PassOwnPtr<WebTaskRunner::Task> callback) |
55 { | 59 { |
56 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 60 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
57 isolate->EnqueueMicrotask(µtaskFunctionCallback, callback.leakPtr()); | 61 isolate->EnqueueMicrotask(µtaskFunctionCallback, callback.leakPtr()); |
58 } | 62 } |
59 | 63 |
60 void Microtask::enqueueMicrotask(PassOwnPtr<SameThreadClosure> callback) | 64 void Microtask::enqueueMicrotask(PassOwnPtr<SameThreadClosure> callback) |
61 { | 65 { |
62 enqueueMicrotask(adoptPtr(new SameThreadTask(callback))); | 66 enqueueMicrotask(adoptPtr(new SameThreadTask(callback))); |
63 } | 67 } |
64 | 68 |
65 } // namespace blink | 69 } // namespace blink |
OLD | NEW |