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

Unified Diff: Source/bindings/core/v8/V8RecursionScope.h

Issue 648423003: Enforce ScriptForbiddenScope and make it non-fatal. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Getting ambitious Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/core/v8/NPV8Object.cpp ('k') | Source/bindings/core/v8/V8ScriptRunner.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8RecursionScope.h
diff --git a/Source/bindings/core/v8/V8RecursionScope.h b/Source/bindings/core/v8/V8RecursionScope.h
index e42a4fa1d3a10cac6aff27666576ac3cc90ecddc..48ef82ec82eef6c4d858ed8e44857c437b5c03d8 100644
--- a/Source/bindings/core/v8/V8RecursionScope.h
+++ b/Source/bindings/core/v8/V8RecursionScope.h
@@ -35,6 +35,7 @@
#include "core/dom/ExecutionContext.h"
#include "platform/ScriptForbiddenScope.h"
#include "wtf/Noncopyable.h"
+#include "wtf/PassOwnPtr.h"
#include <v8.h>
namespace blink {
@@ -59,14 +60,11 @@ namespace blink {
class V8RecursionScope {
WTF_MAKE_NONCOPYABLE(V8RecursionScope);
public:
- explicit V8RecursionScope(v8::Isolate* isolate)
- : m_isolate(isolate)
+ static PassOwnPtr<V8RecursionScope> create(v8::Isolate* isolate)
haraken 2014/10/14 01:04:29 Shall we rename create => createIfScriptAllowed ?
{
- V8PerIsolateData::from(m_isolate)->incrementRecursionLevel();
- RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden());
- // If you want V8 to autorun microtasks, this class needs to have a
- // v8::Isolate::SuppressMicrotaskExecutionScope member.
- ASSERT(!isolate->WillAutorunMicrotasks());
+ return !ScriptForbiddenScope::isScriptForbidden()
+ ? adoptPtr(new V8RecursionScope(isolate))
+ : nullptr;
}
~V8RecursionScope()
@@ -114,6 +112,15 @@ public:
};
private:
+ explicit V8RecursionScope(v8::Isolate* isolate)
+ : m_isolate(isolate)
+ {
+ V8PerIsolateData::from(m_isolate)->incrementRecursionLevel();
+ // If you want V8 to autorun microtasks, this class needs to have a
+ // v8::Isolate::SuppressMicrotaskExecutionScope member.
+ ASSERT(!isolate->WillAutorunMicrotasks());
+ }
+
void didLeaveScriptContext();
v8::Isolate* m_isolate;
« no previous file with comments | « Source/bindings/core/v8/NPV8Object.cpp ('k') | Source/bindings/core/v8/V8ScriptRunner.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698