- add sources.
[platform/framework/web/crosswalk.git] / src / ui / gl / android / surface_texture_listener.cc
1 // Copyright (c) 2013 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 "ui/gl/android/surface_texture_listener.h"
6
7 #include "base/location.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "jni/SurfaceTextureListener_jni.h"
11 #include "ui/gl/android/surface_texture.h"
12
13 namespace gfx {
14
15 SurfaceTextureListener::SurfaceTextureListener(const base::Closure& callback)
16     : callback_(callback),
17       browser_loop_(base::MessageLoopProxy::current()) {
18 }
19
20 SurfaceTextureListener::~SurfaceTextureListener() {
21 }
22
23 void SurfaceTextureListener::Destroy(JNIEnv* env, jobject obj) {
24   delete this;
25 }
26
27 void SurfaceTextureListener::FrameAvailable(JNIEnv* env, jobject obj) {
28   if (!browser_loop_->BelongsToCurrentThread()) {
29     browser_loop_->PostTask(FROM_HERE, callback_);
30   } else {
31     callback_.Run();
32   }
33 }
34
35 // static
36 bool SurfaceTextureListener::RegisterSurfaceTextureListener(JNIEnv* env) {
37   return RegisterNativesImpl(env);
38 }
39
40 }  // namespace gfx