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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2536413003: Added UMA counters for Android tool-types. (Closed)
Patch Set: Added eraser type in histogram. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 using base::android::AttachCurrentThread; 69 using base::android::AttachCurrentThread;
70 using base::android::ConvertJavaStringToUTF16; 70 using base::android::ConvertJavaStringToUTF16;
71 using base::android::ConvertJavaStringToUTF8; 71 using base::android::ConvertJavaStringToUTF8;
72 using base::android::ConvertUTF16ToJavaString; 72 using base::android::ConvertUTF16ToJavaString;
73 using base::android::ConvertUTF8ToJavaString; 73 using base::android::ConvertUTF8ToJavaString;
74 using base::android::JavaParamRef; 74 using base::android::JavaParamRef;
75 using base::android::JavaRef; 75 using base::android::JavaRef;
76 using base::android::ScopedJavaLocalRef; 76 using base::android::ScopedJavaLocalRef;
77 using blink::WebGestureEvent; 77 using blink::WebGestureEvent;
78 using blink::WebInputEvent; 78 using blink::WebInputEvent;
79 using ui::MotionEventAndroid;
79 80
80 namespace content { 81 namespace content {
81 82
82 namespace { 83 namespace {
83 84
84 // Describes the type and enabled state of a select popup item. 85 // Describes the type and enabled state of a select popup item.
85 // 86 //
86 // A Java counterpart will be generated for this enum. 87 // A Java counterpart will be generated for this enum.
87 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input 88 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input
88 enum PopupItemType { 89 enum PopupItemType {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 case WebInputEvent::GesturePinchUpdate: 154 case WebInputEvent::GesturePinchUpdate:
154 return GESTURE_EVENT_TYPE_PINCH_BY; 155 return GESTURE_EVENT_TYPE_PINCH_BY;
155 case WebInputEvent::GestureTwoFingerTap: 156 case WebInputEvent::GestureTwoFingerTap:
156 default: 157 default:
157 NOTREACHED() << "Invalid source gesture type: " 158 NOTREACHED() << "Invalid source gesture type: "
158 << WebInputEvent::GetName(type); 159 << WebInputEvent::GetName(type);
159 return -1; 160 return -1;
160 } 161 }
161 } 162 }
162 163
164 void RecordToolTypeForActionDown(MotionEventAndroid& event) {
165 MotionEventAndroid::Action action = event.GetAction();
166 if (action == MotionEventAndroid::ACTION_DOWN ||
167 action == MotionEventAndroid::ACTION_POINTER_DOWN ||
168 action == MotionEventAndroid::ACTION_BUTTON_PRESS) {
169 UMA_HISTOGRAM_ENUMERATION("Event.AndroidActionDown.ToolType",
170 event.GetToolType(0),
171 MotionEventAndroid::TOOL_TYPE_ERASER + 1);
rkaplow 2016/12/02 20:19:06 instead of tool_type_eraser, you should have a TOO
mustaq 2016/12/02 20:37:17 Done.
172 }
173 }
174
163 } // namespace 175 } // namespace
164 176
165 // Enables a callback when the underlying WebContents is destroyed, to enable 177 // Enables a callback when the underlying WebContents is destroyed, to enable
166 // nulling the back-pointer. 178 // nulling the back-pointer.
167 class ContentViewCoreImpl::ContentViewUserData 179 class ContentViewCoreImpl::ContentViewUserData
168 : public base::SupportsUserData::Data { 180 : public base::SupportsUserData::Data {
169 public: 181 public:
170 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) 182 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core)
171 : content_view_core_(content_view_core) { 183 : content_view_core_(content_view_core) {
172 } 184 }
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 jint android_tool_type_0, 920 jint android_tool_type_0,
909 jint android_tool_type_1, 921 jint android_tool_type_1,
910 jint android_button_state, 922 jint android_button_state,
911 jint android_meta_state, 923 jint android_meta_state,
912 jboolean is_touch_handle_event) { 924 jboolean is_touch_handle_event) {
913 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 925 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
914 // Avoid synthesizing a touch event if it cannot be forwarded. 926 // Avoid synthesizing a touch event if it cannot be forwarded.
915 if (!rwhv) 927 if (!rwhv)
916 return false; 928 return false;
917 929
918 ui::MotionEventAndroid::Pointer pointer0(pointer_id_0, 930 MotionEventAndroid::Pointer pointer0(pointer_id_0,
919 pos_x_0, 931 pos_x_0,
920 pos_y_0, 932 pos_y_0,
921 touch_major_0, 933 touch_major_0,
922 touch_minor_0, 934 touch_minor_0,
923 orientation_0, 935 orientation_0,
924 tilt_0, 936 tilt_0,
925 android_tool_type_0); 937 android_tool_type_0);
926 ui::MotionEventAndroid::Pointer pointer1(pointer_id_1, 938 MotionEventAndroid::Pointer pointer1(pointer_id_1,
927 pos_x_1, 939 pos_x_1,
928 pos_y_1, 940 pos_y_1,
929 touch_major_1, 941 touch_major_1,
930 touch_minor_1, 942 touch_minor_1,
931 orientation_1, 943 orientation_1,
932 tilt_1, 944 tilt_1,
933 android_tool_type_1); 945 android_tool_type_1);
934 ui::MotionEventAndroid event(1.f / dpi_scale(), 946 MotionEventAndroid event(1.f / dpi_scale(),
935 env, 947 env,
936 motion_event, 948 motion_event,
937 time_ms, 949 time_ms,
938 android_action, 950 android_action,
939 pointer_count, 951 pointer_count,
940 history_size, 952 history_size,
941 action_index, 953 action_index,
942 android_button_state, 954 android_button_state,
943 android_meta_state, 955 android_meta_state,
944 raw_pos_x - pos_x_0, 956 raw_pos_x - pos_x_0,
945 raw_pos_y - pos_y_0, 957 raw_pos_y - pos_y_0,
946 &pointer0, 958 &pointer0,
947 &pointer1); 959 &pointer1);
948 960
961 RecordToolTypeForActionDown(event);
962
949 return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event) 963 return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event)
950 : rwhv->OnTouchEvent(event); 964 : rwhv->OnTouchEvent(event);
951 } 965 }
952 966
953 jboolean ContentViewCoreImpl::SendMouseEvent( 967 jboolean ContentViewCoreImpl::SendMouseEvent(
954 JNIEnv* env, 968 JNIEnv* env,
955 const JavaParamRef<jobject>& obj, 969 const JavaParamRef<jobject>& obj,
956 jlong time_ms, 970 jlong time_ms,
957 jint android_action, 971 jint android_action,
958 jfloat x, 972 jfloat x,
959 jfloat y, 973 jfloat y,
960 jint pointer_id, 974 jint pointer_id,
961 jfloat pressure, 975 jfloat pressure,
962 jfloat orientation, 976 jfloat orientation,
963 jfloat tilt, 977 jfloat tilt,
964 jint android_changed_button, 978 jint android_changed_button,
965 jint android_button_state, 979 jint android_button_state,
966 jint android_meta_state, 980 jint android_meta_state,
967 jint android_tool_type) { 981 jint android_tool_type) {
968 982
969 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 983 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
970 if (!rwhv) 984 if (!rwhv)
971 return false; 985 return false;
972 986
973 // Construct a motion_event object minimally, only to convert the raw 987 // Construct a motion_event object minimally, only to convert the raw
974 // parameters to ui::MotionEvent values. Since we used only the cached values 988 // parameters to ui::MotionEvent values. Since we used only the cached values
975 // at index=0, it is okay to even pass a null event to the constructor. 989 // at index=0, it is okay to even pass a null event to the constructor.
976 ui::MotionEventAndroid::Pointer pointer0( 990 MotionEventAndroid::Pointer pointer0(
977 pointer_id, x, y, 0.0f /* touch_major */, 0.0f /* touch_minor */, 991 pointer_id, x, y, 0.0f /* touch_major */, 0.0f /* touch_minor */,
978 orientation, tilt, android_tool_type); 992 orientation, tilt, android_tool_type);
979 993
980 ui::MotionEventAndroid motion_event(1.f / dpi_scale(), 994 MotionEventAndroid motion_event(1.f / dpi_scale(),
981 env, 995 env,
982 nullptr /* event */, 996 nullptr /* event */,
983 time_ms, 997 time_ms,
984 android_action, 998 android_action,
985 1 /* pointer_count */, 999 1 /* pointer_count */,
986 0 /* history_size */, 1000 0 /* history_size */,
987 0 /* action_index */, 1001 0 /* action_index */,
988 android_button_state, 1002 android_button_state,
989 android_meta_state, 1003 android_meta_state,
990 0 /* raw_offset_x_pixels */, 1004 0 /* raw_offset_x_pixels */,
991 0 /* raw_offset_y_pixels */, 1005 0 /* raw_offset_y_pixels */,
992 &pointer0, 1006 &pointer0,
993 nullptr); 1007 nullptr);
994 1008
1009 RecordToolTypeForActionDown(motion_event);
1010
995 // Note: This relies on identical button enum values in MotionEvent and 1011 // Note: This relies on identical button enum values in MotionEvent and
996 // MotionEventAndroid. 1012 // MotionEventAndroid.
997 rwhv->SendMouseEvent(motion_event, android_changed_button); 1013 rwhv->SendMouseEvent(motion_event, android_changed_button);
998 1014
999 return true; 1015 return true;
1000 } 1016 }
1001 1017
1002 jboolean ContentViewCoreImpl::SendMouseWheelEvent( 1018 jboolean ContentViewCoreImpl::SendMouseWheelEvent(
1003 JNIEnv* env, 1019 JNIEnv* env,
1004 const JavaParamRef<jobject>& obj, 1020 const JavaParamRef<jobject>& obj,
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 return ScopedJavaLocalRef<jobject>(); 1614 return ScopedJavaLocalRef<jobject>();
1599 1615
1600 return view->GetJavaObject(); 1616 return view->GetJavaObject();
1601 } 1617 }
1602 1618
1603 bool RegisterContentViewCore(JNIEnv* env) { 1619 bool RegisterContentViewCore(JNIEnv* env) {
1604 return RegisterNativesImpl(env); 1620 return RegisterNativesImpl(env);
1605 } 1621 }
1606 1622
1607 } // namespace content 1623 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698