OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Queue of pending requests from an origin. | 6 * @fileoverview Queue of pending requests from an origin. |
7 * | 7 * |
8 */ | 8 */ |
9 'use strict'; | 9 'use strict'; |
10 | 10 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 }, 0); | 157 }, 0); |
158 } | 158 } |
159 return token; | 159 return token; |
160 }; | 160 }; |
161 | 161 |
162 /** | 162 /** |
163 * @constructor | 163 * @constructor |
164 */ | 164 */ |
165 function OriginKeyedRequestQueue() { | 165 function OriginKeyedRequestQueue() { |
166 /** @private {Object.<string, !RequestQueue>} */ | 166 /** @private {Object<string, !RequestQueue>} */ |
167 this.requests_ = {}; | 167 this.requests_ = {}; |
168 } | 168 } |
169 | 169 |
170 /** | 170 /** |
171 * Queues this request, and, if it's the first request, begins work on it. | 171 * Queues this request, and, if it's the first request, begins work on it. |
172 * @param {string} appId Application Id | 172 * @param {string} appId Application Id |
173 * @param {string} origin Request origin | 173 * @param {string} origin Request origin |
174 * @param {function(QueuedRequestToken)} beginCb Called when work begins on this | 174 * @param {function(QueuedRequestToken)} beginCb Called when work begins on this |
175 * request. | 175 * request. |
176 * @param {Countdown} timer Countdown timer | 176 * @param {Countdown} timer Countdown timer |
177 * @return {QueuedRequestToken} A token for the request. | 177 * @return {QueuedRequestToken} A token for the request. |
178 */ | 178 */ |
179 OriginKeyedRequestQueue.prototype.queueRequest = | 179 OriginKeyedRequestQueue.prototype.queueRequest = |
180 function(appId, origin, beginCb, timer) { | 180 function(appId, origin, beginCb, timer) { |
181 var key = appId + ' ' + origin; | 181 var key = appId + ' ' + origin; |
182 if (!this.requests_.hasOwnProperty(key)) { | 182 if (!this.requests_.hasOwnProperty(key)) { |
183 this.requests_[key] = new RequestQueue(); | 183 this.requests_[key] = new RequestQueue(); |
184 } | 184 } |
185 var queue = this.requests_[key]; | 185 var queue = this.requests_[key]; |
186 return queue.queueRequest(beginCb, timer); | 186 return queue.queueRequest(beginCb, timer); |
187 }; | 187 }; |
OLD | NEW |