Commit fc8a9d66 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

Add trace events for NavigationBodyLoader, background parser, xss auditor.

This would have been useful in the investigation of the linked bug,
otherwise we just see an unknown URLLoaderClient impl taking all the
time.

Bug: 931193
Change-Id: Ic198315ed6272155eca8a14ca8f3a29b17b93251
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574873Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652830}
parent 6c776f45
......@@ -139,6 +139,8 @@ void NavigationBodyLoader::OnTransferSizeUpdated(int32_t transfer_size_diff) {
void NavigationBodyLoader::OnStartLoadingResponseBody(
mojo::ScopedDataPipeConsumerHandle handle) {
TRACE_EVENT1("loading", "NavigationBodyLoader::OnStartLoadingResponseBody",
"url", resource_load_info_->url.possibly_invalid_spec());
DCHECK(!has_received_body_handle_);
DCHECK(!has_received_completion_);
has_received_body_handle_ = true;
......@@ -171,6 +173,8 @@ void NavigationBodyLoader::SetDefersLoading(bool defers) {
void NavigationBodyLoader::StartLoadingBody(
WebNavigationBodyLoader::Client* client,
bool use_isolated_code_cache) {
TRACE_EVENT1("loading", "NavigationBodyLoader::StartLoadingBody", "url",
resource_load_info_->url.possibly_invalid_spec());
client_ = client;
NotifyResourceResponseReceived(render_frame_id_, resource_load_info_.get(),
......@@ -216,6 +220,8 @@ void NavigationBodyLoader::OnConnectionClosed() {
}
void NavigationBodyLoader::OnReadable(MojoResult unused) {
TRACE_EVENT1("loading", "NavigationBodyLoader::OnReadable", "url",
resource_load_info_->url.possibly_invalid_spec());
if (has_seen_end_of_data_ || is_deferred_ || is_in_on_readable_)
return;
// Protect against reentrancy:
......@@ -233,6 +239,8 @@ void NavigationBodyLoader::OnReadable(MojoResult unused) {
}
void NavigationBodyLoader::ReadFromDataPipe() {
TRACE_EVENT1("loading", "NavigationBodyLoader::ReadFromDataPipe", "url",
resource_load_info_->url.possibly_invalid_spec());
uint32_t num_bytes_consumed = 0;
while (!is_deferred_) {
const void* buffer = nullptr;
......
......@@ -301,6 +301,9 @@ void URLLoaderClientImpl::OnTransferSizeUpdated(int32_t transfer_size_diff) {
void URLLoaderClientImpl::OnStartLoadingResponseBody(
mojo::ScopedDataPipeConsumerHandle body) {
TRACE_EVENT1("loading", "URLLoaderClientImpl::OnStartLoadingResponseBody",
"url", last_loaded_url_.possibly_invalid_spec());
DCHECK(has_received_response_head_);
DCHECK(!has_received_response_body_);
has_received_response_body_ = true;
......
......@@ -55,6 +55,7 @@ std::unique_ptr<TextResourceDecoder> DecodedDataDocumentParser::TakeDecoder() {
}
void DecodedDataDocumentParser::AppendBytes(const char* data, size_t length) {
TRACE_EVENT0("loading", "DecodedDataDocumentParser::AppendBytes");
if (!length)
return;
......
......@@ -78,6 +78,8 @@ void BackgroundHTMLParser::Init(
std::unique_ptr<CachedDocumentParameters> cached_document_parameters,
const MediaValuesCached::MediaValuesCachedData& media_values_cached_data,
bool priority_hints_origin_trial_enabled) {
TRACE_EVENT1("loading", "BackgroundHTMLParser::Init", "url",
document_url.GetString().Utf8());
preload_scanner_.reset(new TokenPreloadScanner(
document_url, std::move(cached_document_parameters),
media_values_cached_data, TokenPreloadScanner::ScannerType::kMainDocument,
......@@ -106,6 +108,7 @@ BackgroundHTMLParser::~BackgroundHTMLParser() = default;
void BackgroundHTMLParser::AppendRawBytesFromMainThread(
std::unique_ptr<Vector<char>> buffer) {
TRACE_EVENT0("loading", "BackgroundHTMLParser::AppendRawBytesFromMainThread");
DCHECK(decoder_);
UpdateDocument(decoder_->Decode(buffer->data(), buffer->size()));
}
......
......@@ -769,6 +769,7 @@ void HTMLDocumentParser::insert(const String& source) {
}
void HTMLDocumentParser::StartBackgroundParser() {
TRACE_EVENT0("blink,loading", "HTMLDocumentParser::StartBackgroundParser");
DCHECK(!IsStopped());
DCHECK(ShouldUseThreading());
DCHECK(!have_background_parser_);
......
......@@ -363,6 +363,7 @@ void XSSAuditor::InitForFragment() {
void XSSAuditor::Init(Document* document,
XSSAuditorDelegate* auditor_delegate) {
TRACE_EVENT0("loading", "XSSAuditor::Init");
DCHECK(IsMainThread());
if (state_ != kUninitialized)
return;
......@@ -464,6 +465,7 @@ void XSSAuditor::Init(Document* document,
}
void XSSAuditor::SetEncoding(const WTF::TextEncoding& encoding) {
TRACE_EVENT0("loading", "XSSAuditor::SetEncoding");
const wtf_size_t kMiniumLengthForSuffixTree =
512; // FIXME: Tune this parameter.
const int kSuffixTreeDepth = 5;
......@@ -843,6 +845,8 @@ String XSSAuditor::SnippetFromAttribute(const FilterTokenRequest& request,
}
String XSSAuditor::Canonicalize(String snippet, TruncationKind treatment) {
TRACE_EVENT0("loading", "XSSAuditor::Canonicalize");
String decoded_snippet = FullyDecodeString(snippet, encoding_);
if (treatment != kNoTruncation) {
......
......@@ -517,6 +517,7 @@ void DocumentLoader::BodyCodeCacheReceived(
}
void DocumentLoader::BodyDataReceived(base::span<const char> data) {
TRACE_EVENT0("loading", "DocumentLoader::BodyDataReceived");
GetFrameLoader().Progress().IncrementProgress(main_resource_identifier_,
data.size());
probe::DidReceiveData(probe::ToCoreProbeSink(GetFrame()),
......@@ -532,6 +533,7 @@ void DocumentLoader::BodyLoadingFinished(
int64_t total_decoded_body_length,
bool should_report_corb_blocking,
const base::Optional<WebURLError>& error) {
TRACE_EVENT0("loading", "DocumentLoader::BodyLoadingFinished");
response_.SetEncodedDataLength(total_encoded_data_length);
response_.SetEncodedBodyLength(total_encoded_body_length);
response_.SetDecodedBodyLength(total_decoded_body_length);
......@@ -886,6 +888,7 @@ void DocumentLoader::CommitNavigation(const AtomicString& mime_type,
}
void DocumentLoader::CommitData(const char* bytes, size_t length) {
TRACE_EVENT1("loading", "DocumentLoader::CommitData", "length", length);
DCHECK_GE(state_, kCommitted);
// This can happen if document.close() is called by an event handler while
......@@ -909,6 +912,7 @@ void DocumentLoader::CommitData(const char* bytes, size_t length) {
}
void DocumentLoader::HandleData(const char* data, size_t length) {
TRACE_EVENT1("loading", "DocumentLoader::HandleData", "length", length);
DCHECK(data);
DCHECK(length);
DCHECK(!frame_->GetPage()->Paused());
......
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