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

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

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.h
diff --git a/content/browser/android/scoped_surface_request_manager.h b/content/browser/android/scoped_surface_request_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed8c687ccbb9be90ac0ecdb195f68199b4504e1b
--- /dev/null
+++ b/content/browser/android/scoped_surface_request_manager.h
@@ -0,0 +1,69 @@
+// 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.
+
+#ifndef CONTENT_BROWSER_ANDROID_SCOPED_SURFACE_REQUEST_MANAGER_H_
+#define CONTENT_BROWSER_ANDROID_SCOPED_SURFACE_REQUEST_MANAGER_H_
+
+#include <unordered_map>
+
+#include "base/macros.h"
+#include "base/memory/singleton.h"
+#include "content/common/content_export.h"
+#include "gpu/ipc/common/android/scoped_surface_request_conduit.h"
+#include "ui/gl/android/scoped_java_surface.h"
+
+namespace content {
+
+class CONTENT_EXPORT ScopedSurfaceRequestManager
+ : public gpu::ScopedSurfaceRequestConduit {
+ public:
+ static ScopedSurfaceRequestManager* GetInstance();
+
+ using ScopedSurfaceRequestCB = base::Callback<void(gl::ScopedJavaSurface)>;
+
+ void RegisterScopedSurfaceRequest(uint64_t request_id,
watk 2016/08/29 19:42:26 Without comments it kinda sounds like this gets yo
+ ScopedSurfaceRequestCB request_cb);
+
+ // Unregisters and returns a request previously registered by this class'
+ // Register method.
+ // Returns a default ScopedSurfaceRequestCB if there was no request associated
+ // with |request_id|.
+ ScopedSurfaceRequestCB GetAndUnregisterScopedSurfaceRequest(
+ uint64_t request_id);
+
+ // gpu::ScopedSurfaceRequestConduit implementation
+ //
+ // Runs the request identified by |request_id| if one exists.
+ // Runs the callback on the current thread.
watk 2016/08/29 19:42:26 Not only on the current thread but synchronously.
+ // Used when in single process mode (see ChildProcessServices otherwise).
+ void FulfillScopedSurfaceRequest(
+ uint64_t request_id,
+ gl::SurfaceTexture* surface_texture) override;
+
+ void clear_callbacks_for_testing() { request_callbacks_.clear(); }
+
+ int callback_count_for_testing() { return request_callbacks_.size(); }
+
+ private:
+ friend struct base::DefaultSingletonTraits<ScopedSurfaceRequestManager>;
+
+ // Unregisters and returns the request identified by |request_id|.
+ // Does not acquire |lock_|.
+ ScopedSurfaceRequestCB GetAndUnregisterInternal(uint64_t request_id);
+
+ // Map used to hold references to the registered callbacks.
+ std::unordered_map<uint64_t, ScopedSurfaceRequestCB> request_callbacks_;
+
+ // Used to protect |request_callbacks_|.
+ base::Lock lock_;
+
+ ScopedSurfaceRequestManager();
+ ~ScopedSurfaceRequestManager() override;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedSurfaceRequestManager);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_ANDROID_SCOPED_SURFACE_REQUEST_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698