RESOLVED FIXED 30467
Add DOMTimer support to InspectorTimelineAgent.
https://bugs.webkit.org/show_bug.cgi?id=30467
Summary Add DOMTimer support to InspectorTimelineAgent.
Kelly Norton
Reported 2009-10-16 15:41:25 PDT
Allows information about timers to be collected within inspector via the TimelineAgent.
Attachments
Adds support for timers. (20.79 KB, patch)
2009-10-16 15:48 PDT, Kelly Norton
pfeldman: review-
Updated patch after changing over to ScriptObjects (bug 30707) (11.68 KB, patch)
2009-10-25 20:25 PDT, Kelly Norton
no flags
Added inline function for inspectorTimelineAgent in DOMTimer. (12.72 KB, patch)
2009-10-25 21:05 PDT, Kelly Norton
no flags
Moved static method to InspectorTimelineAgent. (12.63 KB, patch)
2009-10-26 08:51 PDT, Kelly Norton
no flags
Forgot the JS constants. (13.20 KB, patch)
2009-10-26 09:29 PDT, Kelly Norton
no flags
Kelly Norton
Comment 1 2009-10-16 15:48:00 PDT
Created attachment 41335 [details] Adds support for timers.
Pavel Feldman
Comment 2 2009-10-16 23:28:56 PDT
Comment on attachment 41335 [details] Adds support for timers. > +void InspectorTimelineAgent::didInstallTimer(int timerId, int timeout, bool singleShot) > +{ > + m_frontend->addItemToTimeline(TimerFireTimelineItem::newTimerInstallScriptObject(m_frontend, sessionTimeInMilliseconds(), timerId, timeout, singleShot)); > +} TimerF It seems like you are pushing script objects right to the frontend, without keeping them in the controller. That is Ok for 'profile' mode, but you don't need TimelineItem and TimerFireTimeline classes in that case. I'd suggest that you do one of the following: 1) Get rid of these classes, leave only static factories for creating corresponding events. Glue them together on the frontend side so that you did not need m_currentTimelineItem. 2) Leave TimelineItem and TimerTimelineItem classes; Collect them into the timeline events vector within TimelineAgent; Create populateScriptObjects and resetScriptObjects methods in TimelineAgent and call them from within corresponding inspector controller methods; Provide a way for TimelineAgent to push events to the frontend on the fly if latter is available. (Either via passing inspector controller into the timeline agent or coming up with some specific interface). My gut is telling me that (2) is better long term, but I can't really explain why. It seems that (1) is enough at the moment. But (2) allows capturing the state in the frontend-less mode and all other inspector controller metrics (including profiles) are supporting this mode. Drive-by question: Should you introduce some kind of a bit set (or convert TimelineItemTypes consts into one) so that you could filter events based on some preferences. I am sure you will be doing filtering, but given the granularity of the events of your interest, it might make sense to filter on the inspector controller side. I am putting r- because I'd like to explore how InspectorController/InspectorFrontend interaction could be changed in order to allow you plugging your new agent in a more elegant manner. Please also share with me your thoughts on (1) vs (2).
Kelly Norton
Comment 3 2009-10-25 20:25:42 PDT
Created attachment 41839 [details] Updated patch after changing over to ScriptObjects (bug 30707)
Timothy Hatcher
Comment 4 2009-10-25 20:33:11 PDT
Comment on attachment 41839 [details] Updated patch after changing over to ScriptObjects (bug 30707) I like the term "Record" over "TimelineItem". But I see the logic in the name change. > + if (context->isDocument()) > + if (InspectorTimelineAgent* timelineAgent = static_cast<Document*>(context)->inspectorTimelineAgent()) > + timelineAgent->didInstallTimer(timer->m_timeoutId, timeout, singleShot); There should be braces around the outer if() since it is multi-line inside. This would be better as helper inline function that returns InspectorTimelineAgent* to share with the other spots in this code.
Kelly Norton
Comment 5 2009-10-25 21:04:21 PDT
(In reply to comment #4) > (From update of attachment 41839 [details]) > I like the term "Record" over "TimelineItem". But I see the logic in the name > change. > I can't remember why I got rid of "Record" but I like the term better too. How about I do a separate renaming patch? > > + if (context->isDocument()) > > + if (InspectorTimelineAgent* timelineAgent = static_cast<Document*>(context)->inspectorTimelineAgent()) > > + timelineAgent->didInstallTimer(timer->m_timeoutId, timeout, singleShot); > > There should be braces around the outer if() since it is multi-line inside. > Ok > This would be better as helper inline function that returns > InspectorTimelineAgent* to share with the other spots in this code. Done ... uploading patch now.
Kelly Norton
Comment 6 2009-10-25 21:05:40 PDT
Created attachment 41840 [details] Added inline function for inspectorTimelineAgent in DOMTimer.
Timothy Hatcher
Comment 7 2009-10-25 22:45:42 PDT
Comment on attachment 41840 [details] Added inline function for inspectorTimelineAgent in DOMTimer. > +#if ENABLE(INSPECTOR) > + static InspectorTimelineAgent* inspectorTimelineAgent(ScriptExecutionContext*); > +#endif > + > int m_timeoutId; > int m_nestingLevel; > OwnPtr<ScheduledAction> m_action; > @@ -72,6 +79,15 @@ namespace WebCore { > static double s_minTimerInterval; > }; > > +#if ENABLE(INSPECTOR) > +inline InspectorTimelineAgent* DOMTimer::inspectorTimelineAgent(ScriptExecutionContext* context) > +{ > + if (context->isDocument()) > + return static_cast<Document*>(context)->inspectorTimelineAgent(); > + return 0; > +} > +#endif > + I didn't realize this was static before. It would be good to have this as a static in InspectorTimelineAgent.h then. Maybe as: InspectorTimelineAgent::inspectorTimelineAgent(ScriptExecutionContext* context) Who else might need that same code? Otherwise looks good to me.
Kelly Norton
Comment 8 2009-10-26 08:51:04 PDT
Created attachment 41867 [details] Moved static method to InspectorTimelineAgent.
Kelly Norton
Comment 9 2009-10-26 09:29:10 PDT
Created attachment 41871 [details] Forgot the JS constants.
WebKit Commit Bot
Comment 10 2009-10-26 09:47:01 PDT
Comment on attachment 41871 [details] Forgot the JS constants. Clearing flags on attachment: 41871 Committed r50068: <http://trac.webkit.org/changeset/50068>
WebKit Commit Bot
Comment 11 2009-10-26 09:47:06 PDT
All reviewed patches have been landed. Closing bug.
Eric Ayers
Comment 12 2009-11-30 06:32:27 PST
*** Bug 31372 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.