CORS: Reconstruct URLRequest's NetLogWithSource
This is one of the patches of logging CORS preflight request in NetLog.
design doc (Internal):
https://docs.google.com/document/d/1VambUhLsBYXPg9tOXPtTmYgUHXXuArIbBOQAOw8YcKU/edit?usp=sharing
In the case URLLoader was created by CorsURLLoaderFactory, we want to
log CORS related events and original URLRequest events as a series of
logs. So we'll make URLLoader be taken over NetLogSource id from
CorsURLLoader and reconstruct NetLogWithSource by using this id.
We add a new NetLog related field to ResourceRequest in this CL.
https://crrev.com/c/3137837
Now URLLoader can receive the NetLogSource id. We want to reconstruct
URLRequest's NetLogWithSource before first NetLogEvent occurs in
constructor. It's best to reconstruct NetLogWithSource in the
URLRequest's constructor, however, the number of CreateRequest's call
site is too large to change manually. So we introduced
CreateRequestWithNetLogSourceId.
Change-Id: Ic8665532acec6596a68782e3e0d756d00bdd75c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3156319
Reviewed-by: Kinuko Yasuda <[email protected]>
Reviewed-by: Takashi Toyoshima <[email protected]>
Reviewed-by: Matt Menke <[email protected]>
Reviewed-by: Kenichi Ishibashi <[email protected]>
Commit-Queue: Ai Nozaki <[email protected]>
Cr-Commit-Position: refs/heads/main@{#922382}
diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc
index bdb77dc..382b195 100644
--- a/net/url_request/url_request_context.cc
+++ b/net/url_request/url_request_context.cc
@@ -5,6 +5,7 @@
#include "net/url_request/url_request_context.h"
#include <inttypes.h>
+#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/debug/alias.h"
@@ -100,9 +101,11 @@
RequestPriority priority,
URLRequest::Delegate* delegate,
NetworkTrafficAnnotationTag traffic_annotation,
- bool is_for_websockets) const {
- return base::WrapUnique(new URLRequest(
- url, priority, delegate, this, traffic_annotation, is_for_websockets));
+ bool is_for_websockets,
+ const absl::optional<uint32_t> net_log_source_id) const {
+ return base::WrapUnique(new URLRequest(url, priority, delegate, this,
+ traffic_annotation, is_for_websockets,
+ net_log_source_id));
}
void URLRequestContext::set_cookie_store(CookieStore* cookie_store) {