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

Side by Side Diff: third_party/WebKit/Source/core/events/Event.cpp

Issue 1936853002: Assert event timestamp to be monotonic and not from future Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to histogram Created 4 years, 2 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 /* 1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 12 matching lines...) Expand all
23 #include "core/events/Event.h" 23 #include "core/events/Event.h"
24 24
25 #include "core/dom/StaticNodeList.h" 25 #include "core/dom/StaticNodeList.h"
26 #include "core/events/EventDispatchMediator.h" 26 #include "core/events/EventDispatchMediator.h"
27 #include "core/events/EventTarget.h" 27 #include "core/events/EventTarget.h"
28 #include "core/frame/HostsUsingFeatures.h" 28 #include "core/frame/HostsUsingFeatures.h"
29 #include "core/frame/UseCounter.h" 29 #include "core/frame/UseCounter.h"
30 #include "core/svg/SVGElement.h" 30 #include "core/svg/SVGElement.h"
31 #include "core/timing/DOMWindowPerformance.h" 31 #include "core/timing/DOMWindowPerformance.h"
32 #include "core/timing/Performance.h" 32 #include "core/timing/Performance.h"
33 #include "platform/Histogram.h"
33 #include "wtf/CurrentTime.h" 34 #include "wtf/CurrentTime.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 static bool isEventTypeScopedInV0(const AtomicString& eventType) 38 static bool isEventTypeScopedInV0(const AtomicString& eventType)
38 { 39 {
39 // WebKit never allowed selectstart event to cross the the shadow DOM bounda ry. 40 // WebKit never allowed selectstart event to cross the the shadow DOM bounda ry.
40 // Changing this breaks existing sites. 41 // Changing this breaks existing sites.
41 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. 42 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details.
42 return eventType == EventTypeNames::abort 43 return eventType == EventTypeNames::abort
(...skipping 10 matching lines...) Expand all
53 54
54 Event::Event() 55 Event::Event()
55 : Event("", false, false) 56 : Event("", false, false)
56 { 57 {
57 m_wasInitialized = false; 58 m_wasInitialized = false;
58 } 59 }
59 60
60 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, double platformTimeStamp) 61 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, double platformTimeStamp)
61 : Event(eventType, canBubbleArg, cancelableArg, ComposedMode::Scoped, platfo rmTimeStamp) 62 : Event(eventType, canBubbleArg, cancelableArg, ComposedMode::Scoped, platfo rmTimeStamp)
62 { 63 {
64 // Verify that timestamp is coming from the monotonic clock.
65 double delta = monotonicallyIncreasingTime() - platformTimeStamp;
66 bool hasValidTimebase = delta >= 0 && delta <= 60 * 1000;
67
68 DEFINE_STATIC_LOCAL(BooleanHistogram, histogram, ("Event.TimestampHasValidTi mebase.Renderer"));
69 histogram.count(hasValidTimebase);
70 DCHECK(hasValidTimebase);
63 } 71 }
64 72
65 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, ComposedMode composedMode) 73 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, ComposedMode composedMode)
66 : Event(eventType, canBubbleArg, cancelableArg, composedMode, monotonicallyI ncreasingTime()) 74 : Event(eventType, canBubbleArg, cancelableArg, composedMode, monotonicallyI ncreasingTime())
67 { 75 {
68 } 76 }
69 77
70 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, ComposedMode composedMode, double platformTimeStamp) 78 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g, ComposedMode composedMode, double platformTimeStamp)
71 : m_type(eventType) 79 : m_type(eventType)
72 , m_canBubble(canBubbleArg) 80 , m_canBubble(canBubbleArg)
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 374
367 DEFINE_TRACE(Event) 375 DEFINE_TRACE(Event)
368 { 376 {
369 visitor->trace(m_currentTarget); 377 visitor->trace(m_currentTarget);
370 visitor->trace(m_target); 378 visitor->trace(m_target);
371 visitor->trace(m_underlyingEvent); 379 visitor->trace(m_underlyingEvent);
372 visitor->trace(m_eventPath); 380 visitor->trace(m_eventPath);
373 } 381 }
374 382
375 } // namespace blink 383 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698