| 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 V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate); | 43 if (ScriptForbiddenScope::isScriptForbidden()) |
| 44 ASSERT(isolateData); | |
| 45 if (isolateData->recursionLevel() || isolateData->performingMicrotaskCheckpo
int() || isolateData->destructionPending() || ScriptForbiddenScope::isScriptForb
idden()) | |
| 46 return; | 44 return; |
| 47 isolateData->setPerformingMicrotaskCheckpoint(true); | 45 v8::MicrotasksScope::PerformCheckpoint(isolate); |
| 48 isolate->RunMicrotasks(); | |
| 49 isolateData->setPerformingMicrotaskCheckpoint(false); | |
| 50 } | 46 } |
| 51 | 47 |
| 52 static void microtaskFunctionCallback(void* data) | 48 static void microtaskFunctionCallback(void* data) |
| 53 { | 49 { |
| 54 OwnPtr<WebTaskRunner::Task> task = adoptPtr(static_cast<WebTaskRunner::Task*
>(data)); | 50 OwnPtr<WebTaskRunner::Task> task = adoptPtr(static_cast<WebTaskRunner::Task*
>(data)); |
| 55 task->run(); | 51 task->run(); |
| 56 } | 52 } |
| 57 | 53 |
| 58 void Microtask::enqueueMicrotask(PassOwnPtr<WebTaskRunner::Task> callback) | 54 void Microtask::enqueueMicrotask(PassOwnPtr<WebTaskRunner::Task> callback) |
| 59 { | 55 { |
| 60 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 56 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 61 isolate->EnqueueMicrotask(µtaskFunctionCallback, callback.leakPtr()); | 57 isolate->EnqueueMicrotask(µtaskFunctionCallback, callback.leakPtr()); |
| 62 } | 58 } |
| 63 | 59 |
| 64 void Microtask::enqueueMicrotask(PassOwnPtr<SameThreadClosure> callback) | 60 void Microtask::enqueueMicrotask(PassOwnPtr<SameThreadClosure> callback) |
| 65 { | 61 { |
| 66 enqueueMicrotask(adoptPtr(new SameThreadTask(callback))); | 62 enqueueMicrotask(adoptPtr(new SameThreadTask(callback))); |
| 67 } | 63 } |
| 68 | 64 |
| 69 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |