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

Side by Side Diff: media/base/android/dialog_surface_holder.h

Issue 2220623002: DialogSurfaceHolder implementation. Base URL: https://chromium.googlesource.com/chromium/src.git@just_surface_manager
Patch Set: panel => media dialog type 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_ANDROID_DIALOG_SURFACE_HOLDER_H_ 5 #ifndef MEDIA_BASE_ANDROID_DIALOG_SURFACE_HOLDER_H_
6 #define MEDIA_BASE_ANDROID_DIALOG_SURFACE_HOLDER_H_ 6 #define MEDIA_BASE_ANDROID_DIALOG_SURFACE_HOLDER_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 14
15 #include "base/android/scoped_java_ref.h" 15 #include "base/android/scoped_java_ref.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/task_runner.h" 18 #include "base/task_runner.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "media/base/media_export.h" 21 #include "media/base/media_export.h"
22 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
23 #include "ui/gl/android/scoped_java_surface.h" 23 #include "ui/gl/android/scoped_java_surface.h"
24 24
25 namespace base {
26 class WaitableEvent;
27 }
28
25 namespace media { 29 namespace media {
26 30
27 class DialogSurfaceCallback; 31 class DialogSurfaceCallback;
28 class DialogSurfaceManager; 32 class DialogSurfaceManager;
29 33
30 // This class implements the C++ wrapper around a java DialogSurfaceHolder. 34 // This class implements the C++ wrapper around a java DialogSurfaceHolder.
31 // All callbacks happen on the thread that it's constructed on. 35 // All callbacks happen on the thread that it's constructed on.
32 class MEDIA_EXPORT DialogSurfaceHolder { 36 class MEDIA_EXPORT DialogSurfaceHolder {
33 public: 37 public:
34 // These must match DialogSurface.java 38 // These must match DialogSurface.java
35 enum CallbackOp { SURFACE_CREATED = 0, SURFACE_DESTROYED = 1 }; 39 enum CallbackOp { SURFACE_CREATED = 0, SURFACE_DESTROYED = 1 };
36 40
37 // Callback type for finding out about the status of the surface. While we 41 // Callback type for finding out about the status of the surface. While we
38 // don't use this directly, it lets us keep DialogSurfaceCallback as an 42 // don't use this directly, it lets us keep DialogSurfaceCallback as an
39 // implementation detail. 43 // implementation detail.
40 using Callback = base::Callback<void(CallbackOp)>; 44 using Callback = base::Callback<void(CallbackOp)>;
41 45
42 // Configuration for the surface. 46 // Configuration for the surface.
43 struct Config { 47 struct Config {
44 gfx::Rect rect; 48 gfx::Rect rect;
45 // This may also include pixel format, is_secure, etc. 49 // This may also include pixel format, is_secure, etc.
46 }; 50 };
47 51
52 // |unwrapped_surface| is the IDialogSurface java instance, which
53 // we will take ownership of. |callback| is the wrapped callback that it will
54 // use to communicate with us (DialogSurfaceCallback).
55 // Note: one generally doesn't want to call this directly. Use
56 // DialogSurfaceManager instead.
57 DialogSurfaceHolder(const base::android::JavaRef<jobject>& unwrapped_surface,
58 std::unique_ptr<DialogSurfaceCallback>&& callback);
59 ~DialogSurfaceHolder();
60
48 // Schedule a relayout and/or reposition of the surface. 61 // Schedule a relayout and/or reposition of the surface.
49 // void ScheduleLayout(const Config& config); 62 void ScheduleLayout(const Config& config);
50 63
51 // Return the java surface, if any. One should not assume that this is 64 // Return the java surface, if any. One should not assume that this is
52 // available immediately. The callback will be called with SURFACE_CREATED 65 // available immediately. The callback will be called with SURFACE_CREATED
53 // when it is available. Of course, it may become unavailable again 66 // when it is available. Of course, it may become unavailable again
54 // asynchronously, so one must always check. 67 // asynchronously, so one must always check.
55 // gl::ScopedJavaSurface GetSurface(); 68 gl::ScopedJavaSurface GetSurface();
69
70 protected:
71 bool CalledOnValidThread() const;
72
73 private:
74 // Java DialogSurfaceWrapper instance.
75 base::android::ScopedJavaGlobalRef<jobject> j_wrapped_surface_;
76
77 // Callback that's associated with this surface. We maintain ownership of it
78 // so that the native object stays around while we do.
79 std::unique_ptr<DialogSurfaceCallback> wrapped_callback_;
80
81 base::ThreadChecker thread_checker_;
82
83 DISALLOW_COPY_AND_ASSIGN(DialogSurfaceHolder);
56 }; 84 };
57 85
58 } // namespace media 86 } // namespace media
59 87
60 #endif // MEDIA_BASE_ANDROID_DIALOG_SURFACE_HOLDER_H_ 88 #endif // MEDIA_BASE_ANDROID_DIALOG_SURFACE_HOLDER_H_
OLDNEW
« no previous file with comments | « media/base/android/dialog_surface_callback.cc ('k') | media/base/android/dialog_surface_holder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698