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

Side by Side Diff: media/base/android/dialog_surface_manager.cc

Issue 2178973004: DialogSurfaceManager implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DialogSurfaceManager.java => DialogSurfaceManagerImpl.java and stopped using activity for window to… Created 4 years, 1 month 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 #include "media/base/android/dialog_surface_manager.h"
6
7 #include <algorithm>
8 #include <limits>
9 #include <memory>
10 #include <utility>
11
12 #include "base/android/build_info.h"
13 #include "base/android/jni_android.h"
14 #include "base/android/jni_array.h"
15 #include "base/android/jni_string.h"
16 #include "base/logging.h"
17 #include "base/numerics/safe_conversions.h"
18 #include "base/strings/string_util.h"
19 #include "gpu/ipc/common/android/dialog_surface_lookup.h"
20 #include "jni/DialogSurfaceManagerWrapper_jni.h"
21 #include "media/base/bit_reader.h"
22 #include "media/base/decrypt_config.h"
23
24 using base::android::AttachCurrentThread;
25 using base::android::ConvertJavaStringToUTF8;
26 using base::android::ConvertUTF8ToJavaString;
27 using base::android::JavaIntArrayToIntVector;
28 using base::android::ScopedJavaGlobalRef;
29 using base::android::ScopedJavaLocalRef;
30
31 namespace media {
32
33 static base::LazyInstance<DialogSurfaceManager>::Leaky g_surface_manager =
34 LAZY_INSTANCE_INITIALIZER;
35
36 DialogSurfaceManager* DialogSurfaceManager::Get() {
37 return g_surface_manager.Pointer();
38 }
39
40 DialogSurfaceManager::DialogSurfaceManager() {
41 JNIEnv* env = AttachCurrentThread();
42 CHECK(env);
43
44 // Get the surface manager from the browser.
45 // This can, in principle, be run in the gpu process if we send the window
46 // token from the browser. See https://codereview.chromium.org/1967553002 .
47 // Either way, we end up with an IDialogSurfaceManager here, and we don't
48 // care whether it's local or remote.
49 ScopedJavaLocalRef<jobject> unwrapped_manager(
50 gpu::DialogSurfaceLookup::GetInstance()->GetDialogSurfaceManager());
51
52 // Wrap the manager for access from native code.
53 j_wrapped_manager_.Reset(
54 Java_DialogSurfaceManagerWrapper_wrap(env, unwrapped_manager.obj()));
55 }
56
57 DialogSurfaceManager::~DialogSurfaceManager() {}
58
59 std::unique_ptr<DialogSurfaceHolder> DialogSurfaceManager::CreateSurface(
60 base::ProcessHandle pid,
61 int frame_id,
62 const Config& config,
63 const DialogSurfaceHolder::Callback& callback) {
64 JNIEnv* env = AttachCurrentThread();
65 CHECK(env);
66
67 // TODO(liberato): wrap the callback here, and send in place of the nullptr.
68 // This was omitted for the first CL.
69
70 ScopedJavaGlobalRef<jobject> result(
71 Java_DialogSurfaceManagerWrapper_createSurface(
72 env, j_wrapped_manager_.obj(), pid, frame_id, nullptr,
73 config.rect.x(), config.rect.y(), config.rect.width(),
74 config.rect.height()));
75 // NOTE: result is always null right now.
76
77 std::unique_ptr<DialogSurfaceHolder> holder;
78
79 return holder;
80 }
81
82 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698