Changeset 121767 in webkit


Ignore:
Timestamp:
Jul 3, 2012 8:27:06 AM (12 years ago)
Author:
caseq@chromium.org
Message:

Web Inspector: Forward message loop instrumentation data to frontend.
https://bugs.webkit.org/show_bug.cgi?id=89584

Patch by Eugene Klyuchnikov <eustas.bug@gmail.com> on 2012-07-03
Reviewed by Yury Semikhatsky.

Transmit collected message loop tasks to inspector frontend.
Now "Program" should be a top-level event on browsers that
support message loop instrumentation.
Frontend was changed so that user will not see any changes.

Source/WebCore:

  • inspector/InspectorTimelineAgent.cpp:

(TimelineRecordType):
Added new event type - "Program"
(WebCore::InspectorTimelineAgent::willProcessTask):
Begin "Program" event.
(WebCore::InspectorTimelineAgent::didProcessTask):
Finish "Program" event.
(WebCore::InspectorTimelineAgent::setHeapSizeStatistic):
Do not add counters to "Program" events.
(WebCore):
(WebCore::InspectorTimelineAgent::innerSetHeapSizeStatistic):
Renamed from "setHeapSizeStatistic"

  • inspector/InspectorTimelineAgent.h:

(InspectorTimelineAgent):

  • inspector/front-end/MemoryStatistics.js:

(WebInspector.MemoryStatistics.prototype._onRecordAdded):
Unwraps "Program" events.
(WebInspector.MemoryStatistics.prototype._innerRecordAdded):
Renamed from "_onRecordAdded"

  • inspector/front-end/TimelineFrameController.js:

(WebInspector.TimelineFrameController.prototype._addRecord):
Unwraps "Program" events.
(WebInspector.TimelineFrameController.prototype._innerAddRecord):
Renamed from "_addRecord"

  • inspector/front-end/TimelineModel.js:
  • inspector/front-end/TimelineOverviewPane.js:

(WebInspector.TimelineCategoryStrips.prototype.update.appendRecord):
Filter out "Program" category.
(WebInspector.TimelineCategoryStrips.prototype.update):

  • inspector/front-end/TimelinePanel.js:

(WebInspector.TimelinePanel.prototype._createStatusbarButtons):
Filter out "Program" category.
(WebInspector.TimelinePanel.prototype._innerAddRecordToTimeline):
Unwraps "Program" events.

  • inspector/front-end/TimelinePresentationModel.js:

(WebInspector.TimelinePresentationModel.categories):
Added "Program" category.
(WebInspector.TimelinePresentationModel.recordStyle):
Ditto.
(WebInspector.TimelinePresentationModel.prototype.addRecord):
Unwraps "Program" events.
(WebInspector.TimelinePresentationModel.prototype._addRecord):
Renamed from "addRecord"

