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

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

Issue 2091213002: Decouple EventWithLatencyInfo and WebInputEventTraits [extern templates] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reference a better bug Created 4 years, 5 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"
9 #include "content/common/content_export.h"
10 #include "ipc/export_template.h"
11 #include "third_party/WebKit/public/web/WebInputEvent.h"
8 #include "ui/events/latency_info.h" 12 #include "ui/events/latency_info.h"
9 13
10 #include "content/common/input/web_input_event_traits.h"
11
12 namespace blink {
13 class WebGestureEvent;
14 class WebMouseEvent;
15 class WebMouseWheelEvent;
16 class WebTouchEvent;
17 }
18
19 namespace content { 14 namespace content {
20 15
21 template <typename T> 16 template <typename T>
22 class EventWithLatencyInfo { 17 class EventWithLatencyInfo {
23 public: 18 public:
24 T event; 19 T event;
25 mutable ui::LatencyInfo latency; 20 mutable ui::LatencyInfo latency;
26 21
22 EventWithLatencyInfo() {}
27 explicit EventWithLatencyInfo(const T& e) : event(e) {} 23 explicit EventWithLatencyInfo(const T& e) : event(e) {}
28
29 EventWithLatencyInfo(const T& e, const ui::LatencyInfo& l) 24 EventWithLatencyInfo(const T& e, const ui::LatencyInfo& l)
30 : event(e), latency(l) {} 25 : event(e), latency(l) {}
31 26
32 EventWithLatencyInfo() {} 27 #if defined(OS_WIN)
28 // Explicitly declare these, otherwise invoking the move constructor via
29 // dllimport on Windows generates a link error. See http://crbug.com/623844.
30 // Declare all three otherwise the move constructor will hide the others.
31 EventWithLatencyInfo(const EventWithLatencyInfo& other) = default;
32 EventWithLatencyInfo(EventWithLatencyInfo&& other) = default;
33 EventWithLatencyInfo& operator=(const EventWithLatencyInfo& other) = default;
34 #endif
33 35
34 bool CanCoalesceWith(const EventWithLatencyInfo& other) 36 bool CanCoalesceWith(const EventWithLatencyInfo& other) const
35 const WARN_UNUSED_RESULT { 37 WARN_UNUSED_RESULT;
36 return WebInputEventTraits::CanCoalesce(other.event, event); 38 void CoalesceWith(const EventWithLatencyInfo& other);
37 } 39 };
38 40
39 void CoalesceWith(const EventWithLatencyInfo& other) { 41 // The required types are known beforehand, so avoid compiling the required
40 // |other| should be a newer event than |this|. 42 // template in each translation unit that instantiates one by declaring them
41 if (other.latency.trace_id() >= 0 && latency.trace_id() >= 0) 43 // extern. This also allows some internals to be deferred to the .cc. If another
42 DCHECK_GT(other.latency.trace_id(), latency.trace_id()); 44 // type is instantiated, the compiler will generate code for everything except
43 WebInputEventTraits::Coalesce(other.event, &event); 45 // [Can]CoalesceWith(): If those methods are also _invoked_ there will be a link
44 // When coalescing two input events, we keep the oldest LatencyInfo 46 // error unless they're defined somewhere as well.
45 // for Telemetry latency tests, since it will represent the longest 47 extern template class EXPORT_TEMPLATE_DECLARE(CONTENT_EXPORT)
46 // latency. 48 EventWithLatencyInfo<blink::WebGestureEvent>;
47 other.latency = latency; 49 extern template class EXPORT_TEMPLATE_DECLARE(CONTENT_EXPORT)
48 other.latency.set_coalesced(); 50 EventWithLatencyInfo<blink::WebMouseWheelEvent>;
49 } 51 extern template class EXPORT_TEMPLATE_DECLARE(CONTENT_EXPORT)
50 }; 52 EventWithLatencyInfo<blink::WebMouseEvent>;
53 extern template class EXPORT_TEMPLATE_DECLARE(CONTENT_EXPORT)
54 EventWithLatencyInfo<blink::WebTouchEvent>;
51 55
52 typedef EventWithLatencyInfo<blink::WebGestureEvent> 56 typedef EventWithLatencyInfo<blink::WebGestureEvent>
53 GestureEventWithLatencyInfo; 57 GestureEventWithLatencyInfo;
54 typedef EventWithLatencyInfo<blink::WebMouseWheelEvent> 58 typedef EventWithLatencyInfo<blink::WebMouseWheelEvent>
55 MouseWheelEventWithLatencyInfo; 59 MouseWheelEventWithLatencyInfo;
56 typedef EventWithLatencyInfo<blink::WebMouseEvent> 60 typedef EventWithLatencyInfo<blink::WebMouseEvent>
57 MouseEventWithLatencyInfo; 61 MouseEventWithLatencyInfo;
58 typedef EventWithLatencyInfo<blink::WebTouchEvent> 62 typedef EventWithLatencyInfo<blink::WebTouchEvent>
59 TouchEventWithLatencyInfo; 63 TouchEventWithLatencyInfo;
60 64
61 } // namespace content 65 } // namespace content
62 66
63 #endif // CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ 67 #endif // CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/input/event_with_latency_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698