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.h

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 unified diff | Download patch
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 #ifndef ScriptForbiddenScope_h 5 #ifndef ScriptForbiddenScope_h
6 #define ScriptForbiddenScope_h 6 #define ScriptForbiddenScope_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "wtf/Assertions.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/Optional.h" 10 #include "wtf/Optional.h"
11 #include "wtf/TemporaryChange.h" 11 #include "wtf/TemporaryChange.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 // Scoped disabling of script execution on the main thread,
16 // and only to be used by the main thread.
15 class PLATFORM_EXPORT ScriptForbiddenScope { 17 class PLATFORM_EXPORT ScriptForbiddenScope {
18 STACK_ALLOCATED();
16 public: 19 public:
17 ScriptForbiddenScope(); 20 ScriptForbiddenScope();
18 ~ScriptForbiddenScope(); 21 ~ScriptForbiddenScope();
19 22
20 class PLATFORM_EXPORT AllowUserAgentScript { 23 class PLATFORM_EXPORT AllowUserAgentScript {
21 public: 24 public:
22 AllowUserAgentScript(); 25 AllowUserAgentScript();
23 ~AllowUserAgentScript(); 26 ~AllowUserAgentScript();
24 private: 27 private:
25 Optional<TemporaryChange<unsigned>> m_change; 28 Optional<TemporaryChange<unsigned>> m_change;
26 }; 29 };
27 30
28 static void enter(); 31 static void enter();
29 static void exit(); 32 static void exit();
30 static bool isScriptForbidden(); 33 static bool isScriptForbidden();
31 }; 34 };
32 35
36 // Scoped disabling of script execution on the main thread,
37 // if called on the main thread.
38 //
39 // No effect when used by from other threads -- simplifies
40 // call sites that might be used by multiple threads to have
41 // this scope object perform the is-main-thread check on
42 // its behalf.
43 class PLATFORM_EXPORT ScriptForbiddenIfMainThreadScope {
44 STACK_ALLOCATED();
45 public:
46 ScriptForbiddenIfMainThreadScope();
47 ~ScriptForbiddenIfMainThreadScope();
48 };
49
33 } // namespace blink 50 } // namespace blink
34 51
35 #endif // ScriptForbiddenScope_h 52 #endif // ScriptForbiddenScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698