Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into master.lion
Browse files Browse the repository at this point in the history
  • Loading branch information
blueboxd committed Feb 8, 2023
2 parents 7f8feaa + a56ce4e commit 93f88a5
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling feed
# and whatever else without interference from each other.
'dawn_revision': '136ec1e3b4bf83a1532f9c326c82417b66d54b8f',
'dawn_revision': '5b50790d707908a3deb2afec01651a4fc80b28b5',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling feed
# and whatever else without interference from each other.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,10 @@ void ServiceWorkerStorage::FindForClientUrlInDB(
auto resources = std::make_unique<ResourceList>();
status = ServiceWorkerDatabase::Status::kErrorNotFound;

base::UmaHistogramCounts1000(
"ServiceWorker.Storage.FindForClientUrlInDB.ScopeCountForStorageKey",
registration_data_list.size());

// Find one with a scope match.
blink::ServiceWorkerLongestScopeMatcher matcher(client_url);
int64_t match = blink::mojom::kInvalidServiceWorkerRegistrationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void ServiceWorkerContainerHost::GetRegistration(
GetCorrectStorageKeyForWebSecurityState(client_url);

context_->registry()->FindRegistrationForClientUrl(
client_url, key,
ServiceWorkerRegistry::Purpose::kNotForNavigation, client_url, key,
base::BindOnce(&ServiceWorkerContainerHost::GetRegistrationComplete,
weak_factory_.GetWeakPtr(), std::move(callback),
trace_id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ void ServiceWorkerContextCore::CheckHasServiceWorker(
const blink::StorageKey& key,
ServiceWorkerContext::CheckHasServiceWorkerCallback callback) {
registry()->FindRegistrationForClientUrl(
url, key,
ServiceWorkerRegistry::Purpose::kNotForNavigation, url, key,
base::BindOnce(&ServiceWorkerContextCore::
DidFindRegistrationForCheckHasServiceWorker,
AsWeakPtr(), std::move(callback)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ void ServiceWorkerContextWrapper::StartServiceWorkerForNavigationHint(
}

context_core_->registry()->FindRegistrationForClientUrl(
ServiceWorkerRegistry::Purpose::kNotForNavigation,
net::SimplifyUrlForRequest(document_url), key,
base::BindOnce(
&ServiceWorkerContextWrapper::DidFindRegistrationForNavigationHint,
Expand Down Expand Up @@ -986,6 +987,7 @@ void ServiceWorkerContextWrapper::FindReadyRegistrationForClientUrl(
return;
}
context_core_->registry()->FindRegistrationForClientUrl(
ServiceWorkerRegistry::Purpose::kNotForNavigation,
net::SimplifyUrlForRequest(client_url), key,
base::BindOnce(
&ServiceWorkerContextWrapper::DidFindRegistrationForFindImpl, this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void ServiceWorkerControlleeRequestHandler::MaybeCreateLoader(

// Look up a registration.
context_->registry()->FindRegistrationForClientUrl(
stripped_url_, storage_key_,
ServiceWorkerRegistry::Purpose::kNavigation, stripped_url_, storage_key_,
base::BindOnce(
&ServiceWorkerControlleeRequestHandler::ContinueWithRegistration,
weak_factory_.GetWeakPtr(), /*is_for_navigation=*/true,
Expand Down Expand Up @@ -648,11 +648,12 @@ void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration(
// Update failed. Look up the registration again since the original
// registration was possibly unregistered in the meantime.
context_->registry()->FindRegistrationForClientUrl(
stripped_url_, storage_key_,
ServiceWorkerRegistry::Purpose::kNotForNavigation, stripped_url_,
storage_key_,
base::BindOnce(
&ServiceWorkerControlleeRequestHandler::ContinueWithRegistration,
weak_factory_.GetWeakPtr(), /*is_for_navigation=*/false,
base::TimeTicks()));
weak_factory_.GetWeakPtr(),
/*is_for_navigation=*/false, base::TimeTicks()));
TRACE_EVENT_WITH_FLOW1(
"ServiceWorker",
"ServiceWorkerControlleeRequestHandler::DidUpdateRegistration",
Expand Down Expand Up @@ -705,11 +706,12 @@ void ServiceWorkerControlleeRequestHandler::OnUpdatedVersionStatusChanged(
// continue with the incumbent version.
// In case unregister job may have run, look up the registration again.
context_->registry()->FindRegistrationForClientUrl(
stripped_url_, storage_key_,
ServiceWorkerRegistry::Purpose::kNotForNavigation, stripped_url_,
storage_key_,
base::BindOnce(
&ServiceWorkerControlleeRequestHandler::ContinueWithRegistration,
weak_factory_.GetWeakPtr(), /*is_for_navigation=*/false,
base::TimeTicks()));
weak_factory_.GetWeakPtr(),
/*is_for_navigation=*/false, base::TimeTicks()));
return;
}
version->RegisterStatusChangeCallback(base::BindOnce(
Expand Down
10 changes: 6 additions & 4 deletions content/browser/service_worker/service_worker_job_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,12 @@ TEST_F(ServiceWorkerJobTest, SameDocumentSameRegistration) {
base::RepeatingClosure barrier_closure =
base::BarrierClosure(2, run_loop.QuitClosure());
registry()->FindRegistrationForClientUrl(
url, key,
ServiceWorkerRegistry::Purpose::kNotForNavigation, url, key,
SaveFoundRegistration(blink::ServiceWorkerStatusCode::kOk, &registration1,
barrier_closure));
scoped_refptr<ServiceWorkerRegistration> registration2;
registry()->FindRegistrationForClientUrl(
url, key,
ServiceWorkerRegistry::Purpose::kNotForNavigation, url, key,
SaveFoundRegistration(blink::ServiceWorkerStatusCode::kOk, &registration2,
barrier_closure));
run_loop.Run();
Expand All @@ -368,12 +368,14 @@ TEST_F(ServiceWorkerJobTest, SameMatchSameRegistration) {
base::RepeatingClosure barrier_closure =
base::BarrierClosure(2, run_loop.QuitClosure());
registry()->FindRegistrationForClientUrl(
ServiceWorkerRegistry::Purpose::kNotForNavigation,
GURL("https://www.example.com/one"), key,
SaveFoundRegistration(blink::ServiceWorkerStatusCode::kOk, &registration1,
barrier_closure));

scoped_refptr<ServiceWorkerRegistration> registration2;
registry()->FindRegistrationForClientUrl(
ServiceWorkerRegistry::Purpose::kNotForNavigation,
GURL("https://www.example.com/two"), key,
SaveFoundRegistration(blink::ServiceWorkerStatusCode::kOk, &registration2,
barrier_closure));
Expand All @@ -400,12 +402,12 @@ TEST_F(ServiceWorkerJobTest, DifferentMatchDifferentRegistration) {
base::RepeatingClosure barrier_closure =
base::BarrierClosure(2, run_loop.QuitClosure());
registry()->FindRegistrationForClientUrl(
scope1, key,
ServiceWorkerRegistry::Purpose::kNotForNavigation, scope1, key,
SaveFoundRegistration(blink::ServiceWorkerStatusCode::kOk, &registration1,
barrier_closure));
scoped_refptr<ServiceWorkerRegistration> registration2;
registry()->FindRegistrationForClientUrl(
scope2, key,
ServiceWorkerRegistry::Purpose::kNotForNavigation, scope2, key,
SaveFoundRegistration(blink::ServiceWorkerStatusCode::kOk, &registration2,
barrier_closure));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ServiceWorkerOfflineCapabilityChecker::Start(
ServiceWorkerContext::CheckOfflineCapabilityCallback callback) {
callback_ = std::move(callback);
registry->FindRegistrationForClientUrl(
url_, key_,
ServiceWorkerRegistry::Purpose::kNotForNavigation, url_, key_,
base::BindOnce(
&ServiceWorkerOfflineCapabilityChecker::DidFindRegistration,
// We can use base::Unretained(this) because |this| is expected
Expand Down
10 changes: 10 additions & 0 deletions content/browser/service_worker/service_worker_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ void ServiceWorkerRegistry::CreateNewVersion(
}

void ServiceWorkerRegistry::FindRegistrationForClientUrl(
Purpose purpose,
const GURL& client_url,
const blink::StorageKey& key,
FindRegistrationCallback callback) {
Expand All @@ -265,6 +266,15 @@ void ServiceWorkerRegistry::FindRegistrationForClientUrl(
return blink::ServiceWorkerScopeMatches(scope, client_url);
});
}
if (purpose == Purpose::kNavigation) {
base::UmaHistogramBoolean(
"ServiceWorker.FindRegistrationForClientUrl.SkippedMojoCall."
"OnNavigation",
no_registration);
}
base::UmaHistogramBoolean(
"ServiceWorker.FindRegistrationForClientUrl.IsCalledForNavigation",
purpose == Purpose::kNavigation);
// To connect this TRACE_EVENT with the callback, Time::Now() is used as a
// trace event id.
int64_t trace_event_id =
Expand Down
5 changes: 4 additions & 1 deletion content/browser/service_worker/service_worker_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class CONTENT_EXPORT ServiceWorkerRegistry {
using StatusCallback =
base::OnceCallback<void(blink::ServiceWorkerStatusCode status)>;

enum class Purpose { kNotForNavigation, kNavigation };

ServiceWorkerRegistry(ServiceWorkerContextCore* context,
storage::QuotaManagerProxy* quota_manager_proxy,
storage::SpecialStoragePolicy* special_storage_policy);
Expand Down Expand Up @@ -135,7 +137,8 @@ class CONTENT_EXPORT ServiceWorkerRegistry {
// for `client_url` or `registration_id` may complete immediately
// (the callback may be called prior to the method returning) or
// asynchronously.
void FindRegistrationForClientUrl(const GURL& client_url,
void FindRegistrationForClientUrl(Purpose purpose,
const GURL& client_url,
const blink::StorageKey& key,
FindRegistrationCallback callback);
void FindRegistrationForScope(const GURL& scope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class ServiceWorkerRegistryTest : public testing::Test {
blink::ServiceWorkerStatusCode result;
base::RunLoop loop;
registry()->FindRegistrationForClientUrl(
document_url, key,
ServiceWorkerRegistry::Purpose::kNotForNavigation, document_url, key,
base::BindLambdaForTesting(
[&](blink::ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> registration) {
Expand Down Expand Up @@ -1176,7 +1176,7 @@ TEST_P(ServiceWorkerRegistryMergeTest, MergeDuplicateFindRegistrationCalls) {
base::RunLoop loop;
for (int i = 0; i < kCallCount; i++) {
registry()->FindRegistrationForClientUrl(
kScope, kKey,
ServiceWorkerRegistry::Purpose::kNotForNavigation, kScope, kKey,
base::BindLambdaForTesting(
[&](blink::ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> found_registration) {
Expand Down Expand Up @@ -1232,7 +1232,8 @@ class ServiceWorkerScopeCacheTest : public ServiceWorkerRegistryTest {
int expected_registration_scope_cache_size) {
base::RunLoop loop;
registry()->FindRegistrationForClientUrl(
scope, blink::StorageKey(url::Origin::Create(scope)),
ServiceWorkerRegistry::Purpose::kNotForNavigation, scope,
blink::StorageKey(url::Origin::Create(scope)),
base::BindLambdaForTesting(
[&](blink::ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> found_registration) {
Expand Down Expand Up @@ -1848,7 +1849,7 @@ TEST_F(ServiceWorkerRegistryTest, RetryInflightCalls) {
{
base::RunLoop loop1;
registry()->FindRegistrationForClientUrl(
kScope1, kKey1,
ServiceWorkerRegistry::Purpose::kNotForNavigation, kScope1, kKey1,
base::BindLambdaForTesting(
[&](blink::ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> found_registration) {
Expand Down
34 changes: 34 additions & 0 deletions tools/metrics/histograms/metadata/service/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,29 @@ [email protected].
</summary>
</histogram>

<histogram
name="ServiceWorker.FindRegistrationForClientUrl.IsCalledForNavigation"
enum="Boolean" expires_after="2023-12-01">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Whether FindRegistrationForClientUrl() is called for navigation or not. This
is recorded when FindRegistrationForClientUrl() function is called.
</summary>
</histogram>

<histogram
name="ServiceWorker.FindRegistrationForClientUrl.SkippedMojoCall.OnNavigation"
enum="BooleanSkipped" expires_after="2023-12-01">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Whether FindRegistrationForClientUrl() could skip calling mojo API by using
scope cache. This is recorded only when FindRegistrationForClientUrl() is
used for navigation.
</summary>
</histogram>

<histogram name="ServiceWorker.FindRegistrationForClientUrl.Time" units="ms"
expires_after="2023-10-01">
<owner>[email protected]</owner>
Expand Down Expand Up @@ -1180,6 +1203,17 @@ [email protected].
</summary>
</histogram>

<histogram
name="ServiceWorker.Storage.FindForClientUrlInDB.ScopeCountForStorageKey"
units="count" expires_after="2023-12-01">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
The scope count for a given StorageKey. This is recorded when
ServiceWorkerStorage::FindForClientUrlInDB() function is called.
</summary>
</histogram>

<histogram name="ServiceWorker.Storage.FindForClientUrlInDB.Time" units="ms"
expires_after="2023-10-01">
<owner>[email protected]</owner>
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/core/perfetto_binary_roller/binary_deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"full_remote_path": "perfetto-luci-artifacts/3b59f000c939bfe4d05267fd68d282ef0b541334/linux-arm64/trace_processor_shell"
},
"win": {
"hash": "279cb4434608ad7521c7c8fa3de43b16e76de906",
"full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/win/79b41912cc8ddd06371716134ce6a97164389057/trace_processor_shell.exe"
"hash": "3bc30c6747aa0fefd2dad9c006415bbc322e7065",
"full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/win/656582b37c3b7214e3b20aba8fd74d41b35a7160/trace_processor_shell.exe"
},
"linux_arm": {
"hash": "e945a99da7a66211f847b8049627bbec846d2d1d",
Expand Down

0 comments on commit 93f88a5

Please sign in to comment.