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

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

Issue 2484213003: Convert performance monitor to the subscription model. (Closed)
Patch Set: same Created 4 years, 1 month 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "wtf/StdLibExtras.h" 52 #include "wtf/StdLibExtras.h"
53 #include "wtf/Threading.h" 53 #include "wtf/Threading.h"
54 #include "wtf/Vector.h" 54 #include "wtf/Vector.h"
55 #include <memory> 55 #include <memory>
56 56
57 using namespace WTF; 57 using namespace WTF;
58 58
59 namespace blink { 59 namespace blink {
60 namespace { 60 namespace {
61 61
62 static const double kBlockedWarningThresholdMillis = 100.0;
63
64 enum PassiveForcedListenerResultType { 62 enum PassiveForcedListenerResultType {
65 PreventDefaultNotCalled, 63 PreventDefaultNotCalled,
66 DocumentLevelTouchPreventDefaultCalled, 64 DocumentLevelTouchPreventDefaultCalled,
67 PassiveForcedListenerResultTypeMax 65 PassiveForcedListenerResultTypeMax
68 }; 66 };
69 67
70 Event::PassiveMode eventPassiveMode( 68 Event::PassiveMode eventPassiveMode(
71 const RegisteredEventListener& eventListener) { 69 const RegisteredEventListener& eventListener) {
72 if (!eventListener.passive()) 70 if (!eventListener.passive())
73 return Event::PassiveMode::NotPassive; 71 return Event::PassiveMode::NotPassive;
(...skipping 15 matching lines...) Expand all
89 return eventType == EventTypeNames::touchstart || 87 return eventType == EventTypeNames::touchstart ||
90 eventType == EventTypeNames::touchmove; 88 eventType == EventTypeNames::touchmove;
91 } 89 }
92 90
93 bool isScrollBlockingEvent(const AtomicString& eventType) { 91 bool isScrollBlockingEvent(const AtomicString& eventType) {
94 return isTouchScrollBlockingEvent(eventType) || 92 return isTouchScrollBlockingEvent(eventType) ||
95 eventType == EventTypeNames::mousewheel || 93 eventType == EventTypeNames::mousewheel ||
96 eventType == EventTypeNames::wheel; 94 eventType == EventTypeNames::wheel;
97 } 95 }
98 96
99 double blockedEventsWarningThreshold(ExecutionContext* context, Event* event) { 97 double blockedEventsWarningThreshold(ExecutionContext* context,
98 const Event* event) {
100 if (!event->cancelable()) 99 if (!event->cancelable())
101 return 0.0; 100 return 0.0;
102 if (!isScrollBlockingEvent(event->type())) 101 if (!isScrollBlockingEvent(event->type()))
103 return 0.0; 102 return 0.0;
104 103 return PerformanceMonitor::threshold(context,
105 return PerformanceMonitor::enabled(context) 104 PerformanceMonitor::kBlockedEvent);
106 ? kBlockedWarningThresholdMillis / 1000
107 : 0;
108 } 105 }
109 106
110 void reportBlockedEvent(ExecutionContext* context, 107 void reportBlockedEvent(ExecutionContext* context,
111 const Event* event, 108 const Event* event,
112 RegisteredEventListener* registeredListener, 109 RegisteredEventListener* registeredListener,
113 double delayedSeconds) { 110 double delayedSeconds) {
114 if (registeredListener->listener()->type() != 111 if (registeredListener->listener()->type() !=
115 EventListener::JSEventListenerType) 112 EventListener::JSEventListenerType)
116 return; 113 return;
117 114
(...skipping 10 matching lines...) Expand all
128 "Handling of '%s' input event was delayed for %ld ms due to main thread " 125 "Handling of '%s' input event was delayed for %ld ms due to main thread "
129 "being busy. " 126 "being busy. "
130 "Consider marking event handler as 'passive' to make the page more " 127 "Consider marking event handler as 'passive' to make the page more "
131 "responsive.", 128 "responsive.",
132 event->type().getString().utf8().data(), lround(delayedSeconds * 1000)); 129 event->type().getString().utf8().data(), lround(delayedSeconds * 1000));
133 130
134 v8::Local<v8::Function> function = 131 v8::Local<v8::Function> function =
135 eventListenerEffectiveFunction(v8Listener->isolate(), handler); 132 eventListenerEffectiveFunction(v8Listener->isolate(), handler);
136 std::unique_ptr<SourceLocation> location = 133 std::unique_ptr<SourceLocation> location =
137 SourceLocation::fromFunction(function); 134 SourceLocation::fromFunction(function);
138 PerformanceMonitor::logViolation(WarningMessageLevel, context, messageText, 135
139 std::move(location)); 136 PerformanceMonitor::reportGenericViolation(
137 context, PerformanceMonitor::kBlockedEvent, messageText, delayedSeconds,
138 std::move(location));
140 registeredListener->setBlockedEventWarningEmitted(); 139 registeredListener->setBlockedEventWarningEmitted();
141 } 140 }
142 141
143 } // namespace 142 } // namespace
144 143
145 EventTargetData::EventTargetData() {} 144 EventTargetData::EventTargetData() {}
146 145
147 EventTargetData::~EventTargetData() {} 146 EventTargetData::~EventTargetData() {}
148 147
149 DEFINE_TRACE(EventTargetData) { 148 DEFINE_TRACE(EventTargetData) {
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // they have one less listener to invoke. 755 // they have one less listener to invoke.
757 if (d->firingEventIterators) { 756 if (d->firingEventIterators) {
758 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 757 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
759 d->firingEventIterators->at(i).iterator = 0; 758 d->firingEventIterators->at(i).iterator = 0;
760 d->firingEventIterators->at(i).end = 0; 759 d->firingEventIterators->at(i).end = 0;
761 } 760 }
762 } 761 }
763 } 762 }
764 763
765 } // namespace blink 764 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698