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

Unified Diff: third_party/WebKit/Source/platform/ScriptForbiddenScope.h

Issue 2709763003: Avoid calling isMainThread() in the common cases when checking ScriptForbiddenScope::isScriptForbid… (Closed)
Patch Set: english. Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698