Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: Source/devtools/front_end/screencast/ScreencastView.js

Issue 471013002: Use profiling lock in ScreencastView to detect if Timeline or Profiler is started (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 WebInspector.profilingLock().addEventListener(WebInspector.Lock.Events.S tateChanged, this._onProfilingStateChange, this);
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 (WebInspector.profilingLock().isAcquired())
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
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()
193 {
194 this._timelineActive = this._isTimelineActive();
195 if (this._timelineActive)
196 this._stopCasting();
197 else
198 this._startCasting();
199 this._updateGlasspane();
200 },
201
202 /** 185 /**
203 * @param {!WebInspector.Event} event 186 * @param {!WebInspector.Event} event
204 */ 187 */
205 _onProfiler: function(event) 188 _onProfilingStateChange: function(event)
206 { 189 {
207 this._profilerActive = this._isProfilerActive(); 190 if (WebInspector.profilingLock().isAcquired())
208 if (this._profilerActive)
209 this._stopCasting(); 191 this._stopCasting();
210 else 192 else
211 this._startCasting(); 193 this._startCasting();
212 this._updateGlasspane(); 194 this._updateGlasspane();
213 }, 195 },
214 196
215 _updateGlasspane: function() 197 _updateGlasspane: function()
216 { 198 {
217 if (this._targetInactive) { 199 if (this._targetInactive) {
218 this._glassPaneElement.textContent = WebInspector.UIString("The tab is inactive"); 200 this._glassPaneElement.textContent = WebInspector.UIString("The tab is inactive");
219 this._glassPaneElement.classList.remove("hidden"); 201 this._glassPaneElement.classList.remove("hidden");
220 } else if (this._timelineActive) { 202 } else if (WebInspector.profilingLock().isAcquired()) {
221 this._glassPaneElement.textContent = WebInspector.UIString("Timeline is active"); 203 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"); 204 this._glassPaneElement.classList.remove("hidden");
226 } else { 205 } else {
227 this._glassPaneElement.classList.add("hidden"); 206 this._glassPaneElement.classList.add("hidden");
228 } 207 }
229 }, 208 },
230 209
231 /** 210 /**
232 * @param {!Event} event 211 * @param {!Event} event
233 */ 212 */
234 _handleMouseEvent: function(event) 213 _handleMouseEvent: function(event)
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 this._navigationUrl.value = url; 774 this._navigationUrl.value = url;
796 }, 775 },
797 776
798 _focusNavigationBar: function() 777 _focusNavigationBar: function()
799 { 778 {
800 this._navigationUrl.focus(); 779 this._navigationUrl.focus();
801 this._navigationUrl.select(); 780 this._navigationUrl.select();
802 return true; 781 return true;
803 }, 782 },
804 783
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 784 __proto__: WebInspector.VBox.prototype
816 } 785 }
817 786
818 /** 787 /**
819 * @param {!Element} element 788 * @param {!Element} element
820 * @constructor 789 * @constructor
821 */ 790 */
822 WebInspector.ScreencastView.ProgressTracker = function(element) 791 WebInspector.ScreencastView.ProgressTracker = function(element)
823 { 792 {
824 this._element = element; 793 this._element = element;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 return; 856 return;
888 this._maxDisplayedProgress = progress; 857 this._maxDisplayedProgress = progress;
889 this._displayProgress(progress); 858 this._displayProgress(progress);
890 }, 859 },
891 860
892 _displayProgress: function(progress) 861 _displayProgress: function(progress)
893 { 862 {
894 this._element.style.width = (100 * progress) + "%"; 863 this._element.style.width = (100 * progress) + "%";
895 } 864 }
896 }; 865 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698