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