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

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: removed whitespace changes 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/android/unguessable_token_android.h"
17 #include "base/logging.h"
18 #include "base/numerics/safe_conversions.h"
19 #include "base/strings/string_util.h"
20 #include "base/unguessable_token.h"
21 #include "gpu/ipc/common/android/dialog_surface_lookup.h"
22 #include "jni/DialogSurfaceManagerWrapper_jni.h"
23 #include "media/base/bit_reader.h"
24 #include "media/base/decrypt_config.h"
25
26 using base::android::AttachCurrentThread;
27 using base::android::ConvertJavaStringToUTF8;
28 using base::android::ConvertUTF8ToJavaString;
29 using base::android::JavaIntArrayToIntVector;
30 using base::android::ScopedJavaGlobalRef;
31 using base::android::ScopedJavaLocalRef;
32
33 namespace media {
34
35 static base::LazyInstance<DialogSurfaceManager>::Leaky g_surface_manager =
36 LAZY_INSTANCE_INITIALIZER;
37
38 DialogSurfaceManager* DialogSurfaceManager::Get() {
39 return g_surface_manager.Pointer();
40 }
41
42 DialogSurfaceManager::DialogSurfaceManager() {
43 JNIEnv* env = AttachCurrentThread();
44 CHECK(env);
45
46 // Get the surface manager from the browser.
47 // This can, in principle, be run in the gpu process if we send the window
48 // token from the browser. See https://codereview.chromium.org/1967553002 .
49 // Either way, we end up with an IDialogSurfaceManager here, and we don't
50 // care whether it's local or remote.
51 ScopedJavaLocalRef<jobject> unwrapped_manager(
52 gpu::DialogSurfaceLookup::GetInstance()->GetDialogSurfaceManager());
53
54 // Wrap the manager for access from native code.
55 j_wrapped_manager_.Reset(
56 Java_DialogSurfaceManagerWrapper_wrap(env, unwrapped_manager.obj()));
57 }
58
59 DialogSurfaceManager::~DialogSurfaceManager() {}
60
61 std::unique_ptr<DialogSurfaceHolder> DialogSurfaceManager::CreateSurface(
62 const base::UnguessableToken& frame_token,
63 const Config& config,
64 const DialogSurfaceHolder::Callback& callback) {
65 JNIEnv* env = AttachCurrentThread();
66 CHECK(env);
67
68 // TODO(liberato): wrap the callback here, and send in place of the nullptr.
69 // This was omitted for the first CL.
70
71 ScopedJavaLocalRef<jobject> frame_token_java =
72 base::android::UnguessableTokenAndroid::Create(env, frame_token);
73 if (!frame_token_java.obj())
74 return std::unique_ptr<DialogSurfaceHolder>();
boliu 2016/11/14 16:39:25 nit: return nullptr
liberato (no reviews please) 2016/12/20 17:16:38 code was removed entirely.
75
76 ScopedJavaGlobalRef<jobject> result(
77 Java_DialogSurfaceManagerWrapper_createSurface(
78 env, j_wrapped_manager_.obj(), frame_token_java.obj(), nullptr,
79 config.rect.x(), config.rect.y(), config.rect.width(),
80 config.rect.height()));
81 // NOTE: result is always null right now.
82 std::unique_ptr<DialogSurfaceHolder> holder;
83
84 return holder;
85 }
86
87 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698