chore: make WKInterceptableRequest._requestId private (#31762)

With COOP navigation we may need to take over request in the new
provisional page where it will have different id. This is preparation to
that.
This commit is contained in:
Yury Semikhatsky 2024-07-18 15:19:53 -07:00 committed by GitHub
parent 708def8804
commit d007ff3b62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 10 deletions

View File

@ -42,7 +42,7 @@ const errorReasons: { [reason: string]: Protocol.Network.ResourceErrorType } = {
export class WKInterceptableRequest {
private readonly _session: WKSession;
readonly request: network.Request;
readonly _requestId: string;
private readonly _requestId: string;
_timestamp: number;
_wallTime: number;

View File

@ -1032,7 +1032,7 @@ export class WKPage implements PageDelegate {
const request = this._requestIdToRequest.get(event.requestId);
// If we connect late to the target, we could have missed the requestWillBeSent event.
if (request) {
this._handleRequestRedirect(request, event.redirectResponse, event.timestamp);
this._handleRequestRedirect(request, event.requestId, event.redirectResponse, event.timestamp);
redirectedFrom = request;
}
}
@ -1048,7 +1048,7 @@ export class WKPage implements PageDelegate {
const request = new WKInterceptableRequest(session, frame, event, redirectedFrom, documentId);
let route;
if (intercepted) {
route = new WKRouteImpl(session, request._requestId);
route = new WKRouteImpl(session, event.requestId);
// There is no point in waiting for the raw headers in Network.responseReceived when intercepting.
// Use provisional headers as raw headers, so that client can call allHeaders() from the route handler.
request.request.setRawRequestHeaders(null);
@ -1057,14 +1057,14 @@ export class WKPage implements PageDelegate {
this._page._frameManager.requestStarted(request.request, route);
}
private _handleRequestRedirect(request: WKInterceptableRequest, responsePayload: Protocol.Network.Response, timestamp: number) {
private _handleRequestRedirect(request: WKInterceptableRequest, requestId: string, responsePayload: Protocol.Network.Response, timestamp: number) {
const response = request.createResponse(responsePayload);
response._securityDetailsFinished();
response._serverAddrFinished();
response.setResponseHeadersSize(null);
response.setEncodedBodySize(null);
response._requestFinished(responsePayload.timing ? helper.secondsToRoundishMillis(timestamp - request._timestamp) : -1);
this._requestIdToRequest.delete(request._requestId);
this._requestIdToRequest.delete(requestId);
this._page._frameManager.requestReceivedResponse(response);
this._page._frameManager.reportRequestFinished(request.request, response);
}
@ -1094,7 +1094,7 @@ export class WKPage implements PageDelegate {
if (!request)
return;
this._requestIdToResponseReceivedPayloadEvent.set(request._requestId, event);
this._requestIdToResponseReceivedPayloadEvent.set(event.requestId, event);
const response = request.createResponse(event.response);
this._page._frameManager.requestReceivedResponse(response);
@ -1118,7 +1118,7 @@ export class WKPage implements PageDelegate {
// event from protocol. @see https://crbug.com/883475
const response = request.request._existingResponse();
if (response) {
const responseReceivedPayload = this._requestIdToResponseReceivedPayloadEvent.get(request._requestId);
const responseReceivedPayload = this._requestIdToResponseReceivedPayloadEvent.get(event.requestId);
response._serverAddrFinished(parseRemoteAddress(event?.metrics?.remoteAddress));
response._securityDetailsFinished({
protocol: isLoadedSecurely(response.url(), response.timing()) ? event.metrics?.securityConnection?.protocol : undefined,
@ -1137,8 +1137,8 @@ export class WKPage implements PageDelegate {
request.request.setRawRequestHeaders(null);
}
this._requestIdToResponseReceivedPayloadEvent.delete(request._requestId);
this._requestIdToRequest.delete(request._requestId);
this._requestIdToResponseReceivedPayloadEvent.delete(event.requestId);
this._requestIdToRequest.delete(event.requestId);
this._page._frameManager.reportRequestFinished(request.request, response);
}
@ -1168,7 +1168,7 @@ export class WKPage implements PageDelegate {
// Use provisional headers if we didn't have the response with raw headers.
request.request.setRawRequestHeaders(null);
}
this._requestIdToRequest.delete(request._requestId);
this._requestIdToRequest.delete(event.requestId);
request.request._setFailureText(event.errorText);
this._page._frameManager.requestFailed(request.request, event.errorText.includes('cancelled'));
}