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

Side by Side Diff: Source/devtools/front_end/common/Lock.js

Issue 471393002: Revert of Make profiling lock global rather than per Target (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @constructor
7 * @extends {WebInspector.Object}
8 */
9 WebInspector.Lock = function()
10 {
11 this._count = 0; // Reentrant.
12 }
13
14 /**
15 * @enum {string}
16 */
17 WebInspector.Lock.Events = {
18 StateChanged: "StateChanged"
19 }
20
21 WebInspector.Lock.prototype = {
22 /**
23 * @return {boolean}
24 */
25 isAcquired: function()
26 {
27 return !!this._count;
28 },
29
30 acquire: function()
31 {
32 if (++this._count === 1)
33 this.dispatchEventToListeners(WebInspector.Lock.Events.StateChanged) ;
34 },
35
36 release: function()
37 {
38 --this._count;
39 if (this._count < 0) {
40 console.error("WebInspector.Lock acquire/release calls are unbalance d " + new Error().stack);
41 return;
42 }
43 if (!this._count)
44 this.dispatchEventToListeners(WebInspector.Lock.Events.StateChanged) ;
45 },
46
47 __proto__: WebInspector.Object.prototype
48 }
49
50 /** @type {!WebInspector.Lock} */
51 WebInspector.profilingLock = new WebInspector.Lock();
OLDNEW
« no previous file with comments | « Source/devtools/front_end/audits/AuditLauncherView.js ('k') | Source/devtools/front_end/common/Object.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698