| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/child/child_io_surface_manager_mac.h" | 5 #include "content/child/child_io_surface_manager_mac.h" |
| 6 | 6 |
| 7 #include "base/mac/mach_logging.h" | 7 #include "base/mac/mach_logging.h" |
| 8 #include "base/threading/thread_restrictions.h" |
| 8 #include "content/common/mac/io_surface_manager_messages.h" | 9 #include "content/common/mac/io_surface_manager_messages.h" |
| 9 | 10 |
| 10 namespace content { | 11 namespace content { |
| 11 | 12 |
| 12 // static | 13 // static |
| 13 ChildIOSurfaceManager* ChildIOSurfaceManager::GetInstance() { | 14 ChildIOSurfaceManager* ChildIOSurfaceManager::GetInstance() { |
| 14 return Singleton<ChildIOSurfaceManager, | 15 return Singleton<ChildIOSurfaceManager, |
| 15 LeakySingletonTraits<ChildIOSurfaceManager>>::get(); | 16 LeakySingletonTraits<ChildIOSurfaceManager>>::get(); |
| 16 } | 17 } |
| 17 | 18 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 MACH_LOG(ERROR, kr) << "mach_msg"; | 90 MACH_LOG(ERROR, kr) << "mach_msg"; |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 | 93 |
| 93 IOSurfaceRef ChildIOSurfaceManager::AcquireIOSurface( | 94 IOSurfaceRef ChildIOSurfaceManager::AcquireIOSurface( |
| 94 IOSurfaceId io_surface_id) { | 95 IOSurfaceId io_surface_id) { |
| 95 DCHECK(service_port_.is_valid()); | 96 DCHECK(service_port_.is_valid()); |
| 96 | 97 |
| 97 // A valid token is required to acquire an IOSurface. This will wait for a | 98 // A valid token is required to acquire an IOSurface. This will wait for a |
| 98 // valid token if one has not yet been set. | 99 // valid token if one has not yet been set. |
| 99 set_token_event_.Wait(); | 100 { |
| 100 #if !defined(NDEBUG) | 101 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 102 set_token_event_.Wait(); |
| 103 } |
| 104 #if DCHECK_IS_ON() |
| 101 DCHECK(!(set_token_thread_id_ == base::PlatformThread::CurrentRef())); | 105 DCHECK(!(set_token_thread_id_ == base::PlatformThread::CurrentRef())); |
| 102 #endif | 106 #endif |
| 103 DCHECK(!token_.IsZero()); | 107 DCHECK(!token_.IsZero()); |
| 104 | 108 |
| 105 mach_port_t reply_port; | 109 mach_port_t reply_port; |
| 106 kern_return_t kr = mach_port_allocate(mach_task_self(), | 110 kern_return_t kr = mach_port_allocate(mach_task_self(), |
| 107 MACH_PORT_RIGHT_RECEIVE, &reply_port); | 111 MACH_PORT_RIGHT_RECEIVE, &reply_port); |
| 108 if (kr != KERN_SUCCESS) { | 112 if (kr != KERN_SUCCESS) { |
| 109 MACH_LOG(ERROR, kr) << "mach_port_allocate"; | 113 MACH_LOG(ERROR, kr) << "mach_port_allocate"; |
| 110 return nullptr; | 114 return nullptr; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return IOSurfaceLookupFromMachPort(scoped_io_surface_right); | 146 return IOSurfaceLookupFromMachPort(scoped_io_surface_right); |
| 143 } | 147 } |
| 144 | 148 |
| 145 ChildIOSurfaceManager::ChildIOSurfaceManager() | 149 ChildIOSurfaceManager::ChildIOSurfaceManager() |
| 146 : set_token_event_(true, false) {} | 150 : set_token_event_(true, false) {} |
| 147 | 151 |
| 148 ChildIOSurfaceManager::~ChildIOSurfaceManager() { | 152 ChildIOSurfaceManager::~ChildIOSurfaceManager() { |
| 149 } | 153 } |
| 150 | 154 |
| 151 } // namespace content | 155 } // namespace content |
| OLD | NEW |