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

Unified Diff: chrome/browser/android/swipe_refresh_handler.cc

Issue 2528823002: Separate SwipeRefreshHandler and ContentViewCore (Closed)
Patch Set: Fix compile error in test case Created 4 years, 1 month 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: chrome/browser/android/swipe_refresh_handler.cc
diff --git a/chrome/browser/android/swipe_refresh_handler.cc b/chrome/browser/android/swipe_refresh_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0a8d191fb108738962acbf5068ad1e971054ab43
--- /dev/null
+++ b/chrome/browser/android/swipe_refresh_handler.cc
@@ -0,0 +1,65 @@
+// 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 "chrome/browser/android/swipe_refresh_handler.h"
+
+#include "jni/SwipeRefreshHandler_jni.h"
+
+using base::android::AttachCurrentThread;
+using base::android::JavaParamRef;
+using base::android::JavaRef;
+using base::android::ScopedJavaLocalRef;
+
+SwipeRefreshHandler::SwipeRefreshHandler(JNIEnv* env,
+ const JavaRef<jobject>& obj)
+ : java_ref_(env, obj) {}
+
+bool SwipeRefreshHandler::PullStart() {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
+ if (!obj.is_null()) {
+ return Java_SwipeRefreshHandler_start(env, obj);
+ }
+ return false;
+}
+
+void SwipeRefreshHandler::PullUpdate(float delta) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
+ if (!obj.is_null()) {
+ Java_SwipeRefreshHandler_pull(env, obj, delta);
+ }
+}
+
+void SwipeRefreshHandler::PullRelease(bool allow_refresh) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
+ if (!obj.is_null()) {
+ Java_SwipeRefreshHandler_release(env, obj, allow_refresh);
+ }
+}
+
+void SwipeRefreshHandler::PullReset() {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
+ if (!obj.is_null()) {
+ Java_SwipeRefreshHandler_reset(env, obj);
+ }
+}
+
+static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
+ SwipeRefreshHandler* swipe_refresh_handler =
+ new SwipeRefreshHandler(env, obj);
+ return reinterpret_cast<intptr_t>(swipe_refresh_handler);
Jinsuk Kim 2016/11/25 01:49:18 Alternatively, you can set the created object to W
rlanday 2016/11/28 19:42:01 This seems potentially problematic to me; inside T
Jinsuk Kim 2016/11/28 23:06:40 YOu can add the api to native WebContents/WebConte
+}
+
+void SwipeRefreshHandler::Destroy(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
+ delete this;
Jinsuk Kim 2016/11/25 01:49:18 With the refactoring I think this object better be
rlanday 2016/11/28 19:42:01 This seems weird to me; I think the native SwipeRe
Jinsuk Kim 2016/11/28 23:06:40 You don't have to worry about the destruction orde
+}
+
+// static
+bool SwipeRefreshHandler::RegisterSwipeRefreshHandler(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}

Powered by Google App Engine
This is Rietveld 408576698