Commit 8400e57d authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

Use ServiceWorkerStorageControl::GetNewRegistrationId()

This CL replaces ServiceWorkerStorage::GetNewRegistrationId() call
with the corresponding mojo method as a preparation for the Storage
Service migration.

This CL increases the android binary sizes by ~30kb. Most of the
increase (~29kb) comes from mojo generated code and there isn't much we
can do to reduce them. Introducing the mojo interface is necessary for
migrating ServiceWorkerStroage to the storage service. See the design
doc [1] for the motivation of the migration and plans.

[1] https://docs.google.com/document/d/1hO0WEuoEOgEBlf5nDE3fDjuQY2bV_d5hLtk25iBo0LM/edit?usp=sharing

Bug: 1055677
Binary-Size: Size increase is unavoidable (see above)
Change-Id: I33e1e72b1da94ae02dfbe2a929895fc36e216e66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217935
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774947}
parent e04159cc
...@@ -154,7 +154,8 @@ void ServiceWorkerRegistry::CreateNewRegistration( ...@@ -154,7 +154,8 @@ void ServiceWorkerRegistry::CreateNewRegistration(
blink::mojom::ServiceWorkerRegistrationOptions options, blink::mojom::ServiceWorkerRegistrationOptions options,
NewRegistrationCallback callback) { NewRegistrationCallback callback) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
storage()->GetNewRegistrationId(base::BindOnce( BindRemoteStorageControlIfNeeded();
remote_storage_control_->GetNewRegistrationId(base::BindOnce(
&ServiceWorkerRegistry::DidGetNewRegistrationId, &ServiceWorkerRegistry::DidGetNewRegistrationId,
weak_factory_.GetWeakPtr(), std::move(options), std::move(callback))); weak_factory_.GetWeakPtr(), std::move(options), std::move(callback)));
} }
...@@ -1383,4 +1384,15 @@ bool ServiceWorkerRegistry::ShouldPurgeOnShutdown(const url::Origin& origin) { ...@@ -1383,4 +1384,15 @@ bool ServiceWorkerRegistry::ShouldPurgeOnShutdown(const url::Origin& origin) {
!special_storage_policy_->IsStorageProtected(origin.GetURL()); !special_storage_policy_->IsStorageProtected(origin.GetURL());
} }
void ServiceWorkerRegistry::BindRemoteStorageControlIfNeeded() {
DCHECK(!(remote_storage_control_.is_bound() &&
!remote_storage_control_.is_connected()))
<< "Rebinding is not supported yet.";
if (remote_storage_control_.is_bound())
return;
storage_control_->Bind(remote_storage_control_.BindNewPipeAndPassReceiver());
}
} // namespace content } // namespace content
...@@ -349,6 +349,8 @@ class CONTENT_EXPORT ServiceWorkerRegistry { ...@@ -349,6 +349,8 @@ class CONTENT_EXPORT ServiceWorkerRegistry {
void OnStoragePolicyChanged(); void OnStoragePolicyChanged();
bool ShouldPurgeOnShutdown(const url::Origin& origin); bool ShouldPurgeOnShutdown(const url::Origin& origin);
void BindRemoteStorageControlIfNeeded();
// The ServiceWorkerContextCore object must outlive this. // The ServiceWorkerContextCore object must outlive this.
ServiceWorkerContextCore* const context_; ServiceWorkerContextCore* const context_;
......
...@@ -413,7 +413,17 @@ scoped_refptr<ServiceWorkerRegistration> CreateNewServiceWorkerRegistration( ...@@ -413,7 +413,17 @@ scoped_refptr<ServiceWorkerRegistration> CreateNewServiceWorkerRegistration(
ServiceWorkerRegistry* registry, ServiceWorkerRegistry* registry,
const blink::mojom::ServiceWorkerRegistrationOptions& options) { const blink::mojom::ServiceWorkerRegistrationOptions& options) {
scoped_refptr<ServiceWorkerRegistration> registration; scoped_refptr<ServiceWorkerRegistration> registration;
base::RunLoop run_loop; // Using nestable run loop because:
// * The CreateNewRegistration() internally uses a mojo remote and the
// receiver of the remote lives in the same process/sequence in tests.
// * When the receiver lives in the same process a nested task is posted so
// that a sent mojo message to be dispatched to the receiver.
// * Default run loop doesn't execute nested tasks. Tests will hang when
// default run loop is used.
// TODO(bashi): Figure out a way to avoid using nested loop as it's
// problematic especially on the IO thread. This function is called on the IO
// thread when ServiceWorkerOnUI is disabled.
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
registry->CreateNewRegistration( registry->CreateNewRegistration(
options, options,
base::BindLambdaForTesting( base::BindLambdaForTesting(
......
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