battre@chromium.org | 7d937d4 | 2012-04-27 22:55:40 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
brettw@chromium.org | 5b5f5e0 | 2011-01-01 10:01:06 +0900 | [diff] [blame] | 5 | #ifndef BASE_THREADING_THREAD_RESTRICTIONS_H_ |
| 6 | #define BASE_THREADING_THREAD_RESTRICTIONS_H_ |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 7 | |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 8 | #include "base/base_export.h" |
evan@chromium.org | 7c9cd8b | 2010-10-23 14:19:20 +0900 | [diff] [blame] | 9 | #include "base/basictypes.h" |
| 10 | |
jam@chromium.org | 605d18a | 2012-06-26 12:53:37 +0900 | [diff] [blame] | 11 | // See comment at top of thread_checker.h |
| 12 | #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
| 13 | #define ENABLE_THREAD_RESTRICTIONS 1 |
| 14 | #else |
| 15 | #define ENABLE_THREAD_RESTRICTIONS 0 |
| 16 | #endif |
| 17 | |
jam@chromium.org | 786c0b1 | 2012-04-27 03:03:58 +0900 | [diff] [blame] | 18 | class BrowserProcessImpl; |
jam@chromium.org | d36f607 | 2012-04-28 03:28:36 +0900 | [diff] [blame] | 19 | class HistogramSynchronizer; |
jam@chromium.org | 67ff239 | 2012-04-28 01:42:17 +0900 | [diff] [blame] | 20 | class NativeBackendKWallet; |
tedchoc@chromium.org | 00e5e7d | 2012-09-07 14:43:10 +0900 | [diff] [blame] | 21 | class ScopedAllowWaitForLegacyWebViewApi; |
kevers@chromium.org | 7439c76 | 2012-04-28 00:07:37 +0900 | [diff] [blame] | 22 | |
backer@chromium.org | 6c9aa30 | 2012-10-16 06:22:26 +0900 | [diff] [blame] | 23 | namespace cc { |
enne@chromium.org | 531e69e | 2012-10-23 08:09:55 +0900 | [diff] [blame] | 24 | class CompletionEvent; |
weiliangc | 0965f11 | 2015-02-27 03:33:09 +0900 | [diff] [blame] | 25 | class TaskGraphRunner; |
backer@chromium.org | 6c9aa30 | 2012-10-16 06:22:26 +0900 | [diff] [blame] | 26 | } |
jam@chromium.org | 786c0b1 | 2012-04-27 03:03:58 +0900 | [diff] [blame] | 27 | namespace chromeos { |
jam@chromium.org | 67ff239 | 2012-04-28 01:42:17 +0900 | [diff] [blame] | 28 | class BlockingMethodCaller; |
jam@chromium.org | 3593947 | 2012-04-28 05:29:19 +0900 | [diff] [blame] | 29 | namespace system { |
| 30 | class StatisticsProviderImpl; |
| 31 | } |
jam@chromium.org | 786c0b1 | 2012-04-27 03:03:58 +0900 | [diff] [blame] | 32 | } |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 33 | namespace chrome_browser_net { |
| 34 | class Predictor; |
| 35 | } |
mazda@chromium.org | 509d635 | 2012-04-28 05:46:47 +0900 | [diff] [blame] | 36 | namespace content { |
| 37 | class BrowserGpuChannelHostFactory; |
reveman | 8085139 | 2014-10-14 05:52:05 +0900 | [diff] [blame] | 38 | class BrowserGpuMemoryBufferManager; |
wangxianzhu@chromium.org | 47df845 | 2013-09-18 17:15:46 +0900 | [diff] [blame] | 39 | class BrowserShutdownProfileDumper; |
nileshagrawal@chromium.org | eaeda1f | 2013-02-05 07:33:17 +0900 | [diff] [blame] | 40 | class BrowserTestBase; |
jam@chromium.org | 8a7e754 | 2012-10-23 05:16:19 +0900 | [diff] [blame] | 41 | class GpuChannelHost; |
mnissler@chromium.org | a807b7b | 2013-09-04 03:11:10 +0900 | [diff] [blame] | 42 | class NestedMessagePumpAndroid; |
peter@chromium.org | e1a4470 | 2013-06-21 05:02:21 +0900 | [diff] [blame] | 43 | class ScopedAllowWaitForAndroidLayoutTests; |
erikwright | 7458790 | 2015-04-23 23:35:20 +0900 | [diff] [blame] | 44 | class ScopedAllowWaitForDebugURL; |
rjkroege | 36fbab2 | 2015-11-19 10:40:47 +0900 | [diff] [blame] | 45 | class SoftwareOutputDeviceMus; |
jam@chromium.org | 8ff1945 | 2012-10-30 04:35:57 +0900 | [diff] [blame] | 46 | class TextInputClientMac; |
danakj | 651c3e2 | 2015-03-07 10:51:42 +0900 | [diff] [blame] | 47 | } // namespace content |
jam@chromium.org | 1755434 | 2012-04-27 04:08:58 +0900 | [diff] [blame] | 48 | namespace dbus { |
| 49 | class Bus; |
| 50 | } |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 51 | namespace disk_cache { |
| 52 | class BackendImpl; |
| 53 | class InFlightIO; |
| 54 | } |
ben | 05888ea | 2015-11-10 16:56:16 +0900 | [diff] [blame] | 55 | namespace gles2 { |
| 56 | class CommandBufferClientImpl; |
| 57 | } |
sky@chromium.org | 84326df | 2014-07-24 23:57:28 +0900 | [diff] [blame] | 58 | namespace mojo { |
| 59 | namespace common { |
| 60 | class WatcherThreadManager; |
| 61 | } |
| 62 | } |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 63 | namespace net { |
esprehn | f4a9f68 | 2015-06-19 08:23:07 +0900 | [diff] [blame] | 64 | class NetworkChangeNotifierMac; |
pauljensen@chromium.org | 6e72191 | 2012-11-30 02:11:55 +0900 | [diff] [blame] | 65 | namespace internal { |
| 66 | class AddressTrackerLinux; |
| 67 | } |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 68 | } |
| 69 | |
wez@chromium.org | 4b67b1f | 2012-10-10 12:56:12 +0900 | [diff] [blame] | 70 | namespace remoting { |
| 71 | class AutoThread; |
| 72 | } |
| 73 | |
tapted | ef61c04 | 2015-09-24 11:51:02 +0900 | [diff] [blame] | 74 | namespace ui { |
| 75 | class WindowResizeHelperMac; |
| 76 | } |
| 77 | |
sadrul | de03688 | 2015-11-24 04:25:16 +0900 | [diff] [blame^] | 78 | namespace views { |
| 79 | class WindowManagerConnection; |
| 80 | } |
| 81 | |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 82 | namespace base { |
| 83 | |
kristianm@chromium.org | a78bfa9 | 2013-08-08 10:31:52 +0900 | [diff] [blame] | 84 | namespace android { |
| 85 | class JavaHandlerThread; |
| 86 | } |
| 87 | |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 88 | class SequencedWorkerPool; |
| 89 | class SimpleThread; |
| 90 | class Thread; |
| 91 | class ThreadTestHelper; |
| 92 | |
willchan@chromium.org | 25726ef | 2010-11-20 05:34:18 +0900 | [diff] [blame] | 93 | // Certain behavior is disallowed on certain threads. ThreadRestrictions helps |
| 94 | // enforce these rules. Examples of such rules: |
| 95 | // |
| 96 | // * Do not do blocking IO (makes the thread janky) |
| 97 | // * Do not access Singleton/LazyInstance (may lead to shutdown crashes) |
| 98 | // |
| 99 | // Here's more about how the protection works: |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 100 | // |
| 101 | // 1) If a thread should not be allowed to make IO calls, mark it: |
| 102 | // base::ThreadRestrictions::SetIOAllowed(false); |
| 103 | // By default, threads *are* allowed to make IO calls. |
| 104 | // In Chrome browser code, IO calls should be proxied to the File thread. |
| 105 | // |
| 106 | // 2) If a function makes a call that will go out to disk, check whether the |
| 107 | // current thread is allowed: |
| 108 | // base::ThreadRestrictions::AssertIOAllowed(); |
| 109 | // |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 110 | // |
evan@chromium.org | 7c9cd8b | 2010-10-23 14:19:20 +0900 | [diff] [blame] | 111 | // Style tip: where should you put AssertIOAllowed checks? It's best |
| 112 | // if you put them as close to the disk access as possible, at the |
| 113 | // lowest level. This rule is simple to follow and helps catch all |
| 114 | // callers. For example, if your function GoDoSomeBlockingDiskCall() |
| 115 | // only calls other functions in Chrome and not fopen(), you should go |
| 116 | // add the AssertIOAllowed checks in the helper functions. |
| 117 | |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 118 | class BASE_EXPORT ThreadRestrictions { |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 119 | public: |
evan@chromium.org | 7c9cd8b | 2010-10-23 14:19:20 +0900 | [diff] [blame] | 120 | // Constructing a ScopedAllowIO temporarily allows IO for the current |
evan@chromium.org | 0f5557b | 2010-11-02 05:31:45 +0900 | [diff] [blame] | 121 | // thread. Doing this is almost certainly always incorrect. |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 122 | class BASE_EXPORT ScopedAllowIO { |
evan@chromium.org | 7c9cd8b | 2010-10-23 14:19:20 +0900 | [diff] [blame] | 123 | public: |
| 124 | ScopedAllowIO() { previous_value_ = SetIOAllowed(true); } |
| 125 | ~ScopedAllowIO() { SetIOAllowed(previous_value_); } |
| 126 | private: |
| 127 | // Whether IO is allowed when the ScopedAllowIO was constructed. |
| 128 | bool previous_value_; |
| 129 | |
| 130 | DISALLOW_COPY_AND_ASSIGN(ScopedAllowIO); |
| 131 | }; |
evan@chromium.org | c45c127 | 2010-10-23 08:44:17 +0900 | [diff] [blame] | 132 | |
willchan@chromium.org | 25726ef | 2010-11-20 05:34:18 +0900 | [diff] [blame] | 133 | // Constructing a ScopedAllowSingleton temporarily allows accessing for the |
| 134 | // current thread. Doing this is almost always incorrect. |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 135 | class BASE_EXPORT ScopedAllowSingleton { |
willchan@chromium.org | 25726ef | 2010-11-20 05:34:18 +0900 | [diff] [blame] | 136 | public: |
| 137 | ScopedAllowSingleton() { previous_value_ = SetSingletonAllowed(true); } |
| 138 | ~ScopedAllowSingleton() { SetSingletonAllowed(previous_value_); } |
| 139 | private: |
| 140 | // Whether singleton use is allowed when the ScopedAllowSingleton was |
| 141 | // constructed. |
| 142 | bool previous_value_; |
| 143 | |
| 144 | DISALLOW_COPY_AND_ASSIGN(ScopedAllowSingleton); |
| 145 | }; |
| 146 | |
jam@chromium.org | 6f34948 | 2012-06-27 06:47:57 +0900 | [diff] [blame] | 147 | #if ENABLE_THREAD_RESTRICTIONS |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 148 | // Set whether the current thread to make IO calls. |
| 149 | // Threads start out in the *allowed* state. |
evan@chromium.org | 7c9cd8b | 2010-10-23 14:19:20 +0900 | [diff] [blame] | 150 | // Returns the previous value. |
| 151 | static bool SetIOAllowed(bool allowed); |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 152 | |
| 153 | // Check whether the current thread is allowed to make IO calls, |
evan@chromium.org | 7c9cd8b | 2010-10-23 14:19:20 +0900 | [diff] [blame] | 154 | // and DCHECK if not. See the block comment above the class for |
| 155 | // a discussion of where to add these checks. |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 156 | static void AssertIOAllowed(); |
willchan@chromium.org | 25726ef | 2010-11-20 05:34:18 +0900 | [diff] [blame] | 157 | |
| 158 | // Set whether the current thread can use singletons. Returns the previous |
| 159 | // value. |
| 160 | static bool SetSingletonAllowed(bool allowed); |
| 161 | |
| 162 | // Check whether the current thread is allowed to use singletons (Singleton / |
| 163 | // LazyInstance). DCHECKs if not. |
| 164 | static void AssertSingletonAllowed(); |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 165 | |
| 166 | // Disable waiting on the current thread. Threads start out in the *allowed* |
| 167 | // state. Returns the previous value. |
| 168 | static void DisallowWaiting(); |
| 169 | |
| 170 | // Check whether the current thread is allowed to wait, and DCHECK if not. |
| 171 | static void AssertWaitAllowed(); |
evan@chromium.org | c45c127 | 2010-10-23 08:44:17 +0900 | [diff] [blame] | 172 | #else |
jam@chromium.org | 605d18a | 2012-06-26 12:53:37 +0900 | [diff] [blame] | 173 | // Inline the empty definitions of these functions so that they can be |
| 174 | // compiled out. |
evan@chromium.org | 7c9cd8b | 2010-10-23 14:19:20 +0900 | [diff] [blame] | 175 | static bool SetIOAllowed(bool allowed) { return true; } |
evan@chromium.org | c45c127 | 2010-10-23 08:44:17 +0900 | [diff] [blame] | 176 | static void AssertIOAllowed() {} |
willchan@chromium.org | 25726ef | 2010-11-20 05:34:18 +0900 | [diff] [blame] | 177 | static bool SetSingletonAllowed(bool allowed) { return true; } |
| 178 | static void AssertSingletonAllowed() {} |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 179 | static void DisallowWaiting() {} |
| 180 | static void AssertWaitAllowed() {} |
evan@chromium.org | c45c127 | 2010-10-23 08:44:17 +0900 | [diff] [blame] | 181 | #endif |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 182 | |
| 183 | private: |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 184 | // DO NOT ADD ANY OTHER FRIEND STATEMENTS, talk to jam or brettw first. |
| 185 | // BEGIN ALLOWED USAGE. |
wangxianzhu@chromium.org | 47df845 | 2013-09-18 17:15:46 +0900 | [diff] [blame] | 186 | friend class content::BrowserShutdownProfileDumper; |
nileshagrawal@chromium.org | eaeda1f | 2013-02-05 07:33:17 +0900 | [diff] [blame] | 187 | friend class content::BrowserTestBase; |
mnissler@chromium.org | a807b7b | 2013-09-04 03:11:10 +0900 | [diff] [blame] | 188 | friend class content::NestedMessagePumpAndroid; |
peter@chromium.org | e1a4470 | 2013-06-21 05:02:21 +0900 | [diff] [blame] | 189 | friend class content::ScopedAllowWaitForAndroidLayoutTests; |
erikwright | 7458790 | 2015-04-23 23:35:20 +0900 | [diff] [blame] | 190 | friend class content::ScopedAllowWaitForDebugURL; |
jam@chromium.org | d36f607 | 2012-04-28 03:28:36 +0900 | [diff] [blame] | 191 | friend class ::HistogramSynchronizer; |
tedchoc@chromium.org | 00e5e7d | 2012-09-07 14:43:10 +0900 | [diff] [blame] | 192 | friend class ::ScopedAllowWaitForLegacyWebViewApi; |
enne@chromium.org | 531e69e | 2012-10-23 08:09:55 +0900 | [diff] [blame] | 193 | friend class cc::CompletionEvent; |
weiliangc | 0965f11 | 2015-02-27 03:33:09 +0900 | [diff] [blame] | 194 | friend class cc::TaskGraphRunner; |
sky@chromium.org | 84326df | 2014-07-24 23:57:28 +0900 | [diff] [blame] | 195 | friend class mojo::common::WatcherThreadManager; |
wez@chromium.org | 4b67b1f | 2012-10-10 12:56:12 +0900 | [diff] [blame] | 196 | friend class remoting::AutoThread; |
tapted | ef61c04 | 2015-09-24 11:51:02 +0900 | [diff] [blame] | 197 | friend class ui::WindowResizeHelperMac; |
scherkus@chromium.org | f967285 | 2012-11-14 11:47:50 +0900 | [diff] [blame] | 198 | friend class MessagePumpDefault; |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 199 | friend class SequencedWorkerPool; |
| 200 | friend class SimpleThread; |
| 201 | friend class Thread; |
| 202 | friend class ThreadTestHelper; |
epenner@chromium.org | ed1c9ba | 2013-05-22 09:01:38 +0900 | [diff] [blame] | 203 | friend class PlatformThread; |
kristianm@chromium.org | a78bfa9 | 2013-08-08 10:31:52 +0900 | [diff] [blame] | 204 | friend class android::JavaHandlerThread; |
ben | 05888ea | 2015-11-10 16:56:16 +0900 | [diff] [blame] | 205 | friend class gles2::CommandBufferClientImpl; |
wez@chromium.org | 4b67b1f | 2012-10-10 12:56:12 +0900 | [diff] [blame] | 206 | |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 207 | // END ALLOWED USAGE. |
| 208 | // BEGIN USAGE THAT NEEDS TO BE FIXED. |
jam@chromium.org | 67ff239 | 2012-04-28 01:42:17 +0900 | [diff] [blame] | 209 | friend class ::chromeos::BlockingMethodCaller; // http://crbug.com/125360 |
jam@chromium.org | 3593947 | 2012-04-28 05:29:19 +0900 | [diff] [blame] | 210 | friend class ::chromeos::system::StatisticsProviderImpl; // http://crbug.com/125385 |
jam@chromium.org | 67ff239 | 2012-04-28 01:42:17 +0900 | [diff] [blame] | 211 | friend class chrome_browser_net::Predictor; // http://crbug.com/78451 |
mazda@chromium.org | 509d635 | 2012-04-28 05:46:47 +0900 | [diff] [blame] | 212 | friend class |
| 213 | content::BrowserGpuChannelHostFactory; // http://crbug.com/125248 |
reveman | 8085139 | 2014-10-14 05:52:05 +0900 | [diff] [blame] | 214 | friend class |
| 215 | content::BrowserGpuMemoryBufferManager; // http://crbug.com/420368 |
jam@chromium.org | 8a7e754 | 2012-10-23 05:16:19 +0900 | [diff] [blame] | 216 | friend class content::GpuChannelHost; // http://crbug.com/125264 |
jam@chromium.org | 8ff1945 | 2012-10-30 04:35:57 +0900 | [diff] [blame] | 217 | friend class content::TextInputClientMac; // http://crbug.com/121917 |
jam@chromium.org | 67ff239 | 2012-04-28 01:42:17 +0900 | [diff] [blame] | 218 | friend class dbus::Bus; // http://crbug.com/125222 |
| 219 | friend class disk_cache::BackendImpl; // http://crbug.com/74623 |
| 220 | friend class disk_cache::InFlightIO; // http://crbug.com/74623 |
pauljensen@chromium.org | 6e72191 | 2012-11-30 02:11:55 +0900 | [diff] [blame] | 221 | friend class net::internal::AddressTrackerLinux; // http://crbug.com/125097 |
thakis | 879553f | 2015-06-26 00:30:55 +0900 | [diff] [blame] | 222 | friend class net::NetworkChangeNotifierMac; // http://crbug.com/125097 |
jam@chromium.org | 67ff239 | 2012-04-28 01:42:17 +0900 | [diff] [blame] | 223 | friend class ::BrowserProcessImpl; // http://crbug.com/125207 |
jam@chromium.org | 67ff239 | 2012-04-28 01:42:17 +0900 | [diff] [blame] | 224 | friend class ::NativeBackendKWallet; // http://crbug.com/125331 |
rjkroege | 36fbab2 | 2015-11-19 10:40:47 +0900 | [diff] [blame] | 225 | #if !defined(OFFICIAL_BUILD) |
| 226 | friend class content::SoftwareOutputDeviceMus; // Interim non-production code |
sadrul | de03688 | 2015-11-24 04:25:16 +0900 | [diff] [blame^] | 227 | friend class views::WindowManagerConnection; |
rjkroege | 36fbab2 | 2015-11-19 10:40:47 +0900 | [diff] [blame] | 228 | #endif |
| 229 | // END USAGE THAT NEEDS TO BE FIXED. |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 230 | |
jam@chromium.org | 6f34948 | 2012-06-27 06:47:57 +0900 | [diff] [blame] | 231 | #if ENABLE_THREAD_RESTRICTIONS |
jam@chromium.org | 8ed4614 | 2012-04-27 01:34:16 +0900 | [diff] [blame] | 232 | static bool SetWaitAllowed(bool allowed); |
| 233 | #else |
| 234 | static bool SetWaitAllowed(bool allowed) { return true; } |
| 235 | #endif |
| 236 | |
| 237 | // Constructing a ScopedAllowWait temporarily allows waiting on the current |
| 238 | // thread. Doing this is almost always incorrect, which is why we limit who |
| 239 | // can use this through friend. If you find yourself needing to use this, find |
| 240 | // another way. Talk to jam or brettw. |
| 241 | class BASE_EXPORT ScopedAllowWait { |
| 242 | public: |
| 243 | ScopedAllowWait() { previous_value_ = SetWaitAllowed(true); } |
| 244 | ~ScopedAllowWait() { SetWaitAllowed(previous_value_); } |
| 245 | private: |
| 246 | // Whether singleton use is allowed when the ScopedAllowWait was |
| 247 | // constructed. |
| 248 | bool previous_value_; |
| 249 | |
| 250 | DISALLOW_COPY_AND_ASSIGN(ScopedAllowWait); |
| 251 | }; |
| 252 | |
willchan@chromium.org | 25726ef | 2010-11-20 05:34:18 +0900 | [diff] [blame] | 253 | DISALLOW_IMPLICIT_CONSTRUCTORS(ThreadRestrictions); |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 254 | }; |
| 255 | |
evan@chromium.org | e450cfc | 2010-10-20 05:28:03 +0900 | [diff] [blame] | 256 | } // namespace base |
| 257 | |
brettw@chromium.org | 5b5f5e0 | 2011-01-01 10:01:06 +0900 | [diff] [blame] | 258 | #endif // BASE_THREADING_THREAD_RESTRICTIONS_H_ |