Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / browser / renderer_host / event_with_latency_info.h
blob37f67475b38126d506f45ec00856aec1474ef8fa
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"
12 namespace blink {
13 class WebGestureEvent;
14 class WebMouseEvent;
15 class WebMouseWheelEvent;
16 class WebTouchEvent;
19 namespace content {
21 template <typename T>
22 class EventWithLatencyInfo {
23 public:
24 T event;
25 mutable ui::LatencyInfo latency;
27 explicit EventWithLatencyInfo(const T& e) : event(e) {}
29 EventWithLatencyInfo(const T& e, const ui::LatencyInfo& l)
30 : event(e), latency(l) {}
32 EventWithLatencyInfo() {}
34 bool CanCoalesceWith(const EventWithLatencyInfo& other)
35 const WARN_UNUSED_RESULT {
36 return WebInputEventTraits::CanCoalesce(other.event, event);
39 void CoalesceWith(const EventWithLatencyInfo& other) {
40 WebInputEventTraits::Coalesce(other.event, &event);
41 // When coalescing two input events, we keep the oldest LatencyInfo
42 // for Telemetry latency test since it will represent the longest
43 // latency.
44 if (other.latency.trace_id >= 0 &&
45 (latency.trace_id < 0 || other.latency.trace_id < latency.trace_id))
46 latency = other.latency;
50 typedef EventWithLatencyInfo<blink::WebGestureEvent>
51 GestureEventWithLatencyInfo;
52 typedef EventWithLatencyInfo<blink::WebMouseWheelEvent>
53 MouseWheelEventWithLatencyInfo;
54 typedef EventWithLatencyInfo<blink::WebMouseEvent>
55 MouseEventWithLatencyInfo;
56 typedef EventWithLatencyInfo<blink::WebTouchEvent>
57 TouchEventWithLatencyInfo;
59 } // namespace content
61 #endif // CONTENT_BROWSER_RENDERER_HOST_EVENT_WITH_LATENCY_INFO_H_