Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: content/browser/android/scoped_surface_request_manager.cc

Issue 2285593002: Add ScopedSurfaceRequestManager (Closed)
Patch Set: Simplified manager interface. Renamed to Conduit. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/android/scoped_surface_request_manager.cc
diff --git a/content/browser/android/scoped_surface_request_manager.cc b/content/browser/android/scoped_surface_request_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9427df4791d247f731aab06104ba98301fe31f6c
--- /dev/null
+++ b/content/browser/android/scoped_surface_request_manager.cc
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/android/scoped_surface_request_manager.h"
+
+namespace content {
+
+// static
+ScopedSurfaceRequestManager* ScopedSurfaceRequestManager::GetInstance() {
+ return base::Singleton<
+ ScopedSurfaceRequestManager,
+ base::LeakySingletonTraits<ScopedSurfaceRequestManager>>::get();
+}
+
+void ScopedSurfaceRequestManager::RegisterScopedSurfaceRequest(
+ uint64_t request_id,
+ ScopedSurfaceRequestCB request_cb) {
+ base::AutoLock lock(lock_);
+
+ DCHECK(!request_callbacks_.count(request_id));
+ 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
+}
+
+ScopedSurfaceRequestManager::ScopedSurfaceRequestCB
+ScopedSurfaceRequestManager::GetAndUnregisterScopedSurfaceRequest(
+ uint64_t request_id) {
+ base::AutoLock lock(lock_);
+
+ return GetAndUnregisterInternal(request_id);
+}
+
+ScopedSurfaceRequestManager::ScopedSurfaceRequestCB
+ScopedSurfaceRequestManager::GetAndUnregisterInternal(uint64_t request_id) {
+ ScopedSurfaceRequestManager::ScopedSurfaceRequestCB request;
+
+ auto it = request_callbacks_.find(request_id);
+
+ if (it != request_callbacks_.end()) {
+ request = it->second;
+ request_callbacks_.erase(it);
+ }
+
+ return request;
+}
+
+void ScopedSurfaceRequestManager::FulfillScopedSurfaceRequest(
+ uint64_t request_id,
+ gl::SurfaceTexture* surface_texture) {
+ base::AutoLock lock(lock_);
+
+ ScopedSurfaceRequestManager::ScopedSurfaceRequestCB request =
+ GetAndUnregisterInternal(request_id);
+
+ if (!request.is_null()) {
+ gl::ScopedJavaSurface surface(surface_texture);
+ request.Run(std::move(surface));
+ }
+}
+
+ScopedSurfaceRequestManager::ScopedSurfaceRequestManager() {}
+
+ScopedSurfaceRequestManager::~ScopedSurfaceRequestManager() {}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698