Chromium Code Reviews| 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 #ifndef CONTENT_BROWSER_ANDROID_BROWSER_SCOPED_SURFACE_REQUEST_MANAGER_H_ | |
| 6 #define CONTENT_BROWSER_ANDROID_BROWSER_SCOPED_SURFACE_REQUEST_MANAGER_H_ | |
| 7 | |
| 8 #include <unordered_map> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/singleton.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 #include "gpu/ipc/common/android/scoped_surface_request_manager.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class CONTENT_EXPORT BrowserScopedSurfaceRequestManager | |
| 18 : public gpu::ScopedSurfaceRequestManager { | |
| 19 public: | |
| 20 static BrowserScopedSurfaceRequestManager* GetInstance(); | |
| 21 | |
| 22 void RegisterScopedSurfaceRequest(uint64_t request_id, | |
| 23 ScopedSurfaceRequestCB request_cb) override; | |
| 24 | |
| 25 // Unregisters and returns a request previously registered by this class' | |
| 26 // Register method. | |
| 27 // Returns a default ScopedSurfaceRequestCB if there was no request associated | |
| 28 // with |request_id|. | |
| 29 ScopedSurfaceRequestCB GetAndUnregisterScopedSurfaceRequest( | |
| 30 uint64_t request_id) override; | |
| 31 | |
| 32 // 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.
| |
| 33 // Runs the callback on the current thread. | |
| 34 void FulfillScopedSurfaceRequest( | |
| 35 uint64_t request_id, | |
| 36 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!
| |
| 37 | |
| 38 void clear_callbacks_for_testing() { request_callbacks_.clear(); } | |
| 39 | |
| 40 int callback_count_for_testing() { return request_callbacks_.size(); } | |
| 41 | |
| 42 private: | |
| 43 friend struct base::DefaultSingletonTraits< | |
| 44 BrowserScopedSurfaceRequestManager>; | |
| 45 | |
| 46 // Unregisters and returns the request identified by |request_id|. | |
| 47 // Does not acquire |lock_|. | |
| 48 ScopedSurfaceRequestCB GetAndUnregisterInternal(uint64_t request_id); | |
| 49 | |
| 50 // Map used to hold references to the registered callbacks. | |
| 51 std::unordered_map<uint64_t, ScopedSurfaceRequestCB> request_callbacks_; | |
| 52 | |
| 53 // Used to protect |request_callbacks_|. | |
| 54 base::Lock lock_; | |
| 55 | |
| 56 BrowserScopedSurfaceRequestManager(); | |
| 57 ~BrowserScopedSurfaceRequestManager() override; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(BrowserScopedSurfaceRequestManager); | |
| 60 }; | |
| 61 | |
| 62 } // namespace content | |
| 63 | |
| 64 #endif // CONTENT_BROWSER_ANDROID_BROWSER_SCOPED_SURFACE_REQUEST_MANAGER_H_ | |
| OLD | NEW |