Commit 85296db1 authored by Lily Chen's avatar Lily Chen Committed by Commit Bot

Add SiteForCookies and initiator origin to NetLog event for URLRequests

This makes it easier to debug cookie issues, as the SameSite cookie
context is calculated based on these two parameters.

Bug: None
Change-Id: I05bf03533fb1a481fc71a610971da9f8e40de2f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2068580
Commit-Queue: Lily Chen <chlily@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745699}
parent 83d937e7
...@@ -822,10 +822,13 @@ EVENT_TYPE(SOCKET_POOL_CONNECTING_N_SOCKETS) ...@@ -822,10 +822,13 @@ EVENT_TYPE(SOCKET_POOL_CONNECTING_N_SOCKETS)
// { // {
// "url": <String of URL being loaded>, // "url": <String of URL being loaded>,
// "method": <The method ("POST" or "GET" or "HEAD" etc..)>, // "method": <The method ("POST" or "GET" or "HEAD" etc..)>,
// "initiator": <Initiator origin of the request, if any, or else "not an
// origin">,
// "load_flags": <Numeric value of the combined load flags>, // "load_flags": <Numeric value of the combined load flags>,
// "privacy_mode": <True if privacy mode is enabled for the request> // "privacy_mode": <True if privacy mode is enabled for the request>,
// "network_isolation_key": <NIK associated with the request> // "network_isolation_key": <NIK associated with the request>,
// "priority": <Numeric priority of the request>, // "priority": <Numeric priority of the request>,
// "site_for_cookies": <SiteForCookies associated with the request>,
// "traffic_annotation": <int32 for the request's TrafficAnnotationTag>, // "traffic_annotation": <int32 for the request's TrafficAnnotationTag>,
// "upload_id" <String of upload body identifier, if present>, // "upload_id" <String of upload body identifier, if present>,
// } // }
......
...@@ -623,6 +623,7 @@ void URLRequest::StartJob(URLRequestJob* job) { ...@@ -623,6 +623,7 @@ void URLRequest::StartJob(URLRequestJob* job) {
net_log_.BeginEvent(NetLogEventType::URL_REQUEST_START_JOB, [&] { net_log_.BeginEvent(NetLogEventType::URL_REQUEST_START_JOB, [&] {
return NetLogURLRequestStartParams( return NetLogURLRequestStartParams(
url(), method_, load_flags_, privacy_mode_, network_isolation_key_, url(), method_, load_flags_, privacy_mode_, network_isolation_key_,
site_for_cookies_, initiator_,
upload_data_stream_ ? upload_data_stream_->identifier() : -1); upload_data_stream_ ? upload_data_stream_->identifier() : -1);
}); });
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "net/base/network_isolation_key.h" #include "net/base/network_isolation_key.h"
#include "net/cookies/site_for_cookies.h"
#include "net/log/net_log_capture_mode.h" #include "net/log/net_log_capture_mode.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "url/origin.h"
namespace net { namespace net {
...@@ -31,6 +33,8 @@ base::Value NetLogURLRequestStartParams( ...@@ -31,6 +33,8 @@ base::Value NetLogURLRequestStartParams(
int load_flags, int load_flags,
PrivacyMode privacy_mode, PrivacyMode privacy_mode,
const NetworkIsolationKey& network_isolation_key, const NetworkIsolationKey& network_isolation_key,
const SiteForCookies& site_for_cookies,
const base::Optional<url::Origin>& initiator,
int64_t upload_id) { int64_t upload_id) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey("url", url.possibly_invalid_spec()); dict.SetStringKey("url", url.possibly_invalid_spec());
...@@ -39,6 +43,9 @@ base::Value NetLogURLRequestStartParams( ...@@ -39,6 +43,9 @@ base::Value NetLogURLRequestStartParams(
dict.SetIntKey("privacy_mode", privacy_mode == PRIVACY_MODE_ENABLED); dict.SetIntKey("privacy_mode", privacy_mode == PRIVACY_MODE_ENABLED);
dict.SetStringKey("network_isolation_key", dict.SetStringKey("network_isolation_key",
network_isolation_key.ToDebugString()); network_isolation_key.ToDebugString());
dict.SetStringKey("site_for_cookies", site_for_cookies.ToDebugString());
dict.SetStringKey("initiator", initiator.has_value() ? initiator->Serialize()
: "not an origin");
if (upload_id > -1) if (upload_id > -1)
dict.SetStringKey("upload_id", base::NumberToString(upload_id)); dict.SetStringKey("upload_id", base::NumberToString(upload_id));
return dict; return dict;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/optional.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
#include "net/base/privacy_mode.h" #include "net/base/privacy_mode.h"
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
...@@ -22,9 +23,14 @@ namespace base { ...@@ -22,9 +23,14 @@ namespace base {
class Value; class Value;
} }
namespace url {
class Origin;
}
namespace net { namespace net {
class NetworkIsolationKey; class NetworkIsolationKey;
class SiteForCookies;
// Returns a Value containing NetLog parameters for constructing a URLRequest. // Returns a Value containing NetLog parameters for constructing a URLRequest.
NET_EXPORT base::Value NetLogURLRequestConstructorParams( NET_EXPORT base::Value NetLogURLRequestConstructorParams(
...@@ -39,6 +45,8 @@ NET_EXPORT base::Value NetLogURLRequestStartParams( ...@@ -39,6 +45,8 @@ NET_EXPORT base::Value NetLogURLRequestStartParams(
int load_flags, int load_flags,
PrivacyMode privacy_mode, PrivacyMode privacy_mode,
const NetworkIsolationKey& network_isolation_key, const NetworkIsolationKey& network_isolation_key,
const SiteForCookies& site_for_cookies,
const base::Optional<url::Origin>& initiator,
int64_t upload_id); int64_t upload_id);
} // namespace net } // namespace net
......
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