content_readback_handler.h revision 0de6073388f4e2780db8536178b129cd8f6ab386
1// Copyright 2014 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 CONTENT_BROWSER_ANDROID_CONTENT_READBACK_HANDLER_H_
6#define CONTENT_BROWSER_ANDROID_CONTENT_READBACK_HANDLER_H_
7
8#include <jni.h>
9
10#include "base/android/jni_weak_ref.h"
11#include "base/callback.h"
12#include "base/memory/weak_ptr.h"
13
14class SkBitmap;
15
16namespace content {
17
18// Native side of the ContentReadbackHandler.java, which issues content
19// readbacks from the Java side.
20class ContentReadbackHandler {
21 public:
22  // Registers the JNI methods for ContentViewRender.
23  static bool RegisterContentReadbackHandler(JNIEnv* env);
24
25  // Methods called from Java via JNI -----------------------------------------
26  ContentReadbackHandler(JNIEnv* env, jobject obj);
27  void Destroy(JNIEnv* env, jobject obj);
28  void GetContentBitmap(JNIEnv* env,
29                        jobject obj,
30                        jint readback_id,
31                        jfloat scale,
32                        jobject config,
33                        jfloat x,
34                        jfloat y,
35                        jfloat width,
36                        jfloat height,
37                        jobject content_view_core);
38
39 private:
40  virtual ~ContentReadbackHandler();
41
42  void OnFinishContentReadback(int readback_id,
43                               bool success,
44                               const SkBitmap& bitmap);
45
46  base::android::ScopedJavaGlobalRef<jobject> java_obj_;
47  base::WeakPtrFactory<ContentReadbackHandler> weak_factory_;
48
49  DISALLOW_COPY_AND_ASSIGN(ContentReadbackHandler);
50};
51
52}  // namespace content
53
54#endif  // CONTENT_BROWSER_ANDROID_CONTENT_READBACK_HANDLER_H_
55