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 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" | 5 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" |
6 | 6 |
7 #if ENABLE_SYNC_CALL_RESTRICTIONS | 7 #if ENABLE_SYNC_CALL_RESTRICTIONS |
8 | 8 |
9 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
34 SyncCallSettings(); | 34 SyncCallSettings(); |
35 ~SyncCallSettings(); | 35 ~SyncCallSettings(); |
36 | 36 |
37 bool system_defined_value_ = true; | 37 bool system_defined_value_ = true; |
38 size_t scoped_allow_count_ = 0; | 38 size_t scoped_allow_count_ = 0; |
39 }; | 39 }; |
40 | 40 |
41 base::LazyInstance<base::ThreadLocalPointer<SyncCallSettings>> | 41 base::LazyInstance<base::ThreadLocalPointer<SyncCallSettings>>::DestructorAtExit |
42 g_sync_call_settings = LAZY_INSTANCE_INITIALIZER; | 42 g_sync_call_settings = LAZY_INSTANCE_INITIALIZER; |
43 | 43 |
44 // static | 44 // static |
45 SyncCallSettings* SyncCallSettings::current() { | 45 SyncCallSettings* SyncCallSettings::current() { |
46 SyncCallSettings* result = g_sync_call_settings.Pointer()->Get(); | 46 SyncCallSettings* result = g_sync_call_settings.Pointer()->Get(); |
47 if (!result) { | 47 if (!result) { |
48 result = new SyncCallSettings(); | 48 result = new SyncCallSettings(); |
49 ANNOTATE_LEAKING_OBJECT_PTR(result); | 49 ANNOTATE_LEAKING_OBJECT_PTR(result); |
50 DCHECK_EQ(result, g_sync_call_settings.Pointer()->Get()); | 50 DCHECK_EQ(result, g_sync_call_settings.Pointer()->Get()); |
51 } | 51 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 // static | 86 // static |
87 void SyncCallRestrictions::DecreaseScopedAllowCount() { | 87 void SyncCallRestrictions::DecreaseScopedAllowCount() { |
88 SyncCallSettings::current()->DecreaseScopedAllowCount(); | 88 SyncCallSettings::current()->DecreaseScopedAllowCount(); |
89 } | 89 } |
90 | 90 |
91 } // namespace mojo | 91 } // namespace mojo |
92 | 92 |
93 #endif // ENABLE_SYNC_CALL_RESTRICTIONS | 93 #endif // ENABLE_SYNC_CALL_RESTRICTIONS |
OLD | NEW |