Commit 1da74ecc authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Add a use counter for Body::body in a ServiceWorker

Add the use counter FetchBodyStreamInServiceWorker which is triggered
when the body getter is accessed in the Response class.

The purpose of the use counter is to evaluate the potential benefit of
Response body stream optimisations.

Change-Id: I625bb08712f6fc1996def8bdab52a449fc725f07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1909675Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714764}
parent 1c2cff62
...@@ -2467,6 +2467,8 @@ enum WebFeature { ...@@ -2467,6 +2467,8 @@ enum WebFeature {
kByteLengthQueuingStrategyConstructor = 3083, kByteLengthQueuingStrategyConstructor = 3083,
kClassicDedicatedWorker = 3084, kClassicDedicatedWorker = 3084,
kModuleDedicatedWorker = 3085, kModuleDedicatedWorker = 3085,
kFetchBodyStreamInServiceWorker = 3086,
kFetchBodyStreamOutsideServiceWorker = 3087,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "third_party/blink/renderer/core/fetch/body_stream_buffer.h" #include "third_party/blink/renderer/core/fetch/body_stream_buffer.h"
#include "third_party/blink/renderer/core/fetch/fetch_data_loader.h" #include "third_party/blink/renderer/core/fetch/fetch_data_loader.h"
#include "third_party/blink/renderer/core/fileapi/blob.h" #include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/html/forms/form_data.h" #include "third_party/blink/renderer/core/html/forms/form_data.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h" #include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h"
...@@ -349,6 +350,14 @@ ScriptPromise Body::text(ScriptState* script_state, ...@@ -349,6 +350,14 @@ ScriptPromise Body::text(ScriptState* script_state,
} }
ReadableStream* Body::body() { ReadableStream* Body::body() {
auto* execution_context = GetExecutionContext();
if (execution_context->IsServiceWorkerGlobalScope()) {
execution_context->CountUse(WebFeature::kFetchBodyStreamInServiceWorker);
} else {
execution_context->CountUse(
WebFeature::kFetchBodyStreamOutsideServiceWorker);
}
if (!BodyBuffer()) if (!BodyBuffer())
return nullptr; return nullptr;
return BodyBuffer()->Stream(); return BodyBuffer()->Stream();
......
...@@ -25436,6 +25436,8 @@ Called by update_net_error_codes.py.--> ...@@ -25436,6 +25436,8 @@ Called by update_net_error_codes.py.-->
<int value="3083" label="ByteLengthQueuingStrategyConstructor"/> <int value="3083" label="ByteLengthQueuingStrategyConstructor"/>
<int value="3084" label="ClassicDedicatedWorker"/> <int value="3084" label="ClassicDedicatedWorker"/>
<int value="3085" label="ModuleDedicatedWorker"/> <int value="3085" label="ModuleDedicatedWorker"/>
<int value="3086" label="FetchBodyStreamInServiceWorker"/>
<int value="3087" label="FetchBodyStreamOutsideServiceWorker"/>
</enum> </enum>
<enum name="FeaturePolicyAllowlistType"> <enum name="FeaturePolicyAllowlistType">
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