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

Side by Side Diff: content/common/input/event_with_latency_info.h

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Rebase Created 3 years, 11 months 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 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ 5 #ifndef CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_
6 #define CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ 6 #define CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 class EventWithLatencyInfo { 42 class EventWithLatencyInfo {
43 public: 43 public:
44 T event; 44 T event;
45 mutable ui::LatencyInfo latency; 45 mutable ui::LatencyInfo latency;
46 46
47 explicit EventWithLatencyInfo(const T& e) : event(e) {} 47 explicit EventWithLatencyInfo(const T& e) : event(e) {}
48 48
49 EventWithLatencyInfo(const T& e, const ui::LatencyInfo& l) 49 EventWithLatencyInfo(const T& e, const ui::LatencyInfo& l)
50 : event(e), latency(l) {} 50 : event(e), latency(l) {}
51 51
52 EventWithLatencyInfo(blink::WebInputEvent::Type type,
53 int modifiers,
54 double timeStampSeconds,
55 const ui::LatencyInfo& l)
56 : event(type, modifiers, timeStampSeconds), latency(l) {}
57
52 EventWithLatencyInfo() {} 58 EventWithLatencyInfo() {}
53 59
54 bool CanCoalesceWith(const EventWithLatencyInfo& other) 60 bool CanCoalesceWith(const EventWithLatencyInfo& other)
55 const WARN_UNUSED_RESULT { 61 const WARN_UNUSED_RESULT {
56 if (other.event.type != event.type) 62 if (other.event.type != event.type)
57 return false; 63 return false;
58 64
59 DCHECK_EQ(sizeof(T), event.size); 65 DCHECK_EQ(sizeof(T), event.size);
60 DCHECK_EQ(sizeof(T), other.event.size); 66 DCHECK_EQ(sizeof(T), other.event.size);
61 67
62 return ui::CanCoalesce(other.event, event); 68 return ui::CanCoalesce(other.event, event);
63 } 69 }
64 70
65 void CoalesceWith(const EventWithLatencyInfo& other) { 71 void CoalesceWith(const EventWithLatencyInfo& other) {
66 // |other| should be a newer event than |this|. 72 // |other| should be a newer event than |this|.
67 if (other.latency.trace_id() >= 0 && latency.trace_id() >= 0) 73 if (other.latency.trace_id() >= 0 && latency.trace_id() >= 0)
68 DCHECK_GT(other.latency.trace_id(), latency.trace_id()); 74 DCHECK_GT(other.latency.trace_id(), latency.trace_id());
69 75
70 // New events get coalesced into older events, and the newer timestamp 76 // New events get coalesced into older events, and the newer timestamp
71 // should always be preserved. 77 // should always be preserved.
72 const double time_stamp_seconds = other.event.timeStampSeconds; 78 const double time_stamp_seconds = other.event.timeStampSeconds;
73 ui::Coalesce(other.event, &event); 79 ui::Coalesce(other.event, &event);
74 event.timeStampSeconds = time_stamp_seconds; 80 event.setTimeStampSeconds(time_stamp_seconds);
75 81
76 // When coalescing two input events, we keep the oldest LatencyInfo 82 // When coalescing two input events, we keep the oldest LatencyInfo
77 // for Telemetry latency tests, since it will represent the longest 83 // for Telemetry latency tests, since it will represent the longest
78 // latency. 84 // latency.
79 other.latency = latency; 85 other.latency = latency;
80 other.latency.set_coalesced(); 86 other.latency.set_coalesced();
81 } 87 }
82 }; 88 };
83 89
84 typedef EventWithLatencyInfo<blink::WebGestureEvent> 90 typedef EventWithLatencyInfo<blink::WebGestureEvent>
85 GestureEventWithLatencyInfo; 91 GestureEventWithLatencyInfo;
86 typedef EventWithLatencyInfo<blink::WebMouseWheelEvent> 92 typedef EventWithLatencyInfo<blink::WebMouseWheelEvent>
87 MouseWheelEventWithLatencyInfo; 93 MouseWheelEventWithLatencyInfo;
88 typedef EventWithLatencyInfo<blink::WebMouseEvent> 94 typedef EventWithLatencyInfo<blink::WebMouseEvent>
89 MouseEventWithLatencyInfo; 95 MouseEventWithLatencyInfo;
90 typedef EventWithLatencyInfo<blink::WebTouchEvent> 96 typedef EventWithLatencyInfo<blink::WebTouchEvent>
91 TouchEventWithLatencyInfo; 97 TouchEventWithLatencyInfo;
92 98
93 } // namespace content 99 } // namespace content
94 100
95 #endif // CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ 101 #endif // CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698