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

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

Issue 412073002: Local NTP: prevent tiles from reloading on resize by moving them into single <div>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing comments. 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 /**
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
25
26 /**
27 * Increments count of the Barrier.
28 */
29 Barrier.prototype.add = function() {
30 ++this.count_;
31 };
32
33
34 /**
35 * Decrements count of the Barrier, and executes callback on 1-to-0 transition.
36 */
37 Barrier.prototype.remove = function() {
38 if (this.count_ === 0) // Guards against underflow.
39 return;
40 --this.count_;
41 if (this.count_ === 0)
42 this.callback_();
43 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698