mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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>>}
|
* @return {!Promise<!Map<string, !Response>>}
|
||||||
*/
|
*/
|
||||||
async waitForNavigation() {
|
async waitForNavigation() {
|
||||||
this._inflightRequests = 0;
|
|
||||||
this._requestIds = new Set();
|
this._requestIds = new Set();
|
||||||
|
|
||||||
this._eventListeners = [];
|
this._eventListeners = [];
|
||||||
@ -84,9 +83,7 @@ class NavigatorWatcher {
|
|||||||
*/
|
*/
|
||||||
_onLoadingStarted(event) {
|
_onLoadingStarted(event) {
|
||||||
this._requestIds.add(event.requestId);
|
this._requestIds.add(event.requestId);
|
||||||
if (!event.redirectResponse)
|
if (this._requestIds.size > this._idleInflight) {
|
||||||
++this._inflightRequests;
|
|
||||||
if (this._inflightRequests > this._idleInflight) {
|
|
||||||
clearTimeout(this._idleTimer);
|
clearTimeout(this._idleTimer);
|
||||||
this._idleTimer = null;
|
this._idleTimer = null;
|
||||||
}
|
}
|
||||||
@ -96,11 +93,8 @@ class NavigatorWatcher {
|
|||||||
* @param {!Object} event
|
* @param {!Object} event
|
||||||
*/
|
*/
|
||||||
_onLoadingCompleted(event) {
|
_onLoadingCompleted(event) {
|
||||||
if (!this._requestIds.has(event.requestId))
|
this._requestIds.delete(event.requestId);
|
||||||
return;
|
if (this._requestIds.size <= this._idleInflight && !this._idleTimer)
|
||||||
|
|
||||||
--this._inflightRequests;
|
|
||||||
if (this._inflightRequests <= this._idleInflight && !this._idleTimer)
|
|
||||||
this._idleTimer = setTimeout(this._networkIdleCallback, this._idleTime);
|
this._idleTimer = setTimeout(this._networkIdleCallback, this._idleTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user