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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
(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_SCOPED_SURFACE_REQUEST_MANAGER_H_
6 #define CONTENT_BROWSER_ANDROID_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_conduit.h"
14 #include "ui/gl/android/scoped_java_surface.h"
15
16 namespace content {
17
18 class CONTENT_EXPORT ScopedSurfaceRequestManager
19 : public gpu::ScopedSurfaceRequestConduit {
20 public:
21 static ScopedSurfaceRequestManager* GetInstance();
22
23 using ScopedSurfaceRequestCB = base::Callback<void(gl::ScopedJavaSurface)>;
24
25 void RegisterScopedSurfaceRequest(uint64_t request_id,
watk 2016/08/29 19:42:26 Without comments it kinda sounds like this gets yo
26 ScopedSurfaceRequestCB request_cb);
27
28 // Unregisters and returns a request previously registered by this class'
29 // Register method.
30 // Returns a default ScopedSurfaceRequestCB if there was no request associated
31 // with |request_id|.
32 ScopedSurfaceRequestCB GetAndUnregisterScopedSurfaceRequest(
33 uint64_t request_id);
34
35 // gpu::ScopedSurfaceRequestConduit implementation
36 //
37 // Runs the request identified by |request_id| if one exists.
38 // Runs the callback on the current thread.
watk 2016/08/29 19:42:26 Not only on the current thread but synchronously.
39 // Used when in single process mode (see ChildProcessServices otherwise).
40 void FulfillScopedSurfaceRequest(
41 uint64_t request_id,
42 gl::SurfaceTexture* surface_texture) override;
43
44 void clear_callbacks_for_testing() { request_callbacks_.clear(); }
45
46 int callback_count_for_testing() { return request_callbacks_.size(); }
47
48 private:
49 friend struct base::DefaultSingletonTraits<ScopedSurfaceRequestManager>;
50
51 // Unregisters and returns the request identified by |request_id|.
52 // Does not acquire |lock_|.
53 ScopedSurfaceRequestCB GetAndUnregisterInternal(uint64_t request_id);
54
55 // Map used to hold references to the registered callbacks.
56 std::unordered_map<uint64_t, ScopedSurfaceRequestCB> request_callbacks_;
57
58 // Used to protect |request_callbacks_|.
59 base::Lock lock_;
60
61 ScopedSurfaceRequestManager();
62 ~ScopedSurfaceRequestManager() override;
63
64 DISALLOW_COPY_AND_ASSIGN(ScopedSurfaceRequestManager);
65 };
66
67 } // namespace content
68
69 #endif // CONTENT_BROWSER_ANDROID_SCOPED_SURFACE_REQUEST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698