Replace origin with storage key in ServiceWorkerVersionBaseInfo
This change replaces origin with storage key in the
ServiceWorkerVersionBaseInfo. The storage key is used for partitioning
storage (and, in particular, service workers). So service workers are
better identified throguh storage key than origin. Having storage key
on the ServiceWorkerVersionBaseInfo allows passing it through to the
BackgroundFetchServiceImpl.
Bug: 1199077
Change-Id: I7c442ad6249782c17a8c9776260d7acee37e0b8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2980775
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Antonio Sartori <antoniosartori@chromium.org>
Cr-Commit-Position: refs/heads/master@{#895493}
diff --git a/content/browser/background_fetch/background_fetch_service_impl.cc b/content/browser/background_fetch/background_fetch_service_impl.cc
index 7919620..0404f37 100644
--- a/content/browser/background_fetch/background_fetch_service_impl.cc
+++ b/content/browser/background_fetch/background_fetch_service_impl.cc
@@ -52,9 +52,7 @@
WrapRefCounted(static_cast<StoragePartitionImpl*>(
render_process_host->GetStoragePartition())
->GetBackgroundFetchContext()),
- // TODO(https://crbug.com/1199077): Pass directly the worker's
- // StorageKey when we will have it.
- blink::StorageKey(info.origin),
+ info.storage_key,
/* render_frame_tree_node_id= */ 0,
/* wc_getter= */ base::NullCallback(), std::move(receiver)));
}
diff --git a/content/browser/browser_interface_binders.cc b/content/browser/browser_interface_binders.cc
index c166643..81d9420 100644
--- a/content/browser/browser_interface_binders.cc
+++ b/content/browser/browser_interface_binders.cc
@@ -477,7 +477,7 @@
const url::Origin&, mojo::PendingReceiver<Interface>),
const ServiceWorkerVersionBaseInfo& info,
mojo::PendingReceiver<Interface> receiver) {
- auto origin = info.origin;
+ auto origin = info.storage_key.origin();
RunOrPostTaskToBindServiceWorkerReceiver<
const url::Origin&, mojo::PendingReceiver<Interface>>(
host, method, origin, std::move(receiver));
@@ -499,7 +499,7 @@
int, const url::Origin&, mojo::PendingReceiver<Interface>),
const ServiceWorkerVersionBaseInfo& info,
mojo::PendingReceiver<Interface> receiver) {
- auto origin = info.origin;
+ auto origin = info.storage_key.origin();
RunOrPostTaskToBindServiceWorkerReceiver<
int, const url::Origin&, mojo::PendingReceiver<Interface>>(
host, method, MSG_ROUTING_NONE, origin, std::move(receiver));
diff --git a/content/browser/content_index/content_index_service_impl.cc b/content/browser/content_index/content_index_service_impl.cc
index 9108c122..3063dfe 100644
--- a/content/browser/content_index/content_index_service_impl.cc
+++ b/content/browser/content_index/content_index_service_impl.cc
@@ -71,11 +71,11 @@
auto* storage_partition = static_cast<StoragePartitionImpl*>(
render_process_host->GetStoragePartition());
- mojo::MakeSelfOwnedReceiver(
- std::make_unique<ContentIndexServiceImpl>(
- info.origin, storage_partition->GetContentIndexContext(),
- storage_partition->GetServiceWorkerContext()),
- std::move(receiver));
+ mojo::MakeSelfOwnedReceiver(std::make_unique<ContentIndexServiceImpl>(
+ info.storage_key.origin(),
+ storage_partition->GetContentIndexContext(),
+ storage_partition->GetServiceWorkerContext()),
+ std::move(receiver));
}
ContentIndexServiceImpl::ContentIndexServiceImpl(
diff --git a/content/browser/cookie_store/cookie_store_context.cc b/content/browser/cookie_store/cookie_store_context.cc
index 94d0d39..f0035e7e 100644
--- a/content/browser/cookie_store/cookie_store_context.cc
+++ b/content/browser/cookie_store/cookie_store_context.cc
@@ -98,7 +98,7 @@
StoragePartitionImpl* storage_partition = static_cast<StoragePartitionImpl*>(
render_process_host->GetStoragePartition());
storage_partition->GetCookieStoreContext()->CreateServiceForTesting(
- info.origin, std::move(receiver));
+ info.storage_key.origin(), std::move(receiver));
}
void CookieStoreContext::CreateServiceForTesting(
diff --git a/content/browser/service_worker/service_worker_identifiability_metrics.cc b/content/browser/service_worker/service_worker_identifiability_metrics.cc
index 3b760723..782464a 100644
--- a/content/browser/service_worker/service_worker_identifiability_metrics.cc
+++ b/content/browser/service_worker/service_worker_identifiability_metrics.cc
@@ -24,11 +24,12 @@
auto version_it = version_map_.find(version_id);
if (version_it != version_map_.end()) {
DCHECK_EQ(version_it->second.ukm_source_id, version_info.ukm_source_id);
- DCHECK_EQ(version_it->second.origin, version_info.origin.GetURL());
+ DCHECK_EQ(version_it->second.origin,
+ version_info.storage_key.origin().GetURL());
return;
}
- GURL origin = version_info.origin.GetURL();
+ GURL origin = version_info.storage_key.origin().GetURL();
version_map_.emplace(version_id, VersionIdentifiabilityInfo(
version_info.ukm_source_id, origin));
diff --git a/content/browser/service_worker/service_worker_info.cc b/content/browser/service_worker/service_worker_info.cc
index 6b2d77f..90f2241a9 100644
--- a/content/browser/service_worker/service_worker_info.cc
+++ b/content/browser/service_worker/service_worker_info.cc
@@ -28,7 +28,7 @@
ServiceWorkerVersion::FetchHandlerExistence fetch_handler_existence,
const GURL& script_url,
const GURL& scope,
- const url::Origin& origin,
+ const blink::StorageKey& storage_key,
int64_t registration_id,
int64_t version_id,
int process_id,
@@ -36,7 +36,7 @@
int devtools_agent_route_id,
ukm::SourceId ukm_source_id)
: ServiceWorkerVersionBaseInfo(scope,
- origin,
+ storage_key,
registration_id,
version_id,
process_id),
diff --git a/content/browser/service_worker/service_worker_info.h b/content/browser/service_worker/service_worker_info.h
index c2fee64..9744f8c 100644
--- a/content/browser/service_worker/service_worker_info.h
+++ b/content/browser/service_worker/service_worker_info.h
@@ -18,7 +18,10 @@
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_container_type.mojom.h"
#include "url/gurl.h"
-#include "url/origin.h"
+
+namespace blink {
+class StorageKey;
+} // namespace blink
namespace content {
@@ -35,7 +38,7 @@
ServiceWorkerVersion::FetchHandlerExistence fetch_handler_existence,
const GURL& script_url,
const GURL& scope,
- const url::Origin& origin,
+ const blink::StorageKey& storage_key,
int64_t registration_id,
int64_t version_id,
int process_id,
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc
index fb400e2..2f52b96 100644
--- a/content/browser/service_worker/service_worker_version.cc
+++ b/content/browser/service_worker/service_worker_version.cc
@@ -385,7 +385,7 @@
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
ServiceWorkerVersionInfo info(
running_status(), status(), fetch_handler_existence(), script_url(),
- scope(), key().origin(), registration_id(), version_id(),
+ scope(), key(), registration_id(), version_id(),
embedded_worker()->process_id(), embedded_worker()->thread_id(),
embedded_worker()->worker_devtools_agent_route_id(), ukm_source_id());
for (const auto& controllee : controllee_map_) {
diff --git a/content/public/browser/service_worker_version_base_info.h b/content/public/browser/service_worker_version_base_info.h
index 400beea..adae910 100644
--- a/content/public/browser/service_worker_version_base_info.h
+++ b/content/public/browser/service_worker_version_base_info.h
@@ -7,9 +7,9 @@
#include "content/common/content_export.h"
#include "content/public/common/child_process_host.h"
+#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_database.mojom-forward.h"
#include "url/gurl.h"
-#include "url/origin.h"
namespace content {
@@ -18,19 +18,19 @@
public:
ServiceWorkerVersionBaseInfo() = default;
ServiceWorkerVersionBaseInfo(const GURL& scope,
- const url::Origin& origin,
+ const blink::StorageKey& storage_key,
int64_t registration_id,
int64_t version_id,
int process_id)
: scope(scope),
- origin(origin),
+ storage_key(storage_key),
registration_id(registration_id),
version_id(version_id),
process_id(process_id) {}
virtual ~ServiceWorkerVersionBaseInfo() = default;
GURL scope;
- url::Origin origin;
+ blink::StorageKey storage_key;
int64_t registration_id = blink::mojom::kInvalidServiceWorkerRegistrationId;
int64_t version_id = blink::mojom::kInvalidServiceWorkerVersionId;
int process_id = ChildProcessHost::kInvalidUniqueID;