Index: content/browser/android/browser_scoped_surface_request_manager.h |
diff --git a/content/browser/android/browser_scoped_surface_request_manager.h b/content/browser/android/browser_scoped_surface_request_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..98efedf9039d605f40b01cd9b524bcdf378fe212 |
--- /dev/null |
+++ b/content/browser/android/browser_scoped_surface_request_manager.h |
@@ -0,0 +1,64 @@ |
+// 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_BROWSER_SCOPED_SURFACE_REQUEST_MANAGER_H_ |
+#define CONTENT_BROWSER_ANDROID_BROWSER_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_manager.h" |
+ |
+namespace content { |
+ |
+class CONTENT_EXPORT BrowserScopedSurfaceRequestManager |
+ : public gpu::ScopedSurfaceRequestManager { |
+ public: |
+ static BrowserScopedSurfaceRequestManager* GetInstance(); |
+ |
+ void RegisterScopedSurfaceRequest(uint64_t request_id, |
+ ScopedSurfaceRequestCB request_cb) override; |
+ |
+ // 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) override; |
+ |
+ // Tries to callback the request identified by |request_id|. |
watk
2016/08/26 22:01:32
what about "Runs the request callback identified b
tguilbert
2016/08/29 18:30:46
Done.
|
+ // Runs the callback on the current thread. |
+ void FulfillScopedSurfaceRequest( |
+ uint64_t request_id, |
+ gl::SurfaceTexture* surface_texture) override; |
liberato (no reviews please)
2016/08/29 21:10:19
it's a little unexpected that this is a SurfaceTex
tguilbert
2016/08/30 22:53:09
Updated!
|
+ |
+ void clear_callbacks_for_testing() { request_callbacks_.clear(); } |
+ |
+ int callback_count_for_testing() { return request_callbacks_.size(); } |
+ |
+ private: |
+ friend struct base::DefaultSingletonTraits< |
+ BrowserScopedSurfaceRequestManager>; |
+ |
+ // 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_; |
+ |
+ BrowserScopedSurfaceRequestManager(); |
+ ~BrowserScopedSurfaceRequestManager() override; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BrowserScopedSurfaceRequestManager); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_ANDROID_BROWSER_SCOPED_SURFACE_REQUEST_MANAGER_H_ |