Commit e38dded5 authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Chromium LUCI CQ

Remove SetupOnUIThread for EmbeddedWorkerInstance

Thanks to ServiceWorkerOnUI, we can eliminate the class and function to
manage thread-hoppings for starting a service worker. This CL moves
tasks in SetupOnUIThread into EmbeddedWorkerInstance::Start().

Bug: 1138155
Change-Id: I15c72d0d45e792e229a4a8f19972b5d90253fc87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2578717
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarAsami Doi <asamidoi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835989}
parent b6f42464
...@@ -59,7 +59,7 @@ FORWARD_DECLARE_TEST(ServiceWorkerNewScriptLoaderTest, AccessedNetwork); ...@@ -59,7 +59,7 @@ FORWARD_DECLARE_TEST(ServiceWorkerNewScriptLoaderTest, AccessedNetwork);
// may be 'in-waiting' or running in one of the child processes added by // may be 'in-waiting' or running in one of the child processes added by
// AddProcessReference(). // AddProcessReference().
// //
// Owned by ServiceWorkerVersion. Lives on the core thread. // Owned by ServiceWorkerVersion.
class CONTENT_EXPORT EmbeddedWorkerInstance class CONTENT_EXPORT EmbeddedWorkerInstance
: public blink::mojom::EmbeddedWorkerInstanceHost { : public blink::mojom::EmbeddedWorkerInstanceHost {
public: public:
...@@ -264,7 +264,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance ...@@ -264,7 +264,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance
private: private:
typedef base::ObserverList<Listener>::Unchecked ListenerList; typedef base::ObserverList<Listener>::Unchecked ListenerList;
class ScopedLifetimeTracker; class ScopedLifetimeTracker;
class StartTask; struct StartInfo;
class WorkerProcessHandle; class WorkerProcessHandle;
friend class EmbeddedWorkerInstanceTest; friend class EmbeddedWorkerInstanceTest;
FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerInstanceTest, StartAndStop); FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerInstanceTest, StartAndStop);
...@@ -274,21 +274,14 @@ class CONTENT_EXPORT EmbeddedWorkerInstance ...@@ -274,21 +274,14 @@ class CONTENT_EXPORT EmbeddedWorkerInstance
ServiceWorkerNewScriptLoaderTest, ServiceWorkerNewScriptLoaderTest,
AccessedNetwork); AccessedNetwork);
// Called back from StartTask after a process is allocated on the UI thread.
void OnProcessAllocated(std::unique_ptr<WorkerProcessHandle> handle, void OnProcessAllocated(std::unique_ptr<WorkerProcessHandle> handle,
ServiceWorkerMetrics::StartSituation start_situation); ServiceWorkerMetrics::StartSituation start_situation);
// Called back from StartTask after the worker is registered to
// WorkerDevToolsManager.
void OnRegisteredToDevToolsManager( void OnRegisteredToDevToolsManager(
std::unique_ptr<DevToolsProxy> devtools_proxy, std::unique_ptr<DevToolsProxy> devtools_proxy);
bool wait_for_debugger);
// Sends the StartWorker message to the renderer. // Sends the StartWorker message to the renderer.
void SendStartWorker(blink::mojom::EmbeddedWorkerStartParamsPtr params); void SendStartWorker(blink::mojom::EmbeddedWorkerStartParamsPtr params);
// Implements blink::mojom::EmbeddedWorkerInstanceHost. // Implements blink::mojom::EmbeddedWorkerInstanceHost.
// These functions all run on the core thread.
void RequestTermination(RequestTerminationCallback callback) override; void RequestTermination(RequestTerminationCallback callback) override;
void CountFeature(blink::mojom::WebFeature feature) override; void CountFeature(blink::mojom::WebFeature feature) override;
void OnReadyForInspection( void OnReadyForInspection(
...@@ -325,7 +318,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance ...@@ -325,7 +318,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance
blink::ServiceWorkerStatusCode status); blink::ServiceWorkerStatusCode status);
// Called when a foreground service worker is added/removed in a process. // Called when a foreground service worker is added/removed in a process.
// Called on the core thread and dispatches task to the UI thread.
void NotifyForegroundServiceWorkerAdded(); void NotifyForegroundServiceWorkerAdded();
void NotifyForegroundServiceWorkerRemoved(); void NotifyForegroundServiceWorkerRemoved();
...@@ -354,7 +346,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance ...@@ -354,7 +346,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance
// using it. The renderer process will disconnect the pipe when appropriate. // using it. The renderer process will disconnect the pipe when appropriate.
mojo::Remote<blink::mojom::EmbeddedWorkerInstanceClient> client_; mojo::Remote<blink::mojom::EmbeddedWorkerInstanceClient> client_;
// Receiver for EmbeddedWorkerInstanceHost, runs on core thread.
mojo::AssociatedReceiver<EmbeddedWorkerInstanceHost> instance_host_receiver_{ mojo::AssociatedReceiver<EmbeddedWorkerInstanceHost> instance_host_receiver_{
this}; this};
...@@ -372,7 +363,9 @@ class CONTENT_EXPORT EmbeddedWorkerInstance ...@@ -372,7 +363,9 @@ class CONTENT_EXPORT EmbeddedWorkerInstance
ListenerList listener_list_; ListenerList listener_list_;
std::unique_ptr<DevToolsProxy> devtools_proxy_; std::unique_ptr<DevToolsProxy> devtools_proxy_;
std::unique_ptr<StartTask> inflight_start_task_; // Contains info to be recorded on completing StartWorker sequence.
// Set on Start() and cleared on OnStarted().
std::unique_ptr<StartInfo> inflight_start_info_;
std::unique_ptr<ScopedLifetimeTracker> lifetime_tracker_; std::unique_ptr<ScopedLifetimeTracker> lifetime_tracker_;
// This is valid only after a process is allocated for the worker. // This is valid only after a process is allocated for the worker.
...@@ -386,8 +379,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance ...@@ -386,8 +379,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance
mojo::SelfOwnedReceiverRef<network::mojom::URLLoaderFactory> mojo::SelfOwnedReceiverRef<network::mojom::URLLoaderFactory>
script_loader_factory_; script_loader_factory_;
const scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
// Remote interface to talk to a running service worker. Used to update // Remote interface to talk to a running service worker. Used to update
// subresource loader factories in the service worker. // subresource loader factories in the service worker.
mojo::Remote<blink::mojom::SubresourceLoaderUpdater> mojo::Remote<blink::mojom::SubresourceLoaderUpdater>
......
...@@ -157,9 +157,6 @@ class ServiceWorkerMetrics { ...@@ -157,9 +157,6 @@ class ServiceWorkerMetrics {
// The browser received the worker started IPC. // The browser received the worker started IPC.
base::TimeTicks local_end; base::TimeTicks local_end;
// Counts the time overhead of UI/IO thread hops during startup.
base::TimeDelta thread_hop_time;
}; };
// Converts an event type to a string. Used for tracing. // Converts an event type to a string. Used for tracing.
......
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