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

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

Issue 2151933003: Change WTF::TemporaryChange to be an alias for AutoReset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TemporaryChange -> AutoReset Created 4 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
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/Allocator.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/AutoReset.h"
10 #include "wtf/Optional.h" 11 #include "wtf/Optional.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, 15 // Scoped disabling of script execution on the main thread,
16 // and only to be used by the main thread. 16 // and only to be used by the main thread.
17 class PLATFORM_EXPORT ScriptForbiddenScope final { 17 class PLATFORM_EXPORT ScriptForbiddenScope final {
18 STACK_ALLOCATED(); 18 STACK_ALLOCATED();
19 WTF_MAKE_NONCOPYABLE(ScriptForbiddenScope); 19 WTF_MAKE_NONCOPYABLE(ScriptForbiddenScope);
20 public: 20 public:
21 ScriptForbiddenScope(); 21 ScriptForbiddenScope();
22 ~ScriptForbiddenScope(); 22 ~ScriptForbiddenScope();
23 23
24 class PLATFORM_EXPORT AllowUserAgentScript final { 24 class PLATFORM_EXPORT AllowUserAgentScript final {
25 STACK_ALLOCATED(); 25 STACK_ALLOCATED();
26 WTF_MAKE_NONCOPYABLE(AllowUserAgentScript); 26 WTF_MAKE_NONCOPYABLE(AllowUserAgentScript);
27 public: 27 public:
28 AllowUserAgentScript(); 28 AllowUserAgentScript();
29 ~AllowUserAgentScript(); 29 ~AllowUserAgentScript();
30 private: 30 private:
31 Optional<TemporaryChange<unsigned>> m_change; 31 Optional<AutoReset<unsigned>> m_change;
32 }; 32 };
33 33
34 static void enter(); 34 static void enter();
35 static void exit(); 35 static void exit();
36 static bool isScriptForbidden(); 36 static bool isScriptForbidden();
37 }; 37 };
38 38
39 // Scoped disabling of script execution on the main thread, 39 // Scoped disabling of script execution on the main thread,
40 // if called on the main thread. 40 // if called on the main thread.
41 // 41 //
42 // No effect when used by from other threads -- simplifies 42 // No effect when used by from other threads -- simplifies
43 // call sites that might be used by multiple threads to have 43 // call sites that might be used by multiple threads to have
44 // this scope object perform the is-main-thread check on 44 // this scope object perform the is-main-thread check on
45 // its behalf. 45 // its behalf.
46 class PLATFORM_EXPORT ScriptForbiddenIfMainThreadScope final { 46 class PLATFORM_EXPORT ScriptForbiddenIfMainThreadScope final {
47 STACK_ALLOCATED(); 47 STACK_ALLOCATED();
48 WTF_MAKE_NONCOPYABLE(ScriptForbiddenIfMainThreadScope); 48 WTF_MAKE_NONCOPYABLE(ScriptForbiddenIfMainThreadScope);
49 public: 49 public:
50 ScriptForbiddenIfMainThreadScope(); 50 ScriptForbiddenIfMainThreadScope();
51 ~ScriptForbiddenIfMainThreadScope(); 51 ~ScriptForbiddenIfMainThreadScope();
52 }; 52 };
53 53
54 } // namespace blink 54 } // namespace blink
55 55
56 #endif // ScriptForbiddenScope_h 56 #endif // ScriptForbiddenScope_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/LifecycleNotifier.h ('k') | third_party/WebKit/Source/platform/ScriptForbiddenScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698