Index: third_party/WebKit/Source/platform/ScriptForbiddenScope.h |
diff --git a/third_party/WebKit/Source/platform/ScriptForbiddenScope.h b/third_party/WebKit/Source/platform/ScriptForbiddenScope.h |
index b8ddadf0c4abd882d3f5c78575f1a99a717e3240..4aa19b5ff5e1ef72fd95d04ea849913d9a2bc385 100644 |
--- a/third_party/WebKit/Source/platform/ScriptForbiddenScope.h |
+++ b/third_party/WebKit/Source/platform/ScriptForbiddenScope.h |
@@ -44,11 +44,15 @@ class PLATFORM_EXPORT ScriptForbiddenScope final { |
++s_scriptForbiddenCount; |
} |
static void exit() { |
+ DCHECK(isMainThread()); |
DCHECK(s_scriptForbiddenCount); |
--s_scriptForbiddenCount; |
} |
static bool isScriptForbidden() { |
- return isMainThread() && s_scriptForbiddenCount; |
+ // Check s_scriptForbiddenCount first to avoid any calls to isMainThread() |
+ // since under normal situations where we check this (ex. inside |
+ // V8ScriptRunner) the value should always be zero. |
+ return s_scriptForbiddenCount && isMainThread(); |
} |
private: |