⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 107373 in webkit


Ignore:
Timestamp:
Feb 10, 2012, 12:05:49 AM (15 years ago)
Author:
caseq@chromium.org
Message:

Web Inspector: [refactoring] TimelineModel should not depend on TimelinePanel
https://bugs.webkit.org/show_bug.cgi?id=78254

Reviewed by Yury Semikhatsky.

  • inspector/front-end/TimelinePanel.js:

(WebInspector.TimelinePanel):
(WebInspector.TimelinePanel.prototype._loadFromFile):
(WebInspector.TimelinePanel.prototype._toggleTimelineButtonClicked):
(WebInspector.TimelinePanel.prototype._onTimelineEventRecorded):
(WebInspector.TimelinePanel.prototype._clearPanel):
(WebInspector.TimelinePanel.prototype._onRecordsCleared):
(WebInspector.TimelineModel):
(WebInspector.TimelineModel.prototype.startRecord):
(WebInspector.TimelineModel.prototype.stopRecord):
(WebInspector.TimelineModel.prototype._onRecordAdded):
(WebInspector.TimelineModel.prototype._addRecord):
(WebInspector.TimelineModel.prototype._loadNextChunk):
(WebInspector.TimelineModel.prototype._loadFromFile):
(WebInspector.TimelineModel.prototype._reset):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107371 r107373  
     12012-02-09  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Web Inspector: [refactoring] TimelineModel should not depend on TimelinePanel
     4        https://bugs.webkit.org/show_bug.cgi?id=78254
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/front-end/TimelinePanel.js:
     9        (WebInspector.TimelinePanel):
     10        (WebInspector.TimelinePanel.prototype._loadFromFile):
     11        (WebInspector.TimelinePanel.prototype._toggleTimelineButtonClicked):
     12        (WebInspector.TimelinePanel.prototype._onTimelineEventRecorded):
     13        (WebInspector.TimelinePanel.prototype._clearPanel):
     14        (WebInspector.TimelinePanel.prototype._onRecordsCleared):
     15        (WebInspector.TimelineModel):
     16        (WebInspector.TimelineModel.prototype.startRecord):
     17        (WebInspector.TimelineModel.prototype.stopRecord):
     18        (WebInspector.TimelineModel.prototype._onRecordAdded):
     19        (WebInspector.TimelineModel.prototype._addRecord):
     20        (WebInspector.TimelineModel.prototype._loadNextChunk):
     21        (WebInspector.TimelineModel.prototype._loadFromFile):
     22        (WebInspector.TimelineModel.prototype._reset):
     23
    1242012-02-09  Kentaro Hara  <haraken@chromium.org>
    225
  • trunk/Source/WebCore/inspector/front-end/TimelinePanel.js

    r107251 r107373  
    11/*
    2  * Copyright (C) 2011 Google Inc. All rights reserved.
     2 * Copyright (C) 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    115115
    116116    this._createFileSelector();
    117     this._model = new WebInspector.TimelineModel(this);
     117    this._model = new WebInspector.TimelineModel();
     118    this._model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded, this._onTimelineEventRecorded, this);
     119    this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleared, this._onRecordsCleared, this);
    118120
    119121    this._registerShortcuts();
    120     WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onTimelineEventRecorded, this);
    121122    this._linkifier = WebInspector.debuggerPresentationModel.createLinkifier();
    122123}
     
    355356    _loadFromFile: function()
    356357    {
    357         if (this.toggleTimelineButton.toggled)
    358             WebInspector.timelineManager.stop();
    359 
    360         this._clearPanel();
    361 
     358        if (this.toggleTimelineButton.toggled) {
     359            this.toggleTimelineButton.toggled = false;
     360            this._model.stopRecord();
     361        }
    362362        this._model._loadFromFile(this._fileSelectorElement.files[0]);
    363363        this._createFileSelector();
     
    423423    {
    424424        if (this.toggleTimelineButton.toggled)
    425             WebInspector.timelineManager.stop();
     425            this._model.stopRecord();
    426426        else {
    427             this._clearPanel();
    428             WebInspector.timelineManager.start(30);
     427            this._model.startRecord();
    429428            WebInspector.userMetrics.TimelineStarted.record();
    430429        }
     
    463462    _onTimelineEventRecorded: function(event)
    464463    {
    465         if (this.toggleTimelineButton.toggled) {
    466             this._addRecordToTimeline(event.data);
    467 
    468             if (this._memoryStatistics && event.data["domGroups"])
    469                 this._memoryStatistics.addTimlineEvent(event);
    470         }
    471     },
    472 
    473     _addRecordToTimeline: function(record)
    474     {
    475         this._model._addRecord(record);
    476         this._innerAddRecordToTimeline(record, this._rootRecord);
     464        this._innerAddRecordToTimeline(event.data, this._rootRecord);
    477465        this._scheduleRefresh(false);
     466
     467        if (this._memoryStatistics && event.data["domGroups"])
     468            this._memoryStatistics.addTimlineEvent(event);
    478469    },
    479470
     
    601592    _clearPanel: function()
    602593    {
     594        this._model._reset();
     595    },
     596
     597    _onRecordsCleared: function()
     598    {
    603599        this._timeStampRecords = [];
    604600        this._sendRequestRecords = {};
     
    612608        this._refresh();
    613609        this._closeRecordDetails();
    614         this._model._reset();
    615610        this._linkifier.reset();
    616611    },
     
    14271422/**
    14281423 * @constructor
     1424 * @extends {WebInspector.Object}
    14291425 */
    1430 WebInspector.TimelineModel = function(timelinePanel)
     1426WebInspector.TimelineModel = function()
    14311427{
    1432     this._panel = timelinePanel;
    14331428    this._records = [];
     1429    this._collectionEnabled = false;
     1430
     1431    WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onRecordAdded, this);
     1432}
     1433
     1434WebInspector.TimelineModel.Events = {
     1435    RecordAdded: "RecordAdded",
     1436    RecordsCleared: "RecordsCleared"
    14341437}
    14351438
    14361439WebInspector.TimelineModel.prototype = {
     1440    startRecord: function()
     1441    {
     1442        if (this._collectionEnabled)
     1443            return;
     1444        this._reset();
     1445        WebInspector.timelineManager.start(30);
     1446        this._collectionEnabled = true;
     1447    },
     1448
     1449    stopRecord: function()
     1450    {
     1451        if (!this._collectionEnabled)
     1452            return;
     1453        WebInspector.timelineManager.stop();
     1454        this._collectionEnabled = false;
     1455    },
     1456
     1457    _onRecordAdded: function(event)
     1458    {
     1459        if (this._collectionEnabled)
     1460            this._addRecord(event.data);
     1461    },
     1462
    14371463    _addRecord: function(record)
    14381464    {
    14391465        this._records.push(record);
     1466        this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordAdded, record);
    14401467    },
    14411468
     
    14431470    {
    14441471        for (var i = 0; i < 20 && index < data.length; ++i, ++index)
    1445             this._panel._addRecordToTimeline(data[index]);
     1472            this._addRecord(data[index]);
    14461473
    14471474        if (index !== data.length)
     
    14541481        {
    14551482            var data = JSON.parse(e.target.result);
    1456             var version = data[0];
     1483            this._reset();
    14571484            this._loadNextChunk(data, 1);
    14581485        }
     
    14951522    _reset: function()
    14961523    {
     1524        this.stopRecord();
    14971525        this._records = [];
     1526        this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordsCleared);
    14981527    }
    14991528}
     1529
     1530WebInspector.TimelineModel.prototype.__proto__ = WebInspector.Object.prototype;
Note: See TracChangeset for help on using the changeset viewer.