Commit 27ca3331 authored by Sigurður Ásgeirsson's avatar Sigurður Ásgeirsson Committed by Commit Bot

Revert "[PM] Add service worker clients to the graph."

This reverts commit 39fc8ffd.

Reason for revert: https://crbug.com/1142776.

Original change's description:
> [PM] Add service worker clients to the graph.
>
> This is lifted from Pat's change at
> https://chromium-review.googlesource.com/c/chromium/src/+/2355089
>
> Bug: 993029, 1088353, 1121069
> Change-Id: Ibdc91c07a235be347cbe1704f0fe5e77cff73470
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490221
> Reviewed-by: Patrick Monette <pmonette@chromium.org>
> Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#820771}

TBR=pmonette@chromium.org,siggi@chromium.org

Change-Id: I3f7f5694c7e2ed98a176a9521eea551f51e2eb61
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 993029
Bug: 1088353
Bug: 1121069
Bug: 1142776
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502788Reviewed-by: default avatarSigurður Ásgeirsson <siggi@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821207}
parent 3f3ab048
......@@ -356,117 +356,19 @@ void WorkerWatcher::OnControlleeAdded(
int64_t version_id,
const std::string& client_uuid,
const content::ServiceWorkerClientInfo& client_info) {
switch (client_info.type()) {
case blink::mojom::ServiceWorkerClientType::kWindow: {
// For window clients, it is necessary to wait until the navigation has
// committed to a render frame host.
bool inserted = client_frames_awaiting_commit_.insert(client_uuid).second;
DCHECK(inserted);
break;
}
case blink::mojom::ServiceWorkerClientType::kDedicatedWorker: {
blink::DedicatedWorkerToken dedicated_worker_token =
client_info.GetDedicatedWorkerToken();
bool inserted = service_worker_clients_[version_id]
.emplace(client_uuid, dedicated_worker_token)
.second;
DCHECK(inserted);
// If the service worker is already started, connect it to the client.
WorkerNodeImpl* service_worker_node = GetServiceWorkerNode(version_id);
if (service_worker_node)
ConnectDedicatedWorkerClient(service_worker_node,
dedicated_worker_token);
break;
}
case blink::mojom::ServiceWorkerClientType::kSharedWorker: {
blink::SharedWorkerToken shared_worker_token =
client_info.GetSharedWorkerToken();
bool inserted = service_worker_clients_[version_id]
.emplace(client_uuid, shared_worker_token)
.second;
DCHECK(inserted);
// If the service worker is already started, connect it to the client.
WorkerNodeImpl* service_worker_node = GetServiceWorkerNode(version_id);
if (service_worker_node)
ConnectSharedWorkerClient(service_worker_node, shared_worker_token);
break;
}
case blink::mojom::ServiceWorkerClientType::kAll:
NOTREACHED();
break;
}
// TODO(pmonette): Handle service worker clients.
}
void WorkerWatcher::OnControlleeRemoved(int64_t version_id,
const std::string& client_uuid) {
// Nothing to do for a frame client whose navigation never committed.
size_t removed = client_frames_awaiting_commit_.erase(client_uuid);
if (removed) {
#if DCHECK_IS_ON()
// |client_uuid| should not be part of this service worker's clients.
auto it = service_worker_clients_.find(version_id);
if (it != service_worker_clients_.end())
DCHECK(!base::Contains(it->second, client_uuid));
#endif // DCHECK_IS_ON()
return;
}
// First get clients for this worker.
auto it = service_worker_clients_.find(version_id);
DCHECK(it != service_worker_clients_.end());
base::flat_map<std::string /*client_uuid*/, ServiceWorkerClient>& clients =
it->second;
auto it2 = clients.find(client_uuid);
DCHECK(it2 != clients.end());
const ServiceWorkerClient client = it2->second;
clients.erase(it2);
if (clients.empty())
service_worker_clients_.erase(it);
// Now disconnect the client if the service worker is still running.
WorkerNodeImpl* worker_node = GetServiceWorkerNode(version_id);
if (!worker_node)
return;
switch (client.type()) {
case blink::mojom::ServiceWorkerClientType::kWindow:
DisconnectFrameClient(worker_node, client.GetRenderFrameHostId());
break;
case blink::mojom::ServiceWorkerClientType::kDedicatedWorker:
DisconnectDedicatedWorkerClient(worker_node,
client.GetDedicatedWorkerToken());
break;
case blink::mojom::ServiceWorkerClientType::kSharedWorker:
DisconnectSharedWorkerClient(worker_node, client.GetSharedWorkerToken());
break;
case blink::mojom::ServiceWorkerClientType::kAll:
NOTREACHED();
break;
}
// TODO(pmonette): Handle service worker clients.
}
void WorkerWatcher::OnControlleeNavigationCommitted(
int64_t version_id,
const std::string& client_uuid,
content::GlobalFrameRoutingId render_frame_host_id) {
size_t removed = client_frames_awaiting_commit_.erase(client_uuid);
DCHECK_EQ(removed, 1u);
bool inserted = service_worker_clients_[version_id]
.emplace(client_uuid, render_frame_host_id)
.second;
DCHECK(inserted);
WorkerNodeImpl* service_worker_node = GetServiceWorkerNode(version_id);
if (service_worker_node)
ConnectFrameClient(service_worker_node, render_frame_host_id);
// TODO(pmonette): Handle service worker clients.
}
void WorkerWatcher::ConnectFrameClient(
......
......@@ -306,7 +306,7 @@ class TestServiceWorkerContext : public content::FakeServiceWorkerContext {
// Starts an existing service worker.
void StartServiceWorker(int64_t version_id, int worker_process_id);
// Stops a service shared worker.
// Destroys a service shared worker.
void StopServiceWorker(int64_t version_id);
// Adds a new client to an existing service worker and returns its generated
......@@ -826,7 +826,10 @@ TEST_F(WorkerWatcherTest, SimpleSharedWorker) {
}
// This test creates one service worker with one client frame.
TEST_F(WorkerWatcherTest, ServiceWorkerFrameClient) {
//
// TODO(pmonette): Enable this test when the WorkerWatcher starts tracking
// service worker clients.
TEST_F(WorkerWatcherTest, DISABLED_ServiceWorkerFrameClient) {
int render_process_id = process_node_source()->CreateProcessNode();
// Create and start the service worker.
......@@ -874,6 +877,8 @@ TEST_F(WorkerWatcherTest, ServiceWorkerFrameClient) {
EXPECT_TRUE(graph->NodeInGraph(worker_node));
EXPECT_EQ(worker_node->worker_type(), WorkerNode::WorkerType::kService);
EXPECT_EQ(worker_node->process_node(), process_node);
// Now is it correctly hooked up.
EXPECT_TRUE(IsWorkerClient(worker_node, client_frame_node));
}));
......@@ -922,7 +927,9 @@ TEST_F(WorkerWatcherTest, ServiceWorkerFrameClientDestroyedBeforeCommit) {
service_worker_context()->DestroyServiceWorker(service_worker_version_id);
}
TEST_F(WorkerWatcherTest, AllTypesOfServiceWorkerClients) {
// TODO(pmonette): Enable this test when the WorkerWatcher starts tracking
// service worker clients.
TEST_F(WorkerWatcherTest, DISABLED_AllTypesOfServiceWorkerClients) {
int render_process_id = process_node_source()->CreateProcessNode();
// Create and start the service worker.
......@@ -994,7 +1001,11 @@ TEST_F(WorkerWatcherTest, AllTypesOfServiceWorkerClients) {
// starts after it has been assigned a client. In this case, the clients are not
// connected to the service worker until it starts. It also tests that when the
// service worker stops, its existing clients are also disconnected.
TEST_F(WorkerWatcherTest, ServiceWorkerStartsAndStopsWithExistingClients) {
//
// TODO(pmonette): Enable this test when the WorkerWatcher starts tracking
// service worker clients.
TEST_F(WorkerWatcherTest,
DISABLED_ServiceWorkerStartsAndStopsWithExistingClients) {
int render_process_id = process_node_source()->CreateProcessNode();
// Create the worker.
......@@ -1297,7 +1308,9 @@ TEST_F(WorkerWatcherTest, FrameDestroyed) {
EXPECT_TRUE(graph->NodeInGraph(service_worker_node));
EXPECT_TRUE(IsWorkerClient(dedicated_worker_node, client_frame_node));
EXPECT_TRUE(IsWorkerClient(shared_worker_node, client_frame_node));
EXPECT_TRUE(IsWorkerClient(service_worker_node, client_frame_node));
// TODO(pmonette): Change this to EXPECT_TRUE() when the WorkerWatcher
// starts tracking service worker clients.
EXPECT_FALSE(IsWorkerClient(service_worker_node, client_frame_node));
}));
frame_node_source()->DeleteFrameNode(render_frame_host_id);
......
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