Do not count inflight requests explicitly - use set. (#202)
This commit is contained in:
parent
20ba447689
commit
82fbb268db
@ -36,7 +36,6 @@ class NavigatorWatcher {
|
||||
* @return {!Promise<!Map<string, !Response>>}
|
||||
*/
|
||||
async waitForNavigation() {
|
||||
this._inflightRequests = 0;
|
||||
this._requestIds = new Set();
|
||||
|
||||
this._eventListeners = [];
|
||||
@ -84,9 +83,7 @@ class NavigatorWatcher {
|
||||
*/
|
||||
_onLoadingStarted(event) {
|
||||
this._requestIds.add(event.requestId);
|
||||
if (!event.redirectResponse)
|
||||
++this._inflightRequests;
|
||||
if (this._inflightRequests > this._idleInflight) {
|
||||
if (this._requestIds.size > this._idleInflight) {
|
||||
clearTimeout(this._idleTimer);
|
||||
this._idleTimer = null;
|
||||
}
|
||||
@ -96,11 +93,8 @@ class NavigatorWatcher {
|
||||
* @param {!Object} event
|
||||
*/
|
||||
_onLoadingCompleted(event) {
|
||||
if (!this._requestIds.has(event.requestId))
|
||||
return;
|
||||
|
||||
--this._inflightRequests;
|
||||
if (this._inflightRequests <= this._idleInflight && !this._idleTimer)
|
||||
this._requestIds.delete(event.requestId);
|
||||
if (this._requestIds.size <= this._idleInflight && !this._idleTimer)
|
||||
this._idleTimer = setTimeout(this._networkIdleCallback, this._idleTime);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user