Commit 324e45c2 authored by Joey Arhar's avatar Joey Arhar Committed by Commit Bot

[DevTools] Remove post data from XHRReplayData

As explained in crbug.com/958524 this post data was only used when using
the xhr replay feature on the OPTIONS request of a CORS preflight.

Now that OOR-CORS has launched crbug.com/905971 CORS preflights won't
show up in DevTools anymore so we don't need to store this extra copy of
post data.

Bug: 958524, 780935
Change-Id: Ifecb37042c5845dc1bfbd594deb6cb635a3d7c72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051443Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742248}
parent c80298a7
......@@ -1137,13 +1137,12 @@ void InspectorNetworkAgent::WillLoadXHR(ExecutionContext* execution_context,
const AtomicString& method,
const KURL& url,
bool async,
EncodedFormData* form_data,
const HTTPHeaderMap& headers,
bool include_credentials) {
DCHECK(!pending_request_type_);
pending_xhr_replay_data_ = MakeGarbageCollected<XHRReplayData>(
execution_context, method, UrlWithoutFragment(url), async,
form_data ? form_data->DeepCopy() : nullptr, include_credentials);
include_credentials);
for (const auto& header : headers)
pending_xhr_replay_data_->AddHeader(header.key, header.value);
DCHECK(!is_handling_sync_xhr_);
......@@ -1486,12 +1485,8 @@ Response InspectorNetworkAgent::replayXHR(const String& request_id) {
xhr->setRequestHeader(header.key, header.value,
IGNORE_EXCEPTION_FOR_TESTING);
}
scoped_refptr<EncodedFormData> post_data;
if (data)
post_data = data->PostData();
if (!post_data)
post_data = xhr_replay_data->FormData();
xhr->SendForInspectorXHRReplay(post_data, IGNORE_EXCEPTION_FOR_TESTING);
xhr->SendForInspectorXHRReplay(data ? data->PostData() : nullptr,
IGNORE_EXCEPTION_FOR_TESTING);
replay_xhrs_.insert(xhr);
return Response::OK();
......
......@@ -150,7 +150,6 @@ class CORE_EXPORT InspectorNetworkAgent final
const AtomicString& method,
const KURL&,
bool async,
EncodedFormData* form_data,
const HTTPHeaderMap& headers,
bool include_crendentials);
void DidFinishXHR(XMLHttpRequest*);
......
......@@ -50,13 +50,11 @@ XHRReplayData::XHRReplayData(ExecutionContext* execution_context,
const AtomicString& method,
const KURL& url,
bool async,
scoped_refptr<EncodedFormData> form_data,
bool include_credentials)
: execution_context_(execution_context),
method_(method),
url_(url),
async_(async),
form_data_(form_data),
include_credentials_(include_credentials) {}
// ResourceData
......@@ -112,11 +110,6 @@ size_t NetworkResourcesData::ResourceData::RemoveContent() {
post_data_ = nullptr;
}
if (xhr_replay_data_ && xhr_replay_data_->FormData()) {
result += xhr_replay_data_->FormData()->SizeInBytes();
xhr_replay_data_->DeleteFormData();
}
return result;
}
......@@ -163,9 +156,6 @@ uint64_t NetworkResourcesData::ResourceData::DataLength() const {
if (post_data_)
data_length += post_data_->SizeInBytes();
if (xhr_replay_data_ && xhr_replay_data_->FormData())
data_length += xhr_replay_data_->FormData()->SizeInBytes();
return data_length;
}
......@@ -370,15 +360,6 @@ void NetworkResourcesData::SetXHRReplayData(const String& request_id,
if (!resource_data || resource_data->IsContentEvicted())
return;
if (xhr_replay_data->FormData()) {
if (!EnsureFreeSpace(xhr_replay_data->FormData()->SizeInBytes())) {
xhr_replay_data->DeleteFormData();
} else {
content_size_ += xhr_replay_data->FormData()->SizeInBytes();
request_ids_deque_.push_back(request_id);
}
}
resource_data->SetXHRReplayData(xhr_replay_data);
}
......
......@@ -54,7 +54,6 @@ class XHRReplayData final : public GarbageCollected<XHRReplayData> {
const AtomicString& method,
const KURL&,
bool async,
scoped_refptr<EncodedFormData>,
bool include_credentials);
void AddHeader(const AtomicString& key, const AtomicString& value);
......@@ -63,21 +62,16 @@ class XHRReplayData final : public GarbageCollected<XHRReplayData> {
const AtomicString& Method() const { return method_; }
const KURL& Url() const { return url_; }
bool Async() const { return async_; }
EncodedFormData* FormData() const { return form_data_.get(); }
const HTTPHeaderMap& Headers() const { return headers_; }
bool IncludeCredentials() const { return include_credentials_; }
virtual void Trace(Visitor* visitor) { visitor->Trace(execution_context_); }
void DeleteFormData() { form_data_ = nullptr; }
private:
WeakMember<ExecutionContext> execution_context_;
AtomicString method_;
KURL url_;
bool async_;
// TODO(http://crbug.com/958524): Remove form_data_ after OutOfBlinkCORS is launched.
scoped_refptr<EncodedFormData> form_data_;
HTTPHeaderMap headers_;
bool include_credentials_;
};
......
......@@ -103,7 +103,7 @@ interface CoreProbes {
void DidFailLoading(CoreProbeSink*, uint64_t identifier, DocumentLoader*, const ResourceError&);
void WillSendEventSourceRequest(ExecutionContext*);
void WillDispatchEventSourceEvent(ExecutionContext*, uint64_t identifier, const AtomicString& event_name, const AtomicString& event_id, const String& data);
void WillLoadXHR([Keep] ExecutionContext*, const AtomicString& method, const KURL& url, bool async, EncodedFormData* form_data, const HTTPHeaderMap& headers, bool include_credentials);
void WillLoadXHR([Keep] ExecutionContext*, const AtomicString& method, const KURL& url, bool async, const HTTPHeaderMap& headers, bool include_credentials);
void DidFinishXHR(ExecutionContext*, XMLHttpRequest* xhr);
void ScriptImported(ExecutionContext*, uint64_t identifier, const String& source_string);
void ScriptExecutionBlockedByCSP(ExecutionContext*, const String& directive_text);
......
......@@ -1061,7 +1061,7 @@ void XMLHttpRequest::CreateRequest(scoped_refptr<EncodedFormData> http_body,
request.SetExternalRequestStateFromRequestorAddressSpace(
execution_context.GetSecurityContext().AddressSpace());
probe::WillLoadXHR(&execution_context, method_, url_, async_, http_body.get(),
probe::WillLoadXHR(&execution_context, method_, url_, async_,
request_headers_, with_credentials_);
if (http_body) {
......
......@@ -30,6 +30,6 @@ Data included: true, has post data: true
Data length: 64
Testing request body eviction
Data included: true, has post data: true
Did not fetch data: No post data available for the request
Data length: 512
Did not fetch data: No post data available for the request
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