- add sources.
[platform/framework/web/crosswalk.git] / src / mojo / services / native_viewport / android / mojo_viewport.h
1 // Copyright 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 #ifndef MOJO_SERVICES_NATIVE_VIEWPORT_ANDROID_MOJO_VIEWPORT_H_
6 #define MOJO_SERVICES_NATIVE_VIEWPORT_ANDROID_MOJO_VIEWPORT_H_
7
8 #include "base/android/jni_helper.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/single_thread_task_runner.h"
14 #include "mojo/services/native_viewport/native_viewport_android.h"
15
16 struct ANativeWindow;
17
18 namespace mojo {
19 namespace services {
20
21 struct MojoViewportInit {
22   MojoViewportInit();
23   ~MojoViewportInit();
24
25   scoped_refptr<base::SingleThreadTaskRunner> ui_runner;
26   base::WeakPtr<NativeViewportAndroid> native_viewport;
27 };
28
29 class MojoViewport {
30  public:
31   static bool Register(JNIEnv* env);
32
33   static void CreateForActivity(
34     jobject activity, MojoViewportInit* init);
35
36   explicit MojoViewport(MojoViewportInit* init);
37
38   void Destroy(JNIEnv* env, jobject obj);
39   void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface);
40   void SurfaceDestroyed(JNIEnv* env, jobject obj);
41   void SurfaceSetSize(JNIEnv* env, jobject obj, jint width, jint height);
42
43  private:
44   ~MojoViewport();
45
46   scoped_refptr<base::SingleThreadTaskRunner> ui_runner_;
47   base::WeakPtr<NativeViewportAndroid> native_viewport_;
48
49   DISALLOW_COPY_AND_ASSIGN(MojoViewport);
50 };
51
52 }  // namespace services
53 }  // namespace mojo
54
55 #endif  // MOJO_SERVICES_NATIVE_VIEWPORT_ANDROID_MOJO_VIEWPORT_H_