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

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: moved jni out of content/app 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
(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/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::GetPointer() {
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 ScopedJavaLocalRef<jobject> unwrapped_manager(
48 gpu::DialogSurfaceLookup::GetInstance()->GetDialogSurfaceManager());
49
50 // Wrap the manager for local access.
51 j_wrapped_manager_.Reset(
52 Java_DialogSurfaceManagerWrapper_wrap(env, unwrapped_manager.obj()));
53 }
54
55 DialogSurfaceManager::~DialogSurfaceManager() {}
56
57 std::unique_ptr<DialogSurface> DialogSurfaceManager::CreateSurface(
58 base::ProcessHandle pid,
59 int frame_id,
60 const Config& config,
61 const DialogSurface::Callback& callback) {
62 JNIEnv* env = AttachCurrentThread();
63 CHECK(env);
64
65 // TODO(liberato): wrap the callback here, and send in place of the nullptr.
66 // This was omitted for the first CL.
67
68 ScopedJavaGlobalRef<jobject> result(
69 Java_DialogSurfaceManagerWrapper_createSurface(
70 env, j_wrapped_manager_.obj(), pid, frame_id, nullptr,
71 config.position.x(), config.position.y(), config.size.width(),
72 config.size.height()));
73 // NOTE: result is always null right now.
74
75 std::unique_ptr<DialogSurface> controller;
watk 2016/07/26 21:34:30 controller?
liberato (no reviews please) 2016/07/26 22:49:16 Done.
76
77 return controller;
78 }
79
80 bool DialogSurfaceManager::RegisterDialogSurfaceManager(JNIEnv* env) {
81 return RegisterNativesImpl(env);
82 }
83
84 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698