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

Unified Diff: content/browser/renderer_host/smooth_scroll_gesture_android.cc

Issue 11415227: Telemtry: hooks "chrome.gpuBenchmarking.smoothScrollBy" with java on android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove inline virtual dtor Created 8 years 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
« no previous file with comments | « content/browser/renderer_host/smooth_scroll_gesture_android.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/smooth_scroll_gesture_android.cc
diff --git a/content/browser/renderer_host/smooth_scroll_gesture_android.cc b/content/browser/renderer_host/smooth_scroll_gesture_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..240c3406286d972cb5f415a3727d9a1c884f29a5
--- /dev/null
+++ b/content/browser/renderer_host/smooth_scroll_gesture_android.cc
@@ -0,0 +1,68 @@
+// 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/browser/renderer_host/smooth_scroll_gesture_android.h"
+
+#include "base/debug/trace_event.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "jni/SmoothScroller_jni.h"
+
+namespace {
+bool g_jni_initialized = false;
+
+void RegisterNativesIfNeeded(JNIEnv* env) {
+ if (!g_jni_initialized) {
+ content::RegisterNativesImpl(env);
+ g_jni_initialized = true;
+ }
+}
+} // namespace
+
+namespace content {
+
+SmoothScrollGestureAndroid::SmoothScrollGestureAndroid(
+ int pixels_to_scroll,
+ RenderWidgetHost* rwh,
+ base::android::ScopedJavaLocalRef<jobject> java_scroller)
+ : pixels_scrolled_(0),
+ has_started_(false),
+ pixels_to_scroll_(pixels_to_scroll),
+ rwh_(rwh),
+ java_scroller_(java_scroller) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ RegisterNativesIfNeeded(env);
+}
+
+SmoothScrollGestureAndroid::~SmoothScrollGestureAndroid() {
+}
+
+bool SmoothScrollGestureAndroid::ForwardInputEvents(
+ base::TimeTicks now, RenderWidgetHost* host) {
+ if (!has_started_) {
+ has_started_ = true;
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SmoothScroller_start(
+ env, java_scroller_.obj(), reinterpret_cast<int>(this));
+ }
+
+ TRACE_COUNTER_ID1(
+ "gpu", "smooth_scroll_by_pixels_scrolled", this, pixels_scrolled_);
+
+ return pixels_scrolled_ < pixels_to_scroll_;
+}
+
+double SmoothScrollGestureAndroid::Tick(JNIEnv* env, jobject obj) {
+ double delta = SmoothScrollGesture::Tick(
+ base::TimeTicks::HighResNow(),
+ RenderWidgetHostImpl::From(rwh_)->SyntheticScrollMessageInterval());
+ pixels_scrolled_ += delta;
+ return delta;
+}
+
+bool SmoothScrollGestureAndroid::HasFinished(JNIEnv* env, jobject obj) {
+ return pixels_scrolled_ >= pixels_to_scroll_;
+}
+
+} // namespace content
+
« no previous file with comments | « content/browser/renderer_host/smooth_scroll_gesture_android.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698