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

Side by Side Diff: chrome/browser/resources/local_ntp/local_ntp_util.js

Issue 2578153002: Cleanup: delete unused local_ntp_util.js (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | 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
(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 /**
7 * @fileoverview Utilities for local_ntp.js.
8 */
9
10
11 /**
12 * A counter with a callback that gets executed on the 1-to-0 transition.
13 *
14 * @param {function()} callback The callback to be executed.
15 * @constructor
16 */
17 function Barrier(callback) {
18 /** @private {function()} */
19 this.callback_ = callback;
20
21 /** @private {number} */
22 this.count_ = 0;
23
24 /** @private {boolean} */
25 this.isCancelled_ = false;
26 }
27
28
29 /**
30 * Increments count of the Barrier.
31 */
32 Barrier.prototype.add = function() {
33 ++this.count_;
34 };
35
36
37 /**
38 * Decrements count of the Barrier, and executes callback on 1-to-0 transition.
39 */
40 Barrier.prototype.remove = function() {
41 if (this.count_ === 0) // Guards against underflow.
42 return;
43 --this.count_;
44 if (!this.isCancelled_ && this.count_ === 0)
45 this.callback_();
46 };
47
48
49 /**
50 * Deactivates the Barrier; the callback will never be executed.
51 */
52 Barrier.prototype.cancel = function() {
53 this.isCancelled_ = true;
54 };
OLDNEW
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698