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

Side by Side Diff: third_party/WebKit/Source/platform/ScriptForbiddenScope.cpp

Issue 2213903002: Make ScriptForbiddenScope inlineable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moving count variable to private static member Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/ScriptForbiddenScope.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/ScriptForbiddenScope.h" 5 #include "platform/ScriptForbiddenScope.h"
6 6
7 #include "wtf/Assertions.h" 7 #include "wtf/Assertions.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 static unsigned s_scriptForbiddenCount = 0; 11 unsigned ScriptForbiddenScope::s_scriptForbiddenCount = 0;
12 12
13 ScriptForbiddenScope::ScriptForbiddenScope()
14 {
15 enter();
16 }
17
18 ScriptForbiddenScope::~ScriptForbiddenScope()
19 {
20 exit();
21 }
22
23 void ScriptForbiddenScope::enter()
24 {
25 ASSERT(isMainThread());
26 ++s_scriptForbiddenCount;
27 }
28
29 void ScriptForbiddenScope::exit()
30 {
31 ASSERT(isMainThread());
32 ASSERT(s_scriptForbiddenCount);
33 --s_scriptForbiddenCount;
34 }
35
36 bool ScriptForbiddenScope::isScriptForbidden()
37 {
38 return isMainThread() && s_scriptForbiddenCount;
39 }
40
41 ScriptForbiddenScope::AllowUserAgentScript::AllowUserAgentScript()
42 {
43 if (isMainThread())
44 m_change.emplace(&s_scriptForbiddenCount, 0);
45 }
46
47 ScriptForbiddenScope::AllowUserAgentScript::~AllowUserAgentScript()
48 {
49 ASSERT(!isMainThread() || !s_scriptForbiddenCount);
50 }
51
52 ScriptForbiddenIfMainThreadScope::ScriptForbiddenIfMainThreadScope()
53 {
54 if (isMainThread())
55 ScriptForbiddenScope::enter();
56 }
57
58 ScriptForbiddenIfMainThreadScope::~ScriptForbiddenIfMainThreadScope()
59 {
60 if (isMainThread())
61 ScriptForbiddenScope::exit();
62 }
63 } // namespace blink 13 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/ScriptForbiddenScope.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698