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

Unified Diff: content/common/android/surface_texture_listener.cc

Issue 10695020: upstream SurfaceTextureListener and SurfaceTextureBridge class for android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing nits Created 8 years, 6 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: content/common/android/surface_texture_listener.cc
diff --git a/content/common/android/surface_texture_listener.cc b/content/common/android/surface_texture_listener.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1d50a142ef5919a1dfe42263a699d85d150308bd
--- /dev/null
+++ b/content/common/android/surface_texture_listener.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 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 "content/common/android/surface_texture_listener.h"
+
+#include "base/location.h"
+#include "base/logging.h"
+#include "base/message_loop_proxy.h"
+#include "content/common/android/surface_texture_bridge.h"
+#include "jni/surface_texture_listener_jni.h"
+
+namespace content {
+
+// static
+jobject SurfaceTextureListener::CreateSurfaceTextureListener(
+ JNIEnv* env,
+ const base::Closure& callback) {
+ // The java listener object owns and releases the native instance.
+ // This is necessary to avoid races with incoming notifications.
+ ScopedJavaLocalRef<jobject> listener(Java_SurfaceTextureListener_create(env,
+ reinterpret_cast<int>(new SurfaceTextureListener(callback))));
+
+ DCHECK(!listener.is_null());
+ return listener.Release();
+}
+
+SurfaceTextureListener::SurfaceTextureListener(const base::Closure& callback)
+ : callback_(callback),
+ browser_loop_(base::MessageLoopProxy::current()) {
+}
+
+SurfaceTextureListener::~SurfaceTextureListener() {
+}
+
+void SurfaceTextureListener::Destroy(JNIEnv* env, jobject obj) {
+ delete this;
+}
+
+void SurfaceTextureListener::FrameAvailable(JNIEnv* env, jobject obj) {
+ // These notifications should be coming in on a thread private to Java.
+ // Should this ever change, we can try to avoid reposting to the same thread.
+ DCHECK(!browser_loop_->BelongsToCurrentThread());
+ browser_loop_->PostTask(FROM_HERE, callback_);
+}
+
+// static
+bool SurfaceTextureListener::RegisterSurfaceTextureListener(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace content
« no previous file with comments | « content/common/android/surface_texture_listener.h ('k') | content/common/gpu/stream_texture_manager_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698