OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> | 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> |
4 * Copyright (C) 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2011 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 /** | 664 /** |
665 * @implements {SDK.TracingManagerClient} | 665 * @implements {SDK.TracingManagerClient} |
666 * @unrestricted | 666 * @unrestricted |
667 */ | 667 */ |
668 Network.NetworkPanel.FilmStripRecorder = class { | 668 Network.NetworkPanel.FilmStripRecorder = class { |
669 /** | 669 /** |
670 * @param {!Network.NetworkTimeCalculator} timeCalculator | 670 * @param {!Network.NetworkTimeCalculator} timeCalculator |
671 * @param {!PerfUI.FilmStripView} filmStripView | 671 * @param {!PerfUI.FilmStripView} filmStripView |
672 */ | 672 */ |
673 constructor(timeCalculator, filmStripView) { | 673 constructor(timeCalculator, filmStripView) { |
674 /** @type {?SDK.Target} */ | 674 /** @type {?SDK.TracingManager} */ |
675 this._target = null; | 675 this._tracingManager = null; |
| 676 /** @type {?SDK.ResourceTreeModel} */ |
| 677 this._resourceTreeModel = null; |
676 this._timeCalculator = timeCalculator; | 678 this._timeCalculator = timeCalculator; |
677 this._filmStripView = filmStripView; | 679 this._filmStripView = filmStripView; |
678 } | 680 } |
679 | 681 |
680 /** | 682 /** |
681 * @override | 683 * @override |
682 * @param {!Array.<!SDK.TracingManager.EventPayload>} events | 684 * @param {!Array.<!SDK.TracingManager.EventPayload>} events |
683 */ | 685 */ |
684 traceEventsCollected(events) { | 686 traceEventsCollected(events) { |
685 if (this._tracingModel) | 687 if (this._tracingModel) |
686 this._tracingModel.addEvents(events); | 688 this._tracingModel.addEvents(events); |
687 } | 689 } |
688 | 690 |
689 /** | 691 /** |
690 * @override | 692 * @override |
691 */ | 693 */ |
692 tracingComplete() { | 694 tracingComplete() { |
693 if (!this._tracingModel || !this._target) | 695 if (!this._tracingModel || !this._tracingManager) |
694 return; | 696 return; |
695 this._tracingModel.tracingComplete(); | 697 this._tracingModel.tracingComplete(); |
696 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(this._target); | 698 this._tracingManager = null; |
697 this._target = null; | |
698 this._callback(new SDK.FilmStripModel(this._tracingModel, this._timeCalculat
or.minimumBoundary() * 1000)); | 699 this._callback(new SDK.FilmStripModel(this._tracingModel, this._timeCalculat
or.minimumBoundary() * 1000)); |
699 delete this._callback; | 700 delete this._callback; |
700 if (resourceTreeModel) | 701 if (this._resourceTreeModel) |
701 resourceTreeModel.resumeReload(); | 702 this._resourceTreeModel.resumeReload(); |
| 703 this._resourceTreeModel = null; |
702 } | 704 } |
703 | 705 |
704 /** | 706 /** |
705 * @override | 707 * @override |
706 */ | 708 */ |
707 tracingBufferUsage() { | 709 tracingBufferUsage() { |
708 } | 710 } |
709 | 711 |
710 /** | 712 /** |
711 * @override | 713 * @override |
712 * @param {number} progress | 714 * @param {number} progress |
713 */ | 715 */ |
714 eventsRetrievalProgress(progress) { | 716 eventsRetrievalProgress(progress) { |
715 } | 717 } |
716 | 718 |
717 startRecording() { | 719 startRecording() { |
718 this._filmStripView.reset(); | 720 this._filmStripView.reset(); |
719 this._filmStripView.setStatusText(Common.UIString('Recording frames...')); | 721 this._filmStripView.setStatusText(Common.UIString('Recording frames...')); |
720 if (this._target) | 722 var tracingManagers = SDK.targetManager.models(SDK.TracingManager); |
| 723 if (this._tracingManager || !tracingManagers.length) |
721 return; | 724 return; |
722 | 725 |
723 this._target = SDK.targetManager.mainTarget(); | 726 this._tracingManager = tracingManagers[0]; |
| 727 this._resourceTreeModel = this._tracingManager.target().model(SDK.ResourceTr
eeModel); |
724 if (this._tracingModel) | 728 if (this._tracingModel) |
725 this._tracingModel.reset(); | 729 this._tracingModel.reset(); |
726 else | 730 else |
727 this._tracingModel = new SDK.TracingModel(new Bindings.TempFileBackingStor
age('tracing')); | 731 this._tracingModel = new SDK.TracingModel(new Bindings.TempFileBackingStor
age('tracing')); |
728 this._target.tracingManager.start(this, '-*,disabled-by-default-devtools.scr
eenshot', ''); | 732 this._tracingManager.start(this, '-*,disabled-by-default-devtools.screenshot
', ''); |
729 } | 733 } |
730 | 734 |
731 /** | 735 /** |
732 * @return {boolean} | 736 * @return {boolean} |
733 */ | 737 */ |
734 isRecording() { | 738 isRecording() { |
735 return !!this._target; | 739 return !!this._tracingManager; |
736 } | 740 } |
737 | 741 |
738 /** | 742 /** |
739 * @param {function(?SDK.FilmStripModel)} callback | 743 * @param {function(?SDK.FilmStripModel)} callback |
740 */ | 744 */ |
741 stopRecording(callback) { | 745 stopRecording(callback) { |
742 if (!this._target) | 746 if (!this._tracingManager) |
743 return; | 747 return; |
744 | 748 |
745 this._target.tracingManager.stop(); | 749 this._tracingManager.stop(); |
746 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(this._target); | 750 if (this._resourceTreeModel) |
747 if (resourceTreeModel) | 751 this._resourceTreeModel.suspendReload(); |
748 resourceTreeModel.suspendReload(); | |
749 this._callback = callback; | 752 this._callback = callback; |
750 this._filmStripView.setStatusText(Common.UIString('Fetching frames...')); | 753 this._filmStripView.setStatusText(Common.UIString('Fetching frames...')); |
751 } | 754 } |
752 }; | 755 }; |
753 | 756 |
754 /** | 757 /** |
755 * @implements {UI.ActionDelegate} | 758 * @implements {UI.ActionDelegate} |
756 * @unrestricted | 759 * @unrestricted |
757 */ | 760 */ |
758 Network.NetworkPanel.RecordActionDelegate = class { | 761 Network.NetworkPanel.RecordActionDelegate = class { |
759 /** | 762 /** |
760 * @override | 763 * @override |
761 * @param {!UI.Context} context | 764 * @param {!UI.Context} context |
762 * @param {string} actionId | 765 * @param {string} actionId |
763 * @return {boolean} | 766 * @return {boolean} |
764 */ | 767 */ |
765 handleAction(context, actionId) { | 768 handleAction(context, actionId) { |
766 var panel = UI.context.flavor(Network.NetworkPanel); | 769 var panel = UI.context.flavor(Network.NetworkPanel); |
767 console.assert(panel && panel instanceof Network.NetworkPanel); | 770 console.assert(panel && panel instanceof Network.NetworkPanel); |
768 panel._toggleRecording(); | 771 panel._toggleRecording(); |
769 return true; | 772 return true; |
770 } | 773 } |
771 }; | 774 }; |
OLD | NEW |