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 | 10 |
11 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) | 11 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
12 #define ENABLE_SYNC_CALL_RESTRICTIONS 1 | 12 #define ENABLE_SYNC_CALL_RESTRICTIONS 1 |
13 #else | 13 #else |
14 #define ENABLE_SYNC_CALL_RESTRICTIONS 0 | 14 #define ENABLE_SYNC_CALL_RESTRICTIONS 0 |
15 #endif | 15 #endif |
16 | 16 |
17 namespace mus { | |
18 class GpuService; | |
19 } | |
20 | |
21 namespace views { | 17 namespace views { |
22 class ClipboardMus; | 18 class ClipboardMus; |
23 } | 19 } |
24 | 20 |
25 namespace mojo { | 21 namespace mojo { |
26 | 22 |
27 // In some processes, sync calls are disallowed. For example, in the browser | 23 // In some processes, sync calls are disallowed. For example, in the browser |
28 // process we don't want any sync calls to child processes for performance, | 24 // process we don't want any sync calls to child processes for performance, |
29 // security and stability reasons. SyncCallRestrictions helps to enforce such | 25 // security and stability reasons. SyncCallRestrictions helps to enforce such |
30 // rules. | 26 // rules. |
(...skipping 12 matching lines...) Expand all Loading... |
43 // a DCHECK if not. | 39 // a DCHECK if not. |
44 static void AssertSyncCallAllowed(); | 40 static void AssertSyncCallAllowed(); |
45 #else | 41 #else |
46 // Inline the empty definitions of functions so that they can be compiled out. | 42 // Inline the empty definitions of functions so that they can be compiled out. |
47 static void AssertSyncCallAllowed() {} | 43 static void AssertSyncCallAllowed() {} |
48 #endif | 44 #endif |
49 | 45 |
50 private: | 46 private: |
51 // DO NOT ADD ANY OTHER FRIEND STATEMENTS, talk to mojo/OWNERS first. | 47 // DO NOT ADD ANY OTHER FRIEND STATEMENTS, talk to mojo/OWNERS first. |
52 // BEGIN ALLOWED USAGE. | 48 // BEGIN ALLOWED USAGE. |
53 friend class mus::GpuService; // http://crbug.com/620058 | |
54 // END ALLOWED USAGE. | 49 // END ALLOWED USAGE. |
55 | 50 |
56 // BEGIN USAGE THAT NEEDS TO BE FIXED. | 51 // BEGIN USAGE THAT NEEDS TO BE FIXED. |
57 // In the non-mus case, we called blocking OS functions in the ui::Clipboard | 52 // In the non-mus case, we called blocking OS functions in the ui::Clipboard |
58 // implementation which weren't caught by sync call restrictions. Our blocking | 53 // implementation which weren't caught by sync call restrictions. Our blocking |
59 // calls to mus, however, are. | 54 // calls to mus, however, are. |
60 friend class views::ClipboardMus; | 55 friend class views::ClipboardMus; |
61 // END USAGE THAT NEEDS TO BE FIXED. | 56 // END USAGE THAT NEEDS TO BE FIXED. |
62 | 57 |
63 #if ENABLE_SYNC_CALL_RESTRICTIONS | 58 #if ENABLE_SYNC_CALL_RESTRICTIONS |
(...skipping 21 matching lines...) Expand all Loading... |
85 | 80 |
86 DISALLOW_COPY_AND_ASSIGN(ScopedAllowSyncCall); | 81 DISALLOW_COPY_AND_ASSIGN(ScopedAllowSyncCall); |
87 }; | 82 }; |
88 | 83 |
89 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncCallRestrictions); | 84 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncCallRestrictions); |
90 }; | 85 }; |
91 | 86 |
92 } // namespace mojo | 87 } // namespace mojo |
93 | 88 |
94 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ | 89 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ |
OLD | NEW |