OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "mojo/public/cpp/bindings/bindings_export.h" | 10 #include "mojo/public/cpp/bindings/bindings_export.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 namespace mojo { | 42 namespace mojo { |
43 | 43 |
44 // In some processes, sync calls are disallowed. For example, in the browser | 44 // In some processes, sync calls are disallowed. For example, in the browser |
45 // process we don't want any sync calls to child processes for performance, | 45 // process we don't want any sync calls to child processes for performance, |
46 // security and stability reasons. SyncCallRestrictions helps to enforce such | 46 // security and stability reasons. SyncCallRestrictions helps to enforce such |
47 // rules. | 47 // rules. |
48 // | 48 // |
49 // Before processing a sync call, the bindings call | 49 // Before processing a sync call, the bindings call |
50 // SyncCallRestrictions::AssertSyncCallAllowed() to check whether sync calls are | 50 // SyncCallRestrictions::AssertSyncCallAllowed() to check whether sync calls are |
51 // allowed. By default, it is determined by the mojo system property | 51 // allowed. By default, it is determined by the mojo system property |
52 // MOJO_PROPERTY_SYNC_CALL_ALLOWED. If the default setting says no but you have | 52 // MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED. If the default setting says no but you |
53 // a very compelling reason to disregard that (which should be very very rare), | 53 // have a very compelling reason to disregard that (which should be very very |
54 // you can override it by constructing a ScopedAllowSyncCall object, which | 54 // rare), you can override it by constructing a ScopedAllowSyncCall object, |
55 // allows making sync calls on the current thread during its lifetime. | 55 // which allows making sync calls on the current thread during its lifetime. |
56 class MOJO_CPP_BINDINGS_EXPORT SyncCallRestrictions { | 56 class MOJO_CPP_BINDINGS_EXPORT SyncCallRestrictions { |
57 public: | 57 public: |
58 #if ENABLE_SYNC_CALL_RESTRICTIONS | 58 #if ENABLE_SYNC_CALL_RESTRICTIONS |
59 // Checks whether the current thread is allowed to make sync calls, and causes | 59 // Checks whether the current thread is allowed to make sync calls, and causes |
60 // a DCHECK if not. | 60 // a DCHECK if not. |
61 static void AssertSyncCallAllowed(); | 61 static void AssertSyncCallAllowed(); |
62 #else | 62 #else |
63 // Inline the empty definitions of functions so that they can be compiled out. | 63 // Inline the empty definitions of functions so that they can be compiled out. |
64 static void AssertSyncCallAllowed() {} | 64 static void AssertSyncCallAllowed() {} |
65 #endif | 65 #endif |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 DISALLOW_COPY_AND_ASSIGN(ScopedAllowSyncCall); | 113 DISALLOW_COPY_AND_ASSIGN(ScopedAllowSyncCall); |
114 }; | 114 }; |
115 | 115 |
116 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncCallRestrictions); | 116 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncCallRestrictions); |
117 }; | 117 }; |
118 | 118 |
119 } // namespace mojo | 119 } // namespace mojo |
120 | 120 |
121 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ | 121 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ |
OLD | NEW |