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

Unified Diff: media/base/android/android_overlay_provider_proxy.cc

Issue 2178973004: DialogSurfaceManager implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/base/android/android_overlay_provider_proxy.cc
diff --git a/media/base/android/android_overlay_provider_proxy.cc b/media/base/android/android_overlay_provider_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2b67452350b236f14deaacaa0c0d2b73fa0b0b9c
--- /dev/null
+++ b/media/base/android/android_overlay_provider_proxy.cc
@@ -0,0 +1,69 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/android/android_overlay_provider_proxy.h"
+
+#include "base/android/jni_android.h"
+#include "gpu/ipc/common/android/android_overlay_provider_lookup.h"
+#include "jni/AndroidOverlayProviderProxy_jni.h"
+#include "media/base/android/android_overlay_callback.h"
+
+using base::android::AttachCurrentThread;
+using base::android::ScopedJavaGlobalRef;
+using base::android::ScopedJavaLocalRef;
+
+namespace media {
+
+static base::LazyInstance<AndroidOverlayProviderProxy>::Leaky
+ g_surface_manager = LAZY_INSTANCE_INITIALIZER;
+
+AndroidOverlayProviderProxy* AndroidOverlayProviderProxy::Get() {
+ return g_surface_manager.Pointer();
+}
+
+AndroidOverlayProviderProxy::AndroidOverlayProviderProxy() {
+ JNIEnv* env = AttachCurrentThread();
+
+ // Get the surface manager from the browser.
+ // This can, in principle, be run in the gpu process if we send the window
+ // token from the browser. See https://codereview.chromium.org/1967553002 .
+ // Either way, we end up with an IAndroidOverlayProviderProxy here, and we
+ // don't
+ // care whether it's local or remote.
+ ScopedJavaLocalRef<jobject> unwrapped_provider(
+ gpu::AndroidOverlayProviderLookup::GetInstance()
+ ->GetAndroidOverlayProvider());
+
+ // Wrap the manager for access from native code.
+ j_wrapped_provider_.Reset(
+ Java_AndroidOverlayProviderProxy_wrap(env, unwrapped_provider.obj()));
+}
+
+AndroidOverlayProviderProxy::~AndroidOverlayProviderProxy() {}
+
+std::unique_ptr<AndroidOverlayProxy> AndroidOverlayProviderProxy::CreateOverlay(
+ base::ProcessHandle pid,
+ int frame_id,
+ const Config& config,
+ const AndroidOverlayProxy::Callback& callback) {
+ JNIEnv* env = AttachCurrentThread();
+
+ std::unique_ptr<AndroidOverlayCallback> wrapped_callback(
+ new AndroidOverlayCallback(callback));
+
+ ScopedJavaGlobalRef<jobject> result(
+ Java_AndroidOverlayProviderProxy_createOverlay(
+ env, j_wrapped_provider_.obj(), pid, frame_id,
+ wrapped_callback->obj(), config.rect.x(), config.rect.y(),
+ config.rect.width(), config.rect.height()));
+
+ std::unique_ptr<AndroidOverlayProxy> surface;
+ if (!result.is_null()) {
+ surface.reset(new AndroidOverlayProxy(result, std::move(wrapped_callback)));
+ }
+
+ return surface;
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698