Add ICU message format support
[chromium-blink-merge.git] / content / browser / renderer_host / event_with_latency_info.h
blobfb9af6223533c774fd206ebf886fcb7dea4032b4
1 // Copyright 2013 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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_EVENT_WITH_LATENCY_INFO_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_EVENT_WITH_LATENCY_INFO_H_
8 #include "ui/events/latency_info.h"
10 #include "content/common/input/web_input_event_traits.h"
11 #include "content/public/browser/native_web_keyboard_event.h"
13 namespace blink {
14 class WebGestureEvent;
15 class WebMouseEvent;
16 class WebMouseWheelEvent;
17 class WebTouchEvent;
20 namespace content {
22 template <typename T>
23 class EventWithLatencyInfo {
24 public:
25 T event;
26 mutable ui::LatencyInfo latency;
28 explicit EventWithLatencyInfo(const T& e) : event(e) {}
30 EventWithLatencyInfo(const T& e, const ui::LatencyInfo& l)
31 : event(e), latency(l) {}
33 EventWithLatencyInfo() {}
35 bool CanCoalesceWith(const EventWithLatencyInfo& other)
36 const WARN_UNUSED_RESULT {
37 return WebInputEventTraits::CanCoalesce(other.event, event);
40 void CoalesceWith(const EventWithLatencyInfo& other) {
41 WebInputEventTraits::Coalesce(other.event, &event);
42 // When coalescing two input events, we keep the oldest LatencyInfo
43 // for Telemetry latency test since it will represent the longest
44 // latency.
45 if (other.latency.trace_id() >= 0 &&
46 (latency.trace_id() < 0 ||
47 other.latency.trace_id() < latency.trace_id()))
48 latency = other.latency;
52 typedef EventWithLatencyInfo<NativeWebKeyboardEvent>
53 NativeWebKeyboardEventWithLatencyInfo;
54 typedef EventWithLatencyInfo<blink::WebGestureEvent>
55 GestureEventWithLatencyInfo;
56 typedef EventWithLatencyInfo<blink::WebMouseWheelEvent>
57 MouseWheelEventWithLatencyInfo;
58 typedef EventWithLatencyInfo<blink::WebMouseEvent>
59 MouseEventWithLatencyInfo;
60 typedef EventWithLatencyInfo<blink::WebTouchEvent>
61 TouchEventWithLatencyInfo;
63 } // namespace content
65 #endif // CONTENT_BROWSER_RENDERER_HOST_EVENT_WITH_LATENCY_INFO_H_