Changeset 107373 in webkit
- Timestamp:
- Feb 10, 2012, 12:05:49 AM (15 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
inspector/front-end/TimelinePanel.js (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107371 r107373 1 2012-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 1 24 2012-02-09 Kentaro Hara <haraken@chromium.org> 2 25 -
trunk/Source/WebCore/inspector/front-end/TimelinePanel.js
r107251 r107373 1 1 /* 2 * Copyright (C) 201 1Google Inc. All rights reserved.2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 115 115 116 116 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); 118 120 119 121 this._registerShortcuts(); 120 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onTimelineEventRecorded, this);121 122 this._linkifier = WebInspector.debuggerPresentationModel.createLinkifier(); 122 123 } … … 355 356 _loadFromFile: function() 356 357 { 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 } 362 362 this._model._loadFromFile(this._fileSelectorElement.files[0]); 363 363 this._createFileSelector(); … … 423 423 { 424 424 if (this.toggleTimelineButton.toggled) 425 WebInspector.timelineManager.stop();425 this._model.stopRecord(); 426 426 else { 427 this._clearPanel(); 428 WebInspector.timelineManager.start(30); 427 this._model.startRecord(); 429 428 WebInspector.userMetrics.TimelineStarted.record(); 430 429 } … … 463 462 _onTimelineEventRecorded: function(event) 464 463 { 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); 477 465 this._scheduleRefresh(false); 466 467 if (this._memoryStatistics && event.data["domGroups"]) 468 this._memoryStatistics.addTimlineEvent(event); 478 469 }, 479 470 … … 601 592 _clearPanel: function() 602 593 { 594 this._model._reset(); 595 }, 596 597 _onRecordsCleared: function() 598 { 603 599 this._timeStampRecords = []; 604 600 this._sendRequestRecords = {}; … … 612 608 this._refresh(); 613 609 this._closeRecordDetails(); 614 this._model._reset();615 610 this._linkifier.reset(); 616 611 }, … … 1427 1422 /** 1428 1423 * @constructor 1424 * @extends {WebInspector.Object} 1429 1425 */ 1430 WebInspector.TimelineModel = function( timelinePanel)1426 WebInspector.TimelineModel = function() 1431 1427 { 1432 this._panel = timelinePanel;1433 1428 this._records = []; 1429 this._collectionEnabled = false; 1430 1431 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onRecordAdded, this); 1432 } 1433 1434 WebInspector.TimelineModel.Events = { 1435 RecordAdded: "RecordAdded", 1436 RecordsCleared: "RecordsCleared" 1434 1437 } 1435 1438 1436 1439 WebInspector.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 1437 1463 _addRecord: function(record) 1438 1464 { 1439 1465 this._records.push(record); 1466 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordAdded, record); 1440 1467 }, 1441 1468 … … 1443 1470 { 1444 1471 for (var i = 0; i < 20 && index < data.length; ++i, ++index) 1445 this._ panel._addRecordToTimeline(data[index]);1472 this._addRecord(data[index]); 1446 1473 1447 1474 if (index !== data.length) … … 1454 1481 { 1455 1482 var data = JSON.parse(e.target.result); 1456 var version = data[0];1483 this._reset(); 1457 1484 this._loadNextChunk(data, 1); 1458 1485 } … … 1495 1522 _reset: function() 1496 1523 { 1524 this.stopRecord(); 1497 1525 this._records = []; 1526 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordsCleared); 1498 1527 } 1499 1528 } 1529 1530 WebInspector.TimelineModel.prototype.__proto__ = WebInspector.Object.prototype;
Note:
See TracChangeset
for help on using the changeset viewer.