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

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

Issue 2484213003: Convert performance monitor to the subscription model. (Closed)
Patch Set: core export 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 if (eventListener.passiveSpecified()) 71 if (eventListener.passiveSpecified())
(...skipping 20 matching lines...) Expand all
94 return eventType == EventTypeNames::touchstart || 92 return eventType == EventTypeNames::touchstart ||
95 eventType == EventTypeNames::touchmove; 93 eventType == EventTypeNames::touchmove;
96 } 94 }
97 95
98 bool isScrollBlockingEvent(const AtomicString& eventType) { 96 bool isScrollBlockingEvent(const AtomicString& eventType) {
99 return isTouchScrollBlockingEvent(eventType) || 97 return isTouchScrollBlockingEvent(eventType) ||
100 eventType == EventTypeNames::mousewheel || 98 eventType == EventTypeNames::mousewheel ||
101 eventType == EventTypeNames::wheel; 99 eventType == EventTypeNames::wheel;
102 } 100 }
103 101
104 double blockedEventsWarningThreshold(ExecutionContext* context, Event* event) { 102 double blockedEventsWarningThreshold(ExecutionContext* context,
103 const Event* event) {
105 if (!event->cancelable()) 104 if (!event->cancelable())
106 return 0.0; 105 return 0.0;
107 if (!isScrollBlockingEvent(event->type())) 106 if (!isScrollBlockingEvent(event->type()))
108 return 0.0; 107 return 0.0;
109 108 return PerformanceMonitor::threshold(context,
110 return PerformanceMonitor::enabled(context) 109 PerformanceMonitor::kBlockedEvent);
111 ? kBlockedWarningThresholdMillis / 1000
112 : 0;
113 } 110 }
114 111
115 void reportBlockedEvent(ExecutionContext* context, 112 void reportBlockedEvent(ExecutionContext* context,
116 const Event* event, 113 const Event* event,
117 RegisteredEventListener* registeredListener, 114 RegisteredEventListener* registeredListener,
118 double delayedSeconds) { 115 double delayedSeconds) {
119 if (registeredListener->listener()->type() != 116 if (registeredListener->listener()->type() !=
120 EventListener::JSEventListenerType) 117 EventListener::JSEventListenerType)
121 return; 118 return;
122 119
(...skipping 10 matching lines...) Expand all
133 "Handling of '%s' input event was delayed for %ld ms due to main thread " 130 "Handling of '%s' input event was delayed for %ld ms due to main thread "
134 "being busy. " 131 "being busy. "
135 "Consider marking event handler as 'passive' to make the page more " 132 "Consider marking event handler as 'passive' to make the page more "
136 "responsive.", 133 "responsive.",
137 event->type().getString().utf8().data(), lround(delayedSeconds * 1000)); 134 event->type().getString().utf8().data(), lround(delayedSeconds * 1000));
138 135
139 v8::Local<v8::Function> function = 136 v8::Local<v8::Function> function =
140 eventListenerEffectiveFunction(v8Listener->isolate(), handler); 137 eventListenerEffectiveFunction(v8Listener->isolate(), handler);
141 std::unique_ptr<SourceLocation> location = 138 std::unique_ptr<SourceLocation> location =
142 SourceLocation::fromFunction(function); 139 SourceLocation::fromFunction(function);
143 PerformanceMonitor::logViolation(WarningMessageLevel, context, messageText, 140
144 std::move(location)); 141 PerformanceMonitor::reportGenericViolation(
142 context, PerformanceMonitor::kBlockedEvent, messageText, delayedSeconds,
143 location.get());
145 registeredListener->setBlockedEventWarningEmitted(); 144 registeredListener->setBlockedEventWarningEmitted();
146 } 145 }
147 146
148 } // namespace 147 } // namespace
149 148
150 EventTargetData::EventTargetData() {} 149 EventTargetData::EventTargetData() {}
151 150
152 EventTargetData::~EventTargetData() {} 151 EventTargetData::~EventTargetData() {}
153 152
154 DEFINE_TRACE(EventTargetData) { 153 DEFINE_TRACE(EventTargetData) {
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 // they have one less listener to invoke. 764 // they have one less listener to invoke.
766 if (d->firingEventIterators) { 765 if (d->firingEventIterators) {
767 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 766 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
768 d->firingEventIterators->at(i).iterator = 0; 767 d->firingEventIterators->at(i).iterator = 0;
769 d->firingEventIterators->at(i).end = 0; 768 d->firingEventIterators->at(i).end = 0;
770 } 769 }
771 } 770 }
772 } 771 }
773 772
774 } // namespace blink 773 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698