cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / browser / resources / local_ntp / local_ntp_util.js
blob6b05579a1aec2e679830586331919e97cd680aa5
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.
6 /**
7 * @fileoverview Utilities for local_ntp.js.
8 */
11 /**
12 * A counter with a callback that gets executed on the 1-to-0 transition.
14 * @param {function()} callback The callback to be executed.
15 * @constructor
17 function Barrier(callback) {
18 /** @private {function()} */
19 this.callback_ = callback;
21 /** @private {number} */
22 this.count_ = 0;
24 /** @private {boolean} */
25 this.isCancelled_ = false;
29 /**
30 * Increments count of the Barrier.
32 Barrier.prototype.add = function() {
33 ++this.count_;
37 /**
38 * Decrements count of the Barrier, and executes callback on 1-to-0 transition.
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_();
49 /**
50 * Deactivates the Barrier; the callback will never be executed.
52 Barrier.prototype.cancel = function() {
53 this.isCancelled_ = true;