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

Side by Side Diff: Source/core/dom/ScriptForbiddenScope.cpp

Issue 368853002: Add ScriptForbiddenScope to weak callbacks of DOM wrappers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/core/v8/ScriptWrappable.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 "config.h" 5 #include "config.h"
6 #include "core/dom/ScriptForbiddenScope.h" 6 #include "core/dom/ScriptForbiddenScope.h"
7 7
8 #include "wtf/Assertions.h" 8 #include "wtf/Assertions.h"
9 #include "wtf/MainThread.h" 9 #include "wtf/MainThread.h"
10 10
11 namespace WebCore { 11 namespace WebCore {
12 12
13 #if ASSERT_ENABLED 13 #if ASSERT_ENABLED
14 14
15 static unsigned s_scriptForbiddenCount = 0; 15 static unsigned s_scriptForbiddenCount = 0;
16 16
17 ScriptForbiddenScope::ScriptForbiddenScope() 17 ScriptForbiddenScope::ScriptForbiddenScope()
18 { 18 {
19 ASSERT(isMainThread()); 19 // FIXME: Support non-main threads.
20 ++s_scriptForbiddenCount; 20 if (isMainThread())
haraken 2014/07/03 01:56:19 Since ScriptWrappable and DOMWrapperMap are used i
21 ++s_scriptForbiddenCount;
21 } 22 }
22 23
23 ScriptForbiddenScope::~ScriptForbiddenScope() 24 ScriptForbiddenScope::~ScriptForbiddenScope()
24 { 25 {
25 ASSERT(isMainThread()); 26 if (isMainThread())
26 --s_scriptForbiddenCount; 27 --s_scriptForbiddenCount;
27 } 28 }
28 29
29 bool ScriptForbiddenScope::isScriptForbidden() 30 bool ScriptForbiddenScope::isScriptForbidden()
30 { 31 {
31 return isMainThread() && s_scriptForbiddenCount; 32 return isMainThread() && s_scriptForbiddenCount;
32 } 33 }
33 34
34 ScriptForbiddenScope::AllowUserAgentScript::AllowUserAgentScript() 35 ScriptForbiddenScope::AllowUserAgentScript::AllowUserAgentScript()
35 : m_change(s_scriptForbiddenCount, 0) 36 : m_change(s_scriptForbiddenCount, 0)
36 { 37 {
37 } 38 }
38 39
39 ScriptForbiddenScope::AllowUserAgentScript::~AllowUserAgentScript() 40 ScriptForbiddenScope::AllowUserAgentScript::~AllowUserAgentScript()
40 { 41 {
41 ASSERT(!s_scriptForbiddenCount); 42 ASSERT(!s_scriptForbiddenCount);
42 } 43 }
43 44
44 #endif 45 #endif
45 46
46 } // namespace WebCore 47 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptWrappable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698