Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 this._isCasting = false; | 88 this._isCasting = false; |
| 89 this._context = this._canvasElement.getContext("2d"); | 89 this._context = this._canvasElement.getContext("2d"); |
| 90 this._checkerboardPattern = this._createCheckerboardPattern(this._contex t); | 90 this._checkerboardPattern = this._createCheckerboardPattern(this._contex t); |
| 91 | 91 |
| 92 this._shortcuts = /** !Object.<number, function(Event=):boolean> */ ({}) ; | 92 this._shortcuts = /** !Object.<number, function(Event=):boolean> */ ({}) ; |
| 93 this._shortcuts[WebInspector.KeyboardShortcut.makeKey("l", WebInspector. KeyboardShortcut.Modifiers.Ctrl)] = this._focusNavigationBar.bind(this); | 93 this._shortcuts[WebInspector.KeyboardShortcut.makeKey("l", WebInspector. KeyboardShortcut.Modifiers.Ctrl)] = this._focusNavigationBar.bind(this); |
| 94 | 94 |
| 95 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.ScreencastFrame, this._screencastFrame, this); | 95 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.ScreencastFrame, this._screencastFrame, this); |
| 96 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.ScreencastVisibilityChanged, this._screencastVisibilityChanged , this); | 96 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.ScreencastVisibilityChanged, this._screencastVisibilityChanged , this); |
| 97 | 97 |
| 98 WebInspector.targetManager.addModelListener(WebInspector.TimelineManager , WebInspector.TimelineManager.EventTypes.TimelineStarted, this._onTimeline.bind (this), this); | 98 this._target.profilingLock.addEventListener(WebInspector.Lock.Events.Sta teChanged, this._onProfilingStateChange, this); |
|
sergeyv
2014/08/14 15:01:34
Lets make profiling lock global (not per target
yurys
2014/08/14 15:29:09
Done. Please take a look: https://codereview.chrom
| |
| 99 WebInspector.targetManager.addModelListener(WebInspector.TimelineManager , WebInspector.TimelineManager.EventTypes.TimelineStopped, this._onTimeline.bind (this), this); | |
| 100 this._timelineActive = this._isTimelineActive(); | |
| 101 | |
| 102 WebInspector.targetManager.addModelListener(WebInspector.CPUProfilerMode l, WebInspector.CPUProfilerModel.EventTypes.ProfileStarted, this._onProfiler.bin d(this), this); | |
| 103 WebInspector.targetManager.addModelListener(WebInspector.CPUProfilerMode l, WebInspector.CPUProfilerModel.EventTypes.ProfileStopped, this._onProfiler.bin d(this), this); | |
| 104 this._profilerActive = this._isProfilerActive(); | |
| 105 | |
| 106 this._updateGlasspane(); | 99 this._updateGlasspane(); |
| 107 }, | 100 }, |
| 108 | 101 |
| 109 wasShown: function() | 102 wasShown: function() |
| 110 { | 103 { |
| 111 this._startCasting(); | 104 this._startCasting(); |
| 112 }, | 105 }, |
| 113 | 106 |
| 114 willHide: function() | 107 willHide: function() |
| 115 { | 108 { |
| 116 this._stopCasting(); | 109 this._stopCasting(); |
| 117 }, | 110 }, |
| 118 | 111 |
| 119 _startCasting: function() | 112 _startCasting: function() |
| 120 { | 113 { |
| 121 if (this._timelineActive || this._profilerActive) | 114 if (this._isProfiling()) |
| 122 return; | 115 return; |
| 123 if (this._isCasting) | 116 if (this._isCasting) |
| 124 return; | 117 return; |
| 125 this._isCasting = true; | 118 this._isCasting = true; |
| 126 | 119 |
| 127 const maxImageDimension = 2048; | 120 const maxImageDimension = 2048; |
| 128 var dimensions = this._viewportDimensions(); | 121 var dimensions = this._viewportDimensions(); |
| 129 if (dimensions.width < 0 || dimensions.height < 0) { | 122 if (dimensions.width < 0 || dimensions.height < 0) { |
| 130 this._isCasting = false; | 123 this._isCasting = false; |
| 131 return; | 124 return; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 | 175 |
| 183 /** | 176 /** |
| 184 * @param {!WebInspector.Event} event | 177 * @param {!WebInspector.Event} event |
| 185 */ | 178 */ |
| 186 _screencastVisibilityChanged: function(event) | 179 _screencastVisibilityChanged: function(event) |
| 187 { | 180 { |
| 188 this._targetInactive = !event.data.visible; | 181 this._targetInactive = !event.data.visible; |
| 189 this._updateGlasspane(); | 182 this._updateGlasspane(); |
| 190 }, | 183 }, |
| 191 | 184 |
| 192 _onTimeline: function() | 185 /** |
| 186 * @param {!WebInspector.Event} event | |
| 187 */ | |
| 188 _onProfilingStateChange: function(event) | |
| 193 { | 189 { |
| 194 this._timelineActive = this._isTimelineActive(); | 190 if (this._isProfiling()) |
| 195 if (this._timelineActive) | |
| 196 this._stopCasting(); | 191 this._stopCasting(); |
| 197 else | 192 else |
| 198 this._startCasting(); | 193 this._startCasting(); |
| 199 this._updateGlasspane(); | 194 this._updateGlasspane(); |
| 200 }, | 195 }, |
| 201 | 196 |
| 202 /** | 197 _isProfiling: function() |
| 203 * @param {!WebInspector.Event} event | |
| 204 */ | |
| 205 _onProfiler: function(event) | |
| 206 { | 198 { |
| 207 this._profilerActive = this._isProfilerActive(); | 199 return this._target.profilingLock.isAcquired(); |
| 208 if (this._profilerActive) | |
| 209 this._stopCasting(); | |
| 210 else | |
| 211 this._startCasting(); | |
| 212 this._updateGlasspane(); | |
| 213 }, | 200 }, |
| 214 | 201 |
| 215 _updateGlasspane: function() | 202 _updateGlasspane: function() |
| 216 { | 203 { |
| 217 if (this._targetInactive) { | 204 if (this._targetInactive) { |
| 218 this._glassPaneElement.textContent = WebInspector.UIString("The tab is inactive"); | 205 this._glassPaneElement.textContent = WebInspector.UIString("The tab is inactive"); |
| 219 this._glassPaneElement.classList.remove("hidden"); | 206 this._glassPaneElement.classList.remove("hidden"); |
| 220 } else if (this._timelineActive) { | 207 } else if (this._isProfiling()) { |
| 221 this._glassPaneElement.textContent = WebInspector.UIString("Timeline is active"); | 208 this._glassPaneElement.textContent = WebInspector.UIString("Profilin g in progress"); |
| 222 this._glassPaneElement.classList.remove("hidden"); | |
| 223 } else if (this._profilerActive) { | |
| 224 this._glassPaneElement.textContent = WebInspector.UIString("CPU prof iler is active"); | |
| 225 this._glassPaneElement.classList.remove("hidden"); | 209 this._glassPaneElement.classList.remove("hidden"); |
| 226 } else { | 210 } else { |
| 227 this._glassPaneElement.classList.add("hidden"); | 211 this._glassPaneElement.classList.add("hidden"); |
| 228 } | 212 } |
| 229 }, | 213 }, |
| 230 | 214 |
| 231 /** | 215 /** |
| 232 * @param {!Event} event | 216 * @param {!Event} event |
| 233 */ | 217 */ |
| 234 _handleMouseEvent: function(event) | 218 _handleMouseEvent: function(event) |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 this._navigationUrl.value = url; | 779 this._navigationUrl.value = url; |
| 796 }, | 780 }, |
| 797 | 781 |
| 798 _focusNavigationBar: function() | 782 _focusNavigationBar: function() |
| 799 { | 783 { |
| 800 this._navigationUrl.focus(); | 784 this._navigationUrl.focus(); |
| 801 this._navigationUrl.select(); | 785 this._navigationUrl.select(); |
| 802 return true; | 786 return true; |
| 803 }, | 787 }, |
| 804 | 788 |
| 805 _isTimelineActive: function() | |
| 806 { | |
| 807 return WebInspector.targetManager.targets().some(function(target){ retur n target.timelineManager.isStarted();}); | |
| 808 }, | |
| 809 | |
| 810 _isProfilerActive: function() | |
| 811 { | |
| 812 return WebInspector.targetManager.targets().some(function(target){ retur n target.cpuProfilerModel.isRecordingProfile();}); | |
| 813 }, | |
| 814 | |
| 815 __proto__: WebInspector.VBox.prototype | 789 __proto__: WebInspector.VBox.prototype |
| 816 } | 790 } |
| 817 | 791 |
| 818 /** | 792 /** |
| 819 * @param {!Element} element | 793 * @param {!Element} element |
| 820 * @constructor | 794 * @constructor |
| 821 */ | 795 */ |
| 822 WebInspector.ScreencastView.ProgressTracker = function(element) | 796 WebInspector.ScreencastView.ProgressTracker = function(element) |
| 823 { | 797 { |
| 824 this._element = element; | 798 this._element = element; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 return; | 861 return; |
| 888 this._maxDisplayedProgress = progress; | 862 this._maxDisplayedProgress = progress; |
| 889 this._displayProgress(progress); | 863 this._displayProgress(progress); |
| 890 }, | 864 }, |
| 891 | 865 |
| 892 _displayProgress: function(progress) | 866 _displayProgress: function(progress) |
| 893 { | 867 { |
| 894 this._element.style.width = (100 * progress) + "%"; | 868 this._element.style.width = (100 * progress) + "%"; |
| 895 } | 869 } |
| 896 }; | 870 }; |
| OLD | NEW |