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 base::Singleton
<
14 InProcessIOSurfaceManager
,
15 base::LeakySingletonTraits
<InProcessIOSurfaceManager
>>::get();
18 bool InProcessIOSurfaceManager::RegisterIOSurface(IOSurfaceId io_surface_id
,
20 IOSurfaceRef io_surface
) {
21 base::AutoLock
lock(lock_
);
23 DCHECK(io_surfaces_
.find(io_surface_id
) == io_surfaces_
.end());
24 io_surfaces_
.add(io_surface_id
,
25 make_scoped_ptr(new base::mac::ScopedMachSendRight(
26 IOSurfaceCreateMachPort(io_surface
))));
30 void InProcessIOSurfaceManager::UnregisterIOSurface(IOSurfaceId io_surface_id
,
32 base::AutoLock
lock(lock_
);
34 DCHECK(io_surfaces_
.find(io_surface_id
) != io_surfaces_
.end());
35 io_surfaces_
.erase(io_surface_id
);
38 IOSurfaceRef
InProcessIOSurfaceManager::AcquireIOSurface(
39 IOSurfaceId io_surface_id
) {
40 base::AutoLock
lock(lock_
);
42 DCHECK(io_surfaces_
.find(io_surface_id
) != io_surfaces_
.end());
43 return IOSurfaceLookupFromMachPort(io_surfaces_
.get(io_surface_id
)->get());
46 InProcessIOSurfaceManager::InProcessIOSurfaceManager() {
49 InProcessIOSurfaceManager::~InProcessIOSurfaceManager() {
52 } // namespace content