LayoutTests:

  • inspector/timeline/timeline-enum-stability-expected.txt:
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r121765 r121767  
     12012-07-03  Eugene Klyuchnikov  <eustas.bug@gmail.com>
     2
     3        Web Inspector: Forward message loop instrumentation data to frontend.
     4        https://bugs.webkit.org/show_bug.cgi?id=89584
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Transmit collected message loop tasks to inspector frontend.
     9        Now "Program" should be a top-level event on browsers that
     10        support message loop instrumentation.
     11        Frontend was changed so that user will not see any changes.
     12
     13        * inspector/timeline/timeline-enum-stability-expected.txt:
     14
    1152012-07-03  Vsevolod Vlasov  <vsevik@chromium.org>
    216
  • trunk/LayoutTests/inspector/timeline/timeline-enum-stability-expected.txt

    r121763 r121767  
    55{
    66    Root : "Root"
     7    Program : "Program"
    78    EventDispatch : "EventDispatch"
    89    BeginFrame : "BeginFrame"
  • trunk/Source/WebCore/ChangeLog

    r121766 r121767  
     12012-07-03  Eugene Klyuchnikov  <eustas.bug@gmail.com>
     2
     3        Web Inspector: Forward message loop instrumentation data to frontend.
     4        https://bugs.webkit.org/show_bug.cgi?id=89584
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Transmit collected message loop tasks to inspector frontend.
     9        Now "Program" should be a top-level event on browsers that
     10        support message loop instrumentation.
     11        Frontend was changed so that user will not see any changes.
     12
     13        * inspector/InspectorTimelineAgent.cpp:
     14        (TimelineRecordType):
     15        Added new event type - "Program"
     16        (WebCore::InspectorTimelineAgent::willProcessTask):
     17        Begin "Program" event.
     18        (WebCore::InspectorTimelineAgent::didProcessTask):
     19        Finish "Program" event.
     20        (WebCore::InspectorTimelineAgent::setHeapSizeStatistic):
     21        Do not add counters to "Program" events.
     22        (WebCore):
     23        (WebCore::InspectorTimelineAgent::innerSetHeapSizeStatistic):
     24        Renamed from "setHeapSizeStatistic"
     25        * inspector/InspectorTimelineAgent.h:
     26        (InspectorTimelineAgent):
     27        * inspector/front-end/MemoryStatistics.js:
     28        (WebInspector.MemoryStatistics.prototype._onRecordAdded):
     29        Unwraps "Program" events.
     30        (WebInspector.MemoryStatistics.prototype._innerRecordAdded):
     31        Renamed from "_onRecordAdded"
     32        * inspector/front-end/TimelineFrameController.js:
     33        (WebInspector.TimelineFrameController.prototype._addRecord):
     34        Unwraps "Program" events.
     35        (WebInspector.TimelineFrameController.prototype._innerAddRecord):
     36        Renamed from "_addRecord"
     37        * inspector/front-end/TimelineModel.js:
     38        * inspector/front-end/TimelineOverviewPane.js:
     39        (WebInspector.TimelineCategoryStrips.prototype.update.appendRecord):
     40        Filter out "Program" category.
     41        (WebInspector.TimelineCategoryStrips.prototype.update):
     42        * inspector/front-end/TimelinePanel.js:
     43        (WebInspector.TimelinePanel.prototype._createStatusbarButtons):
     44        Filter out "Program" category.
     45        (WebInspector.TimelinePanel.prototype._innerAddRecordToTimeline):
     46        Unwraps "Program" events.
     47        * inspector/front-end/TimelinePresentationModel.js:
     48        (WebInspector.TimelinePresentationModel.categories):
     49        Added "Program" category.
     50        (WebInspector.TimelinePresentationModel.recordStyle):
     51        Ditto.
     52        (WebInspector.TimelinePresentationModel.prototype.addRecord):
     53        Unwraps "Program" events.
     54        (WebInspector.TimelinePresentationModel.prototype._addRecord):
     55        Renamed from "addRecord"
     56
    1572012-07-03  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
    258
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp

    r121763 r121767  
    6161// Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineModel.js
    6262namespace TimelineRecordType {
     63static const char Program[] = "Program";
     64
    6365static const char EventDispatch[] = "EventDispatch";
    6466static const char BeginFrame[] = "BeginFrame";
     
    343345        recordRaw->setString("frameId", frameId);
    344346    }
    345     setHeapSizeStatistic(recordRaw.get());
     347    setHeapSizeStatistics(recordRaw.get());
    346348    // FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now.
    347349    RefPtr<TypeBuilder::Timeline::TimelineEvent> record = TypeBuilder::Timeline::TimelineEvent::runtimeCast(recordRaw.release());
     
    428430void InspectorTimelineAgent::willProcessTask()
    429431{
    430     // TODO: Record task processing start time.
     432    pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Program, false, 0);
    431433}
    432434
    433435void InspectorTimelineAgent::didProcessTask()
    434436{
    435     // TODO: Record task processing end time.
     437    didCompleteCurrentRecord(TimelineRecordType::Program);
    436438}
    437439
     
    444446void InspectorTimelineAgent::innerAddRecordToTimeline(PassRefPtr<InspectorObject> prpRecord, const String& type, const String& frameId)
    445447{
     448    DEFINE_STATIC_LOCAL(String, program, (TimelineRecordType::Program));
     449
    446450    RefPtr<InspectorObject> record(prpRecord);
    447451    record->setString("type", type);
    448452    if (!frameId.isEmpty())
    449453        record->setString("frameId", frameId);
    450     setHeapSizeStatistic(record.get());
     454    if (type != program)
     455        setHeapSizeStatistics(record.get());
     456
    451457    if (m_recordStack.isEmpty()) {
    452458        // FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now.
     
    459465}
    460466
    461 void InspectorTimelineAgent::setHeapSizeStatistic(InspectorObject* record)
     467void InspectorTimelineAgent::setHeapSizeStatistics(InspectorObject* record)
    462468{
    463469    size_t usedHeapSize = 0;
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.h

    r121763 r121767  
    164164
    165165    void pushCurrentRecord(PassRefPtr<InspectorObject>, const String& type, bool captureCallStack, Frame*);
    166     void setHeapSizeStatistic(InspectorObject* record);
    167        
     166    void setHeapSizeStatistics(InspectorObject* record);
     167
    168168    void didCompleteCurrentRecord(const String& type);
    169169    void appendRecord(PassRefPtr<InspectorObject> data, const String& type, bool captureCallStack, Frame*);
  • trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js

    r118674 r121767  
    258258    _onRecordAdded: function(event)
    259259    {
    260         var counters = event.data["counters"];
    261         if (!counters)
    262             return;
    263         this._counters.push({
    264             time: event.data.endTime || event.data.startTime,
    265             documentCount: counters["documents"],
    266             nodeCount: counters["nodes"],
    267             listenerCount: counters["jsEventListeners"]
    268         });
     260        var statistics = this._counters;
     261        function addStatistics(record)
     262        {
     263            var counters = record["counters"];
     264            if (!counters)
     265                return;
     266            statistics.push({
     267                time: record.endTime || record.startTime,
     268                documentCount: counters["documents"],
     269                nodeCount: counters["nodes"],
     270                listenerCount: counters["jsEventListeners"]
     271            });
     272        }
     273        WebInspector.TimelinePresentationModel.forAllRecords([event.data], null, addStatistics);
    269274    },
    270275
  • trunk/Source/WebCore/inspector/front-end/TimelineFrameController.js

    r119485 r121767  
    6262    _addRecord: function(record)
    6363    {
     64        var records;
     65        if (record.type === WebInspector.TimelineModel.RecordType.Program)
     66            records = record["children"] || [];
     67        else
     68            records = [record];
     69        records.forEach(this._innerAddRecord, this);
     70    },
     71
     72    _innerAddRecord: function(record)
     73    {
    6474        if (record.type === WebInspector.TimelineModel.RecordType.BeginFrame && this._lastFrame)
    6575            this._flushFrame(record);
  • trunk/Source/WebCore/inspector/front-end/TimelineModel.js

    r121763 r121767  
    4545WebInspector.TimelineModel.RecordType = {
    4646    Root: "Root",
     47    Program: "Program",
    4748    EventDispatch: "EventDispatch",
    4849
  • trunk/Source/WebCore/inspector/front-end/TimelineOverviewPane.js

    r121084 r121767  
    886886            var recordEnd = Math.ceil((WebInspector.TimelineModel.endTimeInSeconds(record) - timeOffset) * scale);
    887887            var category = WebInspector.TimelinePresentationModel.categoryForRecord(record);
     888            if (category.overviewStripGroupIndex < 0)
     889                return;
    888890            var bar = lastBarByGroup[category.overviewStripGroupIndex];
    889891            // This bar may be merged with previous -- so just adjust the previous bar.
  • trunk/Source/WebCore/inspector/front-end/TimelinePanel.js

    r121690 r121767  
    233233        for (var categoryName in categories) {
    234234            var category = categories[categoryName];
     235            if (category.overviewStripGroupIndex < 0)
     236                continue;
    235237            this.statusBarFilters.appendChild(this._createTimelineCategoryStatusBarCheckbox(category, this._onCategoryCheckboxClicked.bind(this, category)));
    236238        }
     
    496498    _innerAddRecordToTimeline: function(record, parentRecord)
    497499    {
    498         var formattedRecord = this._presentationModel.addRecord(record, parentRecord);
    499         ++this._allRecordsCount;
     500        var records = this._presentationModel.addRecord(record, parentRecord);
     501        this._allRecordsCount += records.length;
    500502        var recordTypes = WebInspector.TimelineModel.RecordType;
    501503        var timeStampRecords = this._timeStampRecords;
     
    508510            hasVisibleRecords |= presentationModel.isVisible(record);
    509511        }
    510         var records = [ formattedRecord ];
    511512        WebInspector.TimelinePresentationModel.forAllRecords(records, processRecord);
     513
     514        function isAdoptedRecord(record)
     515        {
     516            return record.parent !== presentationModel.rootRecord;
     517        }
    512518        // Tell caller update is necessary either if we added a visible record or if we re-parented a record.
    513         return hasVisibleRecords || formattedRecord.parent !== this._presentationModel.rootRecord;
     519        return hasVisibleRecords || records.some(isAdoptedRecord);
    514520    },
    515521
  • trunk/Source/WebCore/inspector/front-end/TimelinePresentationModel.js

    r121763 r121767  
    4848        return WebInspector.TimelinePresentationModel._categories;
    4949    WebInspector.TimelinePresentationModel._categories = {
     50        program: new WebInspector.TimelineCategory("program", WebInspector.UIString("Program"), -1, "#BBBBBB", "#DDDDDD", "#FFFFFF"),
    5051        loading: new WebInspector.TimelineCategory("loading", WebInspector.UIString("Loading"), 0, "#5A8BCC", "#8EB6E9", "#70A2E3"),
    5152        scripting: new WebInspector.TimelineCategory("scripting", WebInspector.UIString("Scripting"), 1, "#D8AA34", "#F3D07A", "#F1C453"),
     
    6970    var recordStyles = {};
    7071    recordStyles[recordTypes.Root] = { title: "#root", category: categories["loading"] };
     72    recordStyles[recordTypes.Program] = { title: WebInspector.UIString("Program"), category: categories["program"] };
    7173    recordStyles[recordTypes.EventDispatch] = { title: WebInspector.UIString("Event"), category: categories["scripting"] };
    7274    recordStyles[recordTypes.BeginFrame] = { title: WebInspector.UIString("Frame Start"), category: categories["rendering"] };
     
    104106WebInspector.TimelinePresentationModel.categoryForRecord = function(record)
    105107{
    106     return WebInspector.TimelinePresentationModel.recordStyle(record).category;
     108        return WebInspector.TimelinePresentationModel.recordStyle(record).category;
    107109}
    108110
     
    118120}
    119121
    120 WebInspector.TimelinePresentationModel.forAllRecords = function(recordsArray, callback)
     122/**
     123 * @param {Array} recordsArray
     124 * @param {?function(*)} preOrderCallback
     125 * @param {function(*)=} postOrderCallback
     126 */
     127WebInspector.TimelinePresentationModel.forAllRecords = function(recordsArray, preOrderCallback, postOrderCallback)
    121128{
    122129    if (!recordsArray)
     
    128135        if (entry.index < records.length) {
    129136             var record = records[entry.index];
    130              if (callback(record))
     137             if (preOrderCallback && preOrderCallback(record))
    131138                 return;
    132139             if (record.children)
    133                  stack.push({array: record.children, index: 0});
     140                 stack.push({array: record.children, index: 0, record: record});
     141             else if (postOrderCallback && postOrderCallback(record))
     142                return;
    134143             ++entry.index;
    135         } else
     144        } else {
     145            if (entry.record && postOrderCallback && postOrderCallback(entry.record))
     146                return;
    136147            stack.pop();
     148        }
    137149    }
    138150}
     
    206218    addRecord: function(record, parentRecord)
    207219    {
     220        if (this._minimumRecordTime === -1 || record.startTime < this._minimumRecordTime)
     221            this._minimumRecordTime = WebInspector.TimelineModel.startTimeInSeconds(record);
     222
     223        var records;
     224        if (record.type === WebInspector.TimelineModel.RecordType.Program)
     225            records = record.children;
     226        else
     227            records = [record];
     228
     229        var formattedRecords = [];
     230        var recordsCount = records.length;
     231        for (var i = 0; i < recordsCount; ++i)
     232            formattedRecords.push(this._innerAddRecord(records[i], parentRecord));
     233        return formattedRecords;
     234    },
     235
     236    _innerAddRecord: function(record, parentRecord)
     237    {
    208238        var connectedToOldRecord = false;
    209239        var recordTypes = WebInspector.TimelineModel.RecordType;
    210 
    211         if (this._minimumRecordTime === -1 || record.startTime < this._minimumRecordTime)
    212             this._minimumRecordTime = WebInspector.TimelineModel.startTimeInSeconds(record);
    213240
    214241        switch (record.type) {
     
    258285        var childrenCount = children ? children.length : 0;
    259286        for (var i = 0; i < childrenCount; ++i)
    260             this.addRecord(children[i], formattedRecord);
     287            this._innerAddRecord(children[i], formattedRecord);
    261288
    262289        formattedRecord.calculateAggregatedStats(WebInspector.TimelinePresentationModel.categories());
Note: See TracChangeset for help on using the changeset viewer.