Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / ScriptForbiddenScope.cpp
blobf0c50c6e688feb1ccf267c4a595973f0ccbd5c8b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "platform/ScriptForbiddenScope.h"
8 #include "wtf/Assertions.h"
9 #include "wtf/MainThread.h"
11 namespace blink {
13 static unsigned s_scriptForbiddenCount = 0;
15 ScriptForbiddenScope::ScriptForbiddenScope()
17 ASSERT(isMainThread());
18 ++s_scriptForbiddenCount;
21 ScriptForbiddenScope::~ScriptForbiddenScope()
23 ASSERT(isMainThread());
24 ASSERT(s_scriptForbiddenCount);
25 --s_scriptForbiddenCount;
28 void ScriptForbiddenScope::enter()
30 ASSERT(isMainThread());
31 ++s_scriptForbiddenCount;
34 void ScriptForbiddenScope::exit()
36 ASSERT(isMainThread());
37 ASSERT(s_scriptForbiddenCount);
38 --s_scriptForbiddenCount;
41 bool ScriptForbiddenScope::isScriptForbidden()
43 return isMainThread() && s_scriptForbiddenCount;
46 ScriptForbiddenScope::AllowUserAgentScript::AllowUserAgentScript()
48 if (isMainThread())
49 m_change.emplace(s_scriptForbiddenCount, 0);
52 ScriptForbiddenScope::AllowUserAgentScript::~AllowUserAgentScript()
54 ASSERT(!isMainThread() || !s_scriptForbiddenCount);
57 } // namespace blink