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

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

Issue 1502093002: Improve ScriptForbiddenScope handling in cross-threaded code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased up past r363426 Created 5 years 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
Index: third_party/WebKit/Source/platform/ScriptForbiddenScope.cpp
diff --git a/third_party/WebKit/Source/platform/ScriptForbiddenScope.cpp b/third_party/WebKit/Source/platform/ScriptForbiddenScope.cpp
index f0c50c6e688feb1ccf267c4a595973f0ccbd5c8b..c36591837ba96557488caa19fca134a429568f2b 100644
--- a/third_party/WebKit/Source/platform/ScriptForbiddenScope.cpp
+++ b/third_party/WebKit/Source/platform/ScriptForbiddenScope.cpp
@@ -14,15 +14,12 @@ static unsigned s_scriptForbiddenCount = 0;
ScriptForbiddenScope::ScriptForbiddenScope()
{
- ASSERT(isMainThread());
- ++s_scriptForbiddenCount;
+ enter();
}
ScriptForbiddenScope::~ScriptForbiddenScope()
{
- ASSERT(isMainThread());
- ASSERT(s_scriptForbiddenCount);
- --s_scriptForbiddenCount;
+ exit();
}
void ScriptForbiddenScope::enter()
@@ -54,4 +51,15 @@ ScriptForbiddenScope::AllowUserAgentScript::~AllowUserAgentScript()
ASSERT(!isMainThread() || !s_scriptForbiddenCount);
}
+ScriptForbiddenIfMainThreadScope::ScriptForbiddenIfMainThreadScope()
+{
+ if (isMainThread())
+ ScriptForbiddenScope::enter();
+}
+
+ScriptForbiddenIfMainThreadScope::~ScriptForbiddenIfMainThreadScope()
+{
+ if (isMainThread())
+ ScriptForbiddenScope::exit();
+}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/ScriptForbiddenScope.h ('k') | third_party/WebKit/Source/platform/heap/Heap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698