OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/android/scoped_surface_request_manager.h" | |
6 | |
7 namespace content { | |
8 | |
9 // static | |
10 ScopedSurfaceRequestManager* ScopedSurfaceRequestManager::GetInstance() { | |
11 return base::Singleton< | |
12 ScopedSurfaceRequestManager, | |
13 base::LeakySingletonTraits<ScopedSurfaceRequestManager>>::get(); | |
14 } | |
15 | |
16 void ScopedSurfaceRequestManager::RegisterScopedSurfaceRequest( | |
17 uint64_t request_id, | |
18 ScopedSurfaceRequestCB request_cb) { | |
19 base::AutoLock lock(lock_); | |
20 | |
21 DCHECK(!request_callbacks_.count(request_id)); | |
22 request_callbacks_.insert(std::make_pair(request_id, request_cb)); | |
watk
2016/08/29 19:42:26
Seems like the request token should be generated h
liberato (no reviews please)
2016/08/29 21:10:19
should also check with chrome security if int64 is
tguilbert
2016/08/30 22:53:09
Done @ generating the token here. I will follow up
| |
23 } | |
24 | |
25 ScopedSurfaceRequestManager::ScopedSurfaceRequestCB | |
26 ScopedSurfaceRequestManager::GetAndUnregisterScopedSurfaceRequest( | |
27 uint64_t request_id) { | |
28 base::AutoLock lock(lock_); | |
29 | |
30 return GetAndUnregisterInternal(request_id); | |
31 } | |
32 | |
33 ScopedSurfaceRequestManager::ScopedSurfaceRequestCB | |
34 ScopedSurfaceRequestManager::GetAndUnregisterInternal(uint64_t request_id) { | |
35 ScopedSurfaceRequestManager::ScopedSurfaceRequestCB request; | |
36 | |
37 auto it = request_callbacks_.find(request_id); | |
38 | |
39 if (it != request_callbacks_.end()) { | |
40 request = it->second; | |
41 request_callbacks_.erase(it); | |
42 } | |
43 | |
44 return request; | |
45 } | |
46 | |
47 void ScopedSurfaceRequestManager::FulfillScopedSurfaceRequest( | |
48 uint64_t request_id, | |
49 gl::SurfaceTexture* surface_texture) { | |
50 base::AutoLock lock(lock_); | |
51 | |
52 ScopedSurfaceRequestManager::ScopedSurfaceRequestCB request = | |
53 GetAndUnregisterInternal(request_id); | |
54 | |
55 if (!request.is_null()) { | |
56 gl::ScopedJavaSurface surface(surface_texture); | |
57 request.Run(std::move(surface)); | |
58 } | |
59 } | |
60 | |
61 ScopedSurfaceRequestManager::ScopedSurfaceRequestManager() {} | |
62 | |
63 ScopedSurfaceRequestManager::~ScopedSurfaceRequestManager() {} | |
64 | |
65 } // namespace content | |
OLD | NEW |