Commit 54c74ea7 authored by Dominic Farolino's avatar Dominic Farolino Committed by Commit Bot

Inline request referrer serialization for debugging

In crbug.com/1090391, we're seeing crashes due to an incorrect referrer
header, so this CL, similar to crrev.com/c/1896251 and
crrev.com/c/1954211, inlines the request referrer serialization so we
can get a better stack trace from the process that the request was in
before it was sent to the Network Service.

There is a TODO to undo this, since it is not ideal, and is just
debugging behavior.

R=dcheng@chromium.org, mmenke@chromium.org

Bug: 1090391
Change-Id: Ibd186d02cf13b6bb515867323e6107b7de6a3191
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2229205Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774973}
parent 12660162
......@@ -7,7 +7,6 @@
#include <string>
#include "base/bind.h"
#include "base/debug/dump_without_crashing.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/domain_reliability/monitor.h"
......@@ -259,14 +258,6 @@ bool NetworkServiceNetworkDelegate::
LOG(ERROR) << "Cancelling request to " << target_url
<< " with invalid referrer " << referrer_url;
// Record information to help debug issues like http://crbug.com/422871.
if (target_url.SchemeIsHTTPOrHTTPS()) {
auto referrer_policy = request.referrer_policy();
base::debug::Alias(&referrer_policy);
DEBUG_ALIAS_FOR_GURL(target_buf, target_url);
DEBUG_ALIAS_FOR_GURL(referrer_buf, referrer_url);
base::debug::DumpWithoutCrashing();
}
return true;
}
......
......@@ -267,4 +267,30 @@ bool StructTraits<network::mojom::DataElementDataView, network::DataElement>::
return true;
}
// static
const GURL&
StructTraits<network::mojom::URLRequestDataView, network::ResourceRequest>::
referrer(const network::ResourceRequest& request) {
// TODO(crbug.com/1090391): Move this method back inline, and move the
// debugging logic back to NetworkServiceNetworkDelegate when the current
// cause of referrer mismatches is found.
if (request.referrer !=
net::URLRequestJob::ComputeReferrerForPolicy(
request.referrer_policy, request.referrer, request.url)) {
// Record information to help debug issues like http://crbug.com/422871.
if (request.url.SchemeIsHTTPOrHTTPS()) {
auto referrer_policy = request.referrer_policy;
base::debug::Alias(&referrer_policy);
DEBUG_ALIAS_FOR_GURL(target_buf, request.url);
DEBUG_ALIAS_FOR_GURL(referrer_buf, request.referrer);
DEBUG_ALIAS_FOR_GURL(
initiator_buf,
request.request_initiator.value_or(url::Origin()).GetURL())
base::debug::DumpWithoutCrashing();
}
}
return request.referrer;
}
} // namespace mojo
......@@ -9,6 +9,7 @@
#include <utility>
#include "base/component_export.h"
#include "base/debug/dump_without_crashing.h"
#include "base/memory/scoped_refptr.h"
#include "mojo/public/cpp/base/file_mojom_traits.h"
#include "mojo/public/cpp/base/file_path_mojom_traits.h"
......@@ -109,9 +110,7 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE)
const network::ResourceRequest& request) {
return request.isolated_world_origin;
}
static const GURL& referrer(const network::ResourceRequest& request) {
return request.referrer;
}
static const GURL& referrer(const network::ResourceRequest& request);
static net::URLRequest::ReferrerPolicy referrer_policy(
const network::ResourceRequest& request) {
return request.referrer_policy;
......
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