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

Side by Side Diff: third_party/WebKit/Source/core/dom/Microtask.cpp

Issue 1743763004: Use v8::MicrotasksScope internally in V8RecursionScope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8rs-2-endofscope
Patch Set: v8_helpers Created 4 years, 9 months 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
OLDNEW
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
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(&microtaskFunctionCallback, callback.leakPtr()); 57 isolate->EnqueueMicrotask(&microtaskFunctionCallback, 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698