summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-16 18:17:44 +0000
committerjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-16 18:17:44 +0000
commit8e299aa93e66370ad703ae477e86083b9c104f34 (patch)
treea20af1c9b9e9cb30d4c80a9b693a8eefb4753761 /content
parentfb16be49af31a2f000ab8277b9e77d48ecf5825b (diff)
downloadchromium_src-8e299aa93e66370ad703ae477e86083b9c104f34.zip
chromium_src-8e299aa93e66370ad703ae477e86083b9c104f34.tar.gz
chromium_src-8e299aa93e66370ad703ae477e86083b9c104f34.tar.bz2
Expose WebInputEvent::Type string conversion with WebInputEventTraits
Move the WebInputEvent::Type to string conversion code from RenderWidget to WebInputEventTraits. This is particularly useful for event tracing at various stages of the input pipeline. Review URL: https://codereview.chromium.org/27336003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/input/immediate_input_router.cc7
-rw-r--r--content/common/input/web_input_event_traits.cc47
-rw-r--r--content/common/input/web_input_event_traits.h1
-rw-r--r--content/renderer/render_widget.cc48
4 files changed, 56 insertions, 47 deletions
diff --git a/content/browser/renderer_host/input/immediate_input_router.cc b/content/browser/renderer_host/input/immediate_input_router.cc
index 4334aac..3ccc913 100644
--- a/content/browser/renderer_host/input/immediate_input_router.cc
+++ b/content/browser/renderer_host/input/immediate_input_router.cc
@@ -15,6 +15,7 @@
#include "content/browser/renderer_host/overscroll_controller.h"
#include "content/common/content_constants_internal.h"
#include "content/common/edit_command.h"
+#include "content/common/input/web_input_event_traits.h"
#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
#include "content/port/common/input_event_ack_state.h"
@@ -322,7 +323,8 @@ void ImmediateInputRouter::FilterAndSendWebInputEvent(
const WebInputEvent& input_event,
const ui::LatencyInfo& latency_info,
bool is_keyboard_shortcut) {
- TRACE_EVENT0("input", "ImmediateInputRouter::FilterAndSendWebInputEvent");
+ TRACE_EVENT1("input", "ImmediateInputRouter::FilterAndSendWebInputEvent",
+ "type", WebInputEventTraits::GetName(input_event.type));
// Yield events to the OverscrollController before forwarding.
OverscrollController* controller = client_->GetOverscrollController();
@@ -427,7 +429,8 @@ void ImmediateInputRouter::ProcessInputEventAck(
InputEventAckState ack_result,
const ui::LatencyInfo& latency_info,
AckSource ack_source) {
- TRACE_EVENT1("input", "ImmediateInputRouter::ProcessInputEventAck",
+ TRACE_EVENT2("input", "ImmediateInputRouter::ProcessInputEventAck",
+ "type", WebInputEventTraits::GetName(event_type),
"ack", GetEventAckName(ack_result));
// Note: The keyboard ack must be treated carefully, as it may result in
diff --git a/content/common/input/web_input_event_traits.cc b/content/common/input/web_input_event_traits.cc
index cf8cd3e..2f2eb7f 100644
--- a/content/common/input/web_input_event_traits.cc
+++ b/content/common/input/web_input_event_traits.cc
@@ -200,6 +200,53 @@ bool Apply(Operator op,
} // namespace
+const char* WebInputEventTraits::GetName(WebInputEvent::Type type) {
+#define CASE_TYPE(t) case WebInputEvent::t: return #t
+ switch(type) {
+ CASE_TYPE(Undefined);
+ CASE_TYPE(MouseDown);
+ CASE_TYPE(MouseUp);
+ CASE_TYPE(MouseMove);
+ CASE_TYPE(MouseEnter);
+ CASE_TYPE(MouseLeave);
+ CASE_TYPE(ContextMenu);
+ CASE_TYPE(MouseWheel);
+ CASE_TYPE(RawKeyDown);
+ CASE_TYPE(KeyDown);
+ CASE_TYPE(KeyUp);
+ CASE_TYPE(Char);
+ CASE_TYPE(GestureScrollBegin);
+ CASE_TYPE(GestureScrollEnd);
+ CASE_TYPE(GestureScrollUpdate);
+ CASE_TYPE(GestureFlingStart);
+ CASE_TYPE(GestureFlingCancel);
+ CASE_TYPE(GestureShowPress);
+ CASE_TYPE(GestureTap);
+ CASE_TYPE(GestureTapUnconfirmed);
+ CASE_TYPE(GestureTapDown);
+ CASE_TYPE(GestureTapCancel);
+ CASE_TYPE(GestureDoubleTap);
+ CASE_TYPE(GestureTwoFingerTap);
+ CASE_TYPE(GestureLongPress);
+ CASE_TYPE(GestureLongTap);
+ CASE_TYPE(GesturePinchBegin);
+ CASE_TYPE(GesturePinchEnd);
+ CASE_TYPE(GesturePinchUpdate);
+ CASE_TYPE(TouchStart);
+ CASE_TYPE(TouchMove);
+ CASE_TYPE(TouchEnd);
+ CASE_TYPE(TouchCancel);
+ default:
+ // Must include default to let WebKit::WebInputEvent add new event types
+ // before they're added here.
+ DLOG(WARNING) <<
+ "Unhandled WebInputEvent type in WebInputEventTraits::GetName.\n";
+ break;
+ }
+#undef CASE_TYPE
+ return "";
+}
+
size_t WebInputEventTraits::GetSize(WebInputEvent::Type type) {
size_t size = 0;
Apply(WebInputEventSize(), type, type, &size);
diff --git a/content/common/input/web_input_event_traits.h b/content/common/input/web_input_event_traits.h
index 078e141..dba5f9c 100644
--- a/content/common/input/web_input_event_traits.h
+++ b/content/common/input/web_input_event_traits.h
@@ -14,6 +14,7 @@ namespace content {
// Utility class for performing operations on and with WebInputEvents.
class WebInputEventTraits {
public:
+ static const char* GetName(WebKit::WebInputEvent::Type type);
static size_t GetSize(WebKit::WebInputEvent::Type type);
static ScopedWebInputEvent Clone(const WebKit::WebInputEvent& event);
static void Delete(WebKit::WebInputEvent* event);
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 1cb162a..18f8556 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -22,6 +22,7 @@
#include "content/child/npapi/webplugin.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
+#include "content/common/input/web_input_event_traits.h"
#include "content/common/input_messages.h"
#include "content/common/swapped_out_messages.h"
#include "content/common/view_messages.h"
@@ -99,50 +100,6 @@ using WebKit::WebVector;
using WebKit::WebWidget;
namespace {
-const char* GetEventName(WebInputEvent::Type type) {
-#define CASE_TYPE(t) case WebInputEvent::t: return #t
- switch(type) {
- CASE_TYPE(Undefined);
- CASE_TYPE(MouseDown);
- CASE_TYPE(MouseUp);
- CASE_TYPE(MouseMove);
- CASE_TYPE(MouseEnter);
- CASE_TYPE(MouseLeave);
- CASE_TYPE(ContextMenu);
- CASE_TYPE(MouseWheel);
- CASE_TYPE(RawKeyDown);
- CASE_TYPE(KeyDown);
- CASE_TYPE(KeyUp);
- CASE_TYPE(Char);
- CASE_TYPE(GestureScrollBegin);
- CASE_TYPE(GestureScrollEnd);
- CASE_TYPE(GestureScrollUpdate);
- CASE_TYPE(GestureFlingStart);
- CASE_TYPE(GestureFlingCancel);
- CASE_TYPE(GestureTap);
- CASE_TYPE(GestureTapUnconfirmed);
- CASE_TYPE(GestureTapDown);
- CASE_TYPE(GestureTapCancel);
- CASE_TYPE(GestureDoubleTap);
- CASE_TYPE(GestureTwoFingerTap);
- CASE_TYPE(GestureLongPress);
- CASE_TYPE(GestureLongTap);
- CASE_TYPE(GesturePinchBegin);
- CASE_TYPE(GesturePinchEnd);
- CASE_TYPE(GesturePinchUpdate);
- CASE_TYPE(TouchStart);
- CASE_TYPE(TouchMove);
- CASE_TYPE(TouchEnd);
- CASE_TYPE(TouchCancel);
- default:
- // Must include default to let WebKit::WebInputEvent add new event types
- // before they're added here.
- DLOG(WARNING) << "Unhandled WebInputEvent type in GetEventName.\n";
- break;
- }
-#undef CASE_TYPE
- return "";
-}
typedef std::map<std::string, ui::TextInputMode> TextInputModeMap;
@@ -1072,7 +1029,8 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
return;
}
- const char* const event_name = GetEventName(input_event->type);
+ const char* const event_name =
+ WebInputEventTraits::GetName(input_event->type);
TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent",
"event", event_name);