OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "content/browser/in_process_io_surface_manager_mac.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 namespace content { | |
10 | |
11 // static | |
12 InProcessIOSurfaceManager* InProcessIOSurfaceManager::GetInstance() { | |
13 return Singleton<InProcessIOSurfaceManager, | |
14 LeakySingletonTraits<InProcessIOSurfaceManager>>::get(); | |
15 } | |
16 | |
17 bool InProcessIOSurfaceManager::RegisterIOSurface(int io_surface_id, | |
18 int client_id, | |
19 IOSurfaceRef io_surface) { | |
20 base::AutoLock lock(lock_); | |
21 | |
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)))); | |
26 return true; | |
27 } | |
28 | |
29 void InProcessIOSurfaceManager::UnregisterIOSurface(int io_surface_id, | |
30 int client_id) { | |
31 base::AutoLock lock(lock_); | |
32 | |
33 DCHECK(io_surfaces_.find(io_surface_id) != io_surfaces_.end()); | |
34 io_surfaces_.erase(io_surface_id); | |
35 } | |
36 | |
37 IOSurfaceRef InProcessIOSurfaceManager::AcquireIOSurface(int io_surface_id) { | |
38 base::AutoLock lock(lock_); | |
39 | |
40 DCHECK(io_surfaces_.find(io_surface_id) != io_surfaces_.end()); | |
41 return IOSurfaceLookupFromMachPort(io_surfaces_.get(io_surface_id)->get()); | |
42 } | |
43 | |
44 InProcessIOSurfaceManager::InProcessIOSurfaceManager() { | |
45 } | |
46 | |
47 InProcessIOSurfaceManager::~InProcessIOSurfaceManager() { | |
48 } | |
49 | |
50 } // namespace content | |
OLD | NEW |