Commit 2c172aae authored by Nasko Oskov's avatar Nasko Oskov Committed by Commit Bot

Add support for AsValueInto in NavigationRequest.

Implementing AsValueInto method in NavigationRequest allows it to be
used as input into tracing events macros. This CL adds this support and
uses it to log the NavigationRequest in its constructor.

Bug: 1043616
Change-Id: Iac28d6d52944064e448d99fe2734057ad0cf6ac4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2353546
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797772}
parent 7c5a055c
......@@ -23,6 +23,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "base/trace_event/trace_conversion_helper.h"
#include "build/build_config.h"
#include "content/browser/appcache/appcache_navigation_handle.h"
#include "content/browser/appcache/chrome_appcache_service.h"
......@@ -1119,10 +1120,9 @@ NavigationRequest::NavigationRequest(
DCHECK((IsInMainFrame() && browser_initiated) ||
commit_params_->frame_policy.has_value());
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(
"navigation", "NavigationRequest", navigation_id_, "frame_tree_node",
frame_tree_node_->frame_tree_node_id(), "url",
common_params_->url.possibly_invalid_spec());
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1("navigation", "NavigationRequest",
navigation_id_, "navigation_request",
base::trace_event::ToTracedValue(this));
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("navigation", "Initializing",
navigation_id_);
NavigationControllerImpl* controller = GetNavigationController();
......@@ -4315,6 +4315,30 @@ url::Origin NavigationRequest::GetOriginForURLLoaderFactory() {
return result;
}
void NavigationRequest::AsValueInto(
base::trace_event::TracedValue* traced_value) {
traced_value->SetPointer("this", this);
traced_value->SetInteger("navigation_id", navigation_id_);
traced_value->SetInteger("frame_tree_node",
frame_tree_node_->frame_tree_node_id());
traced_value->SetString("url", common_params_->url.possibly_invalid_spec());
traced_value->SetBoolean("browser_initiated", browser_initiated_);
traced_value->SetBoolean("from_begin_navigation", from_begin_navigation_);
traced_value->SetBoolean("is_for_commit", is_for_commit_);
traced_value->SetInteger("reload_type", static_cast<int>(reload_type_));
traced_value->SetInteger("navigation_type",
static_cast<int>(common_params_->navigation_type));
traced_value->SetInteger("state", static_cast<int>(state_));
if (IsServedFromBackForwardCache()) {
traced_value->SetBoolean("bf cached", true);
rfh_restored_from_back_forward_cache_->AsValueInto(traced_value);
}
if (state_ >= WILL_PROCESS_RESPONSE)
GetRenderFrameHost()->AsValueInto(traced_value);
}
void NavigationRequest::RenderProcessBlockedStateChanged(bool blocked) {
if (blocked)
StopCommitTimeout();
......
......@@ -54,6 +54,12 @@
#include "content/browser/android/navigation_handle_proxy.h"
#endif
namespace base {
namespace trace_event {
class TracedValue;
} // namespace trace_event
} // namespace base
namespace network {
class ResourceRequestBody;
struct URLLoaderCompletionStatus;
......@@ -716,6 +722,10 @@ class CONTENT_EXPORT NavigationRequest
// should be renamed to something like GetOriginToCommit().
url::Origin GetOriginForURLLoaderFactory();
// Add information about this NavigationRequest to |traced_value| for
// tracing purposes.
void AsValueInto(base::trace_event::TracedValue* traced_value);
private:
friend class NavigationRequestTest;
......
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