Commit 7e2cc9b3 authored by Nasko Oskov's avatar Nasko Oskov Committed by Commit Bot

Initialize navigation_handle_id_ during construction.

The navigation_handle_id_ is initialized when the navigation starts.
The goal of this CL is to initialize it during the construction of the
NavigationRequest object, so it can be used as unique identifier for
emitting tracing events for the lifetime of the NavigationRequest.

Bug: None
Change-Id: Iee966826d4275a1b6659348d89f7f3dd3855c871
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274596
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarAaron Colwell <acolwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795632}
parent 8cad3af3
......@@ -548,13 +548,6 @@ void RecordReadyToCommitMetrics(
}
}
// Use this to get a new unique ID for a NavigationHandle during construction.
// The returned ID is guaranteed to be nonzero (zero is the "no ID" indicator).
int64_t CreateUniqueHandleID() {
static int64_t unique_id_counter = 0;
return ++unique_id_counter;
}
// Given an net::IPAddress and a CSP set, this function calculates the
// IPAddressSpace which should be associated with the document this navigation
// eventually commits into.
......@@ -1059,6 +1052,10 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateForCommit(
return navigation_request;
}
// static class variable used to generate unique navigation ids for
// NavigationRequest.
int64_t NavigationRequest::unique_id_counter_ = 0;
NavigationRequest::NavigationRequest(
FrameTreeNode* frame_tree_node,
mojom::CommonNavigationParamsPtr common_params,
......@@ -1549,7 +1546,7 @@ void NavigationRequest::StartNavigation(bool is_for_commit) {
DCHECK(!IsNavigationStarted());
SetState(WILL_START_REQUEST);
navigation_handle_id_ = CreateUniqueHandleID();
is_navigation_started_ = true;
modified_request_headers_.Clear();
removed_request_headers_.clear();
......@@ -1615,8 +1612,8 @@ void NavigationRequest::ResetForCrossDocumentRestart() {
// Reset the state of the NavigationRequest, and the navigation_handle_id.
StopCommitTimeout();
SetState(NOT_STARTED);
is_navigation_started_ = false;
processing_navigation_throttle_ = false;
navigation_handle_id_ = 0;
#if defined(OS_ANDROID)
if (navigation_handle_proxy_)
......@@ -4459,7 +4456,7 @@ bool NavigationRequest::HasPrefetchedAlternativeSubresourceSignedExchange() {
}
int64_t NavigationRequest::GetNavigationId() {
return navigation_handle_id_;
return navigation_id_;
}
const GURL& NavigationRequest::GetURL() {
......@@ -4732,7 +4729,7 @@ ReloadType NavigationRequest::NavigationTypeToReloadType(
}
bool NavigationRequest::IsNavigationStarted() const {
return navigation_handle_id_;
return is_navigation_started_;
}
bool NavigationRequest::RequiresSourceSiteInstance() const {
......
......@@ -1108,6 +1108,7 @@ class CONTENT_EXPORT NavigationRequest
scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory_;
NavigationState state_;
bool is_navigation_started_ = false;
std::unique_ptr<NavigationURLLoader> loader_;
......@@ -1317,8 +1318,11 @@ class CONTENT_EXPORT NavigationRequest
// Which proxy server was used for this navigation, if any.
net::ProxyServer proxy_server_;
// The unique id to identify the NavigationHandle with.
int64_t navigation_handle_id_ = 0;
// Unique id that identifies the navigation for which this NavigationRequest
// is created.
const int64_t navigation_id_ = ++unique_id_counter_;
// static member for generating the unique id above.
static int64_t unique_id_counter_;
// Manages the lifetime of a pre-created ServiceWorkerContainerHost until a
// corresponding container is created in the renderer.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment