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
3 // found in the LICENSE file.
5 #include "content/browser/in_process_io_surface_manager_mac.h"
7 #include "base/logging.h"
12 InProcessIOSurfaceManager
* InProcessIOSurfaceManager::GetInstance() {
13 return Singleton
<InProcessIOSurfaceManager
,
14 LeakySingletonTraits
<InProcessIOSurfaceManager
>>::get();
17 bool InProcessIOSurfaceManager::RegisterIOSurface(IOSurfaceId io_surface_id
,
19 IOSurfaceRef io_surface
) {
20 base::AutoLock
lock(lock_
);
22 DCHECK(io_surfaces_
.find(io_surface_id
) == io_surfaces_
.end());
23 io_surfaces_
.add(io_surface_id
,
24 make_scoped_ptr(new base::mac::ScopedMachSendRight(
25 IOSurfaceCreateMachPort(io_surface
))));
29 void InProcessIOSurfaceManager::UnregisterIOSurface(IOSurfaceId io_surface_id
,
31 base::AutoLock
lock(lock_
);
33 DCHECK(io_surfaces_
.find(io_surface_id
) != io_surfaces_
.end());
34 io_surfaces_
.erase(io_surface_id
);
37 IOSurfaceRef
InProcessIOSurfaceManager::AcquireIOSurface(
38 IOSurfaceId io_surface_id
) {
39 base::AutoLock
lock(lock_
);
41 DCHECK(io_surfaces_
.find(io_surface_id
) != io_surfaces_
.end());
42 return IOSurfaceLookupFromMachPort(io_surfaces_
.get(io_surface_id
)->get());
45 InProcessIOSurfaceManager::InProcessIOSurfaceManager() {
48 InProcessIOSurfaceManager::~InProcessIOSurfaceManager() {
51 } // namespace content