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

Side by Side Diff: Source/devtools/front_end/profiler/ProfilesPanel.js

Issue 475803002: Make profiling lock global rather than per Target (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Extracted Lock.js 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 { 231 {
232 return this._profileBeingRecorded; 232 return this._profileBeingRecorded;
233 }, 233 },
234 234
235 /** 235 /**
236 * @param {?WebInspector.ProfileHeader} profile 236 * @param {?WebInspector.ProfileHeader} profile
237 */ 237 */
238 setProfileBeingRecorded: function(profile) 238 setProfileBeingRecorded: function(profile)
239 { 239 {
240 if (this._profileBeingRecorded && this._profileBeingRecorded.target()) 240 if (this._profileBeingRecorded && this._profileBeingRecorded.target())
241 this._profileBeingRecorded.target().profilingLock.release(); 241 WebInspector.profilingLock.release();
242 if (profile && profile.target()) 242 if (profile && profile.target())
243 profile.target().profilingLock.acquire(); 243 WebInspector.profilingLock.acquire();
244 this._profileBeingRecorded = profile; 244 this._profileBeingRecorded = profile;
245 }, 245 },
246 246
247 profileBeingRecordedRemoved: function() 247 profileBeingRecordedRemoved: function()
248 { 248 {
249 }, 249 },
250 250
251 _reset: function() 251 _reset: function()
252 { 252 {
253 var profiles = this._profiles.slice(0); 253 var profiles = this._profiles.slice(0);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 this._fromFile = true; 433 this._fromFile = true;
434 }, 434 },
435 435
436 __proto__: WebInspector.Object.prototype 436 __proto__: WebInspector.Object.prototype
437 } 437 }
438 438
439 /** 439 /**
440 * @constructor 440 * @constructor
441 * @implements {WebInspector.Searchable} 441 * @implements {WebInspector.Searchable}
442 * @implements {WebInspector.ProfileType.DataDisplayDelegate} 442 * @implements {WebInspector.ProfileType.DataDisplayDelegate}
443 * @implements {WebInspector.TargetManager.Observer}
444 * @extends {WebInspector.PanelWithSidebarTree} 443 * @extends {WebInspector.PanelWithSidebarTree}
445 */ 444 */
446 WebInspector.ProfilesPanel = function() 445 WebInspector.ProfilesPanel = function()
447 { 446 {
448 WebInspector.PanelWithSidebarTree.call(this, "profiles"); 447 WebInspector.PanelWithSidebarTree.call(this, "profiles");
449 this.registerRequiredCSS("panelEnablerView.css"); 448 this.registerRequiredCSS("panelEnablerView.css");
450 this.registerRequiredCSS("heapProfiler.css"); 449 this.registerRequiredCSS("heapProfiler.css");
451 this.registerRequiredCSS("profilesPanel.css"); 450 this.registerRequiredCSS("profilesPanel.css");
452 451
453 this._searchableView = new WebInspector.SearchableView(this); 452 this._searchableView = new WebInspector.SearchableView(this);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 for (var i = 0; i < types.length; i++) 493 for (var i = 0; i < types.length; i++)
495 this._registerProfileType(types[i]); 494 this._registerProfileType(types[i]);
496 this._launcherView.restoreSelectedProfileType(); 495 this._launcherView.restoreSelectedProfileType();
497 this.profilesItemTreeElement.select(); 496 this.profilesItemTreeElement.select();
498 this._showLauncherView(); 497 this._showLauncherView();
499 498
500 this._createFileSelectorElement(); 499 this._createFileSelectorElement();
501 this.element.addEventListener("contextmenu", this._handleContextMenuEvent.bi nd(this), true); 500 this.element.addEventListener("contextmenu", this._handleContextMenuEvent.bi nd(this), true);
502 this._registerShortcuts(); 501 this._registerShortcuts();
503 502
504 WebInspector.targetManager.observeTargets(this); 503 WebInspector.profilingLock.addEventListener(WebInspector.Lock.Events.StateCh anged, this._onProfilingStateChanged, this);
505 } 504 }
506 505
507 WebInspector.ProfilesPanel.prototype = { 506 WebInspector.ProfilesPanel.prototype = {
508 /** 507 /**
509 * @param {!WebInspector.Target} target
510 */
511 targetAdded: function(target)
512 {
513 target.profilingLock.addEventListener(WebInspector.Lock.Events.StateChan ged, this._onProfilingStateChanged, this);
514 },
515
516 /**
517 * @param {!WebInspector.Target} target
518 */
519 targetRemoved: function(target)
520 {
521 target.profilingLock.removeEventListener(WebInspector.Lock.Events.StateC hanged, this._onProfilingStateChanged, this);
522 },
523
524 /**
525 * @return {!WebInspector.SearchableView} 508 * @return {!WebInspector.SearchableView}
526 */ 509 */
527 searchableView: function() 510 searchableView: function()
528 { 511 {
529 return this._searchableView; 512 return this._searchableView;
530 }, 513 },
531 514
532 _createFileSelectorElement: function() 515 _createFileSelectorElement: function()
533 { 516 {
534 if (this._fileSelectorElement) 517 if (this._fileSelectorElement)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 this._updateRecordButton(this.recordButton.toggled); 593 this._updateRecordButton(this.recordButton.toggled);
611 }, 594 },
612 595
613 /** 596 /**
614 * @param {boolean} toggled 597 * @param {boolean} toggled
615 */ 598 */
616 _updateRecordButton: function(toggled) 599 _updateRecordButton: function(toggled)
617 { 600 {
618 if (WebInspector.experimentsSettings.disableAgentsWhenProfile.isEnabled( )) 601 if (WebInspector.experimentsSettings.disableAgentsWhenProfile.isEnabled( ))
619 WebInspector.inspectorView.setCurrentPanelLocked(toggled); 602 WebInspector.inspectorView.setCurrentPanelLocked(toggled);
620 var isAcquiredInSomeTarget = WebInspector.targetManager.targets().some(f unction(target) { return target.profilingLock.isAcquired(); }); 603 var isAcquiredInSomeTarget = WebInspector.profilingLock.isAcquired();
621 var enable = toggled || !isAcquiredInSomeTarget; 604 var enable = toggled || !isAcquiredInSomeTarget;
622 this.recordButton.setEnabled(enable); 605 this.recordButton.setEnabled(enable);
623 this.recordButton.toggled = toggled; 606 this.recordButton.toggled = toggled;
624 if (enable) 607 if (enable)
625 this.recordButton.title = this._selectedProfileType ? this._selected ProfileType.buttonTooltip : ""; 608 this.recordButton.title = this._selectedProfileType ? this._selected ProfileType.buttonTooltip : "";
626 else 609 else
627 this.recordButton.title = WebInspector.anotherProfilerActiveLabel(); 610 this.recordButton.title = WebInspector.anotherProfilerActiveLabel();
628 if (this._selectedProfileType) 611 if (this._selectedProfileType)
629 this._launcherView.updateProfileType(this._selectedProfileType, enab le); 612 this._launcherView.updateProfileType(this._selectedProfileType, enab le);
630 }, 613 },
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 this._panel._showLauncherView(); 1287 this._panel._showLauncherView();
1305 }, 1288 },
1306 1289
1307 get selectable() 1290 get selectable()
1308 { 1291 {
1309 return true; 1292 return true;
1310 }, 1293 },
1311 1294
1312 __proto__: WebInspector.SidebarTreeElement.prototype 1295 __proto__: WebInspector.SidebarTreeElement.prototype
1313 } 1296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698