| 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_handle_registry.h" | 5 #include "mojo/public/cpp/bindings/sync_handle_registry.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| 11 #include "mojo/public/c/system/core.h" | 11 #include "mojo/public/c/system/core.h" |
| 12 | 12 |
| 13 namespace mojo { | 13 namespace mojo { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 base::LazyInstance<base::ThreadLocalPointer<SyncHandleRegistry>> | 16 base::LazyInstance<base::ThreadLocalPointer<SyncHandleRegistry>>::Leaky |
| 17 g_current_sync_handle_watcher = LAZY_INSTANCE_INITIALIZER; | 17 g_current_sync_handle_watcher = LAZY_INSTANCE_INITIALIZER; |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 // static | 21 // static |
| 22 scoped_refptr<SyncHandleRegistry> SyncHandleRegistry::current() { | 22 scoped_refptr<SyncHandleRegistry> SyncHandleRegistry::current() { |
| 23 scoped_refptr<SyncHandleRegistry> result( | 23 scoped_refptr<SyncHandleRegistry> result( |
| 24 g_current_sync_handle_watcher.Pointer()->Get()); | 24 g_current_sync_handle_watcher.Pointer()->Get()); |
| 25 if (!result) { | 25 if (!result) { |
| 26 result = new SyncHandleRegistry(); | 26 result = new SyncHandleRegistry(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return; | 117 return; |
| 118 | 118 |
| 119 // If this breaks, it is likely that the global variable is bulit into and | 119 // If this breaks, it is likely that the global variable is bulit into and |
| 120 // accessed from multiple modules. | 120 // accessed from multiple modules. |
| 121 DCHECK_EQ(this, g_current_sync_handle_watcher.Pointer()->Get()); | 121 DCHECK_EQ(this, g_current_sync_handle_watcher.Pointer()->Get()); |
| 122 | 122 |
| 123 g_current_sync_handle_watcher.Pointer()->Set(nullptr); | 123 g_current_sync_handle_watcher.Pointer()->Set(nullptr); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace mojo | 126 } // namespace mojo |
| OLD | NEW |