| 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 leveldb { | 18 namespace leveldb { |
| 19 class LevelDBMojoProxy; | 19 class LevelDBMojoProxy; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace prefs { |
| 23 class PersistentPrefStoreClient; |
| 24 } |
| 25 |
| 22 namespace ui { | 26 namespace ui { |
| 23 class Gpu; | 27 class Gpu; |
| 24 } | 28 } |
| 25 | 29 |
| 26 namespace views { | 30 namespace views { |
| 27 class ClipboardMus; | 31 class ClipboardMus; |
| 28 } | 32 } |
| 29 | 33 |
| 30 namespace mojo { | 34 namespace mojo { |
| 31 | 35 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 51 // Inline the empty definitions of functions so that they can be compiled out. | 55 // Inline the empty definitions of functions so that they can be compiled out. |
| 52 static void AssertSyncCallAllowed() {} | 56 static void AssertSyncCallAllowed() {} |
| 53 #endif | 57 #endif |
| 54 | 58 |
| 55 private: | 59 private: |
| 56 // DO NOT ADD ANY OTHER FRIEND STATEMENTS, talk to mojo/OWNERS first. | 60 // DO NOT ADD ANY OTHER FRIEND STATEMENTS, talk to mojo/OWNERS first. |
| 57 // BEGIN ALLOWED USAGE. | 61 // BEGIN ALLOWED USAGE. |
| 58 friend class ui::Gpu; // http://crbug.com/620058 | 62 friend class ui::Gpu; // http://crbug.com/620058 |
| 59 // LevelDBMojoProxy makes same-process sync calls from the DB thread. | 63 // LevelDBMojoProxy makes same-process sync calls from the DB thread. |
| 60 friend class leveldb::LevelDBMojoProxy; | 64 friend class leveldb::LevelDBMojoProxy; |
| 65 // Pref service connection is sync at startup. |
| 66 friend class prefs::PersistentPrefStoreClient; |
| 67 |
| 61 // END ALLOWED USAGE. | 68 // END ALLOWED USAGE. |
| 62 | 69 |
| 63 // BEGIN USAGE THAT NEEDS TO BE FIXED. | 70 // BEGIN USAGE THAT NEEDS TO BE FIXED. |
| 64 // In the non-mus case, we called blocking OS functions in the ui::Clipboard | 71 // In the non-mus case, we called blocking OS functions in the ui::Clipboard |
| 65 // implementation which weren't caught by sync call restrictions. Our blocking | 72 // implementation which weren't caught by sync call restrictions. Our blocking |
| 66 // calls to mus, however, are. | 73 // calls to mus, however, are. |
| 67 friend class views::ClipboardMus; | 74 friend class views::ClipboardMus; |
| 68 // END USAGE THAT NEEDS TO BE FIXED. | 75 // END USAGE THAT NEEDS TO BE FIXED. |
| 69 | 76 |
| 70 #if ENABLE_SYNC_CALL_RESTRICTIONS | 77 #if ENABLE_SYNC_CALL_RESTRICTIONS |
| (...skipping 21 matching lines...) Expand all Loading... |
| 92 | 99 |
| 93 DISALLOW_COPY_AND_ASSIGN(ScopedAllowSyncCall); | 100 DISALLOW_COPY_AND_ASSIGN(ScopedAllowSyncCall); |
| 94 }; | 101 }; |
| 95 | 102 |
| 96 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncCallRestrictions); | 103 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncCallRestrictions); |
| 97 }; | 104 }; |
| 98 | 105 |
| 99 } // namespace mojo | 106 } // namespace mojo |
| 100 | 107 |
| 101 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ | 108 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ |
| OLD | NEW |