Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shared storage] add implementation for blink-style worklet
What: currently the worklet lives in a ThreadPool thread and the JS bindings are added via native v8 / Gin library. This CL added the implementation to use the blink worklet pattern: create the thread via ThreadedWorkletMessagingProxy, and rely on IDLs & blink functions for the JS bindings and function execution. For this CL, the only thing this worklet can do is to execute a module script (still using the existing custom network loader to download the script content), which makes the new system testable E2E. Why: with the IDL, worklet functions will align more with the web standard (e.g. JS function input param validation), and will be easier to extend (e.g. add new bindings); easier to connect to devtool/debugger. How: - Create classes SharedStorageWorkletMessagingProxy/WorkletThread/GlobalScope similar to the pattern creating regular blink worklet. - The thread is created in agent_scheduling_group.cc (which is NOT associated with an ExecutionContext) - When there’s a need for the main thread’s `execution_context`, we’ll either disable the code path (e.g. for devtool connection), or use default values (e.g. for many params in the GlobalScopeCreationParams). Created a meta bug to track those special-cased scenarios (crbug/1419253); the default values and skipped code paths are not needed for the initial migration work. - Pass in the main thread task runner (as a counterpart for ParentExecutionContextTaskRunners when there's no ExecutionContext) for the worklet thread to notify the main thread about the its termination. Fuchsia-Binary-Size: Size increase is unavoidable. Bug: 1414951 Change-Id: I37039b87fba466ae3aa1ba99cbeda58d1b0b19c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4284641 Reviewed-by: Nate Chapin <japhet@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Cammie Smith Barnes <cammie@chromium.org> Commit-Queue: Yao Xiao <yaoxia@chromium.org> Cr-Commit-Position: refs/heads/main@{#1117746}
- Loading branch information
1 parent
ae39685
commit dfb8931
Showing
48 changed files
with
1,359 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
{{SCRIPT_BODY}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
third_party/blink/public/web/web_shared_storage_worklet_thread.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SHARED_STORAGE_WORKLET_THREAD_H_ | ||
#define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SHARED_STORAGE_WORKLET_THREAD_H_ | ||
|
||
#include "base/memory/scoped_refptr.h" | ||
#include "base/task/single_thread_task_runner.h" | ||
#include "mojo/public/cpp/bindings/pending_receiver.h" | ||
#include "third_party/blink/public/mojom/shared_storage/shared_storage_worklet_service.mojom-forward.h" | ||
#include "third_party/blink/public/platform/web_common.h" | ||
|
||
namespace blink { | ||
|
||
// An interface to start a self-owned shared storage worklet thread. | ||
class BLINK_EXPORT WebSharedStorageWorkletThread { | ||
public: | ||
static void Start( | ||
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, | ||
mojo::PendingReceiver<mojom::SharedStorageWorkletService> receiver); | ||
|
||
virtual ~WebSharedStorageWorkletThread() = default; | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SHARED_STORAGE_WORKLET_THREAD_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.