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 |