Commit 037854c8 authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

AppCache: Rename AppCacheQuotaClient methods to clarify lifecycle.

This CL renames two AppCacheQuotaClient methods, NotifyAppCacheReady ->
NotifyStorageReady, and NotifyAppCacheDestroyed ->
NotifyServiceDestroyed, to clarify when the methods will get called.

This CL does not introduce any functional changes.

Bug: 1016065
Change-Id: I52238c731bcf805212d24bf744519adaf7a78374
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514666
Auto-Submit: Victor Costan <pwnall@chromium.org>
Commit-Queue: enne <enne@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823328}
parent a1067992
...@@ -251,7 +251,7 @@ AppCacheQuotaClient::GetServiceDeleteCallback() { ...@@ -251,7 +251,7 @@ AppCacheQuotaClient::GetServiceDeleteCallback() {
return service_delete_callback_.get(); return service_delete_callback_.get();
} }
void AppCacheQuotaClient::NotifyAppCacheReady() { void AppCacheQuotaClient::NotifyStorageReady() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Can reoccur during reinitialization. // Can reoccur during reinitialization.
...@@ -261,7 +261,7 @@ void AppCacheQuotaClient::NotifyAppCacheReady() { ...@@ -261,7 +261,7 @@ void AppCacheQuotaClient::NotifyAppCacheReady() {
} }
} }
void AppCacheQuotaClient::NotifyAppCacheDestroyed() { void AppCacheQuotaClient::NotifyServiceDestroyed() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
service_ = nullptr; service_ = nullptr;
......
...@@ -57,8 +57,8 @@ class AppCacheQuotaClient : public storage::QuotaClient { ...@@ -57,8 +57,8 @@ class AppCacheQuotaClient : public storage::QuotaClient {
private: private:
friend class content::AppCacheQuotaClientTest; friend class content::AppCacheQuotaClientTest;
friend class AppCacheServiceImpl; // for NotifyAppCacheIsDestroyed friend class AppCacheServiceImpl; // for NotifyServiceDestroyed
friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady friend class AppCacheStorageImpl; // for NotifyStorageReady
~AppCacheQuotaClient() override; ~AppCacheQuotaClient() override;
...@@ -70,8 +70,15 @@ class AppCacheQuotaClient : public storage::QuotaClient { ...@@ -70,8 +70,15 @@ class AppCacheQuotaClient : public storage::QuotaClient {
net::CancelableCompletionRepeatingCallback* GetServiceDeleteCallback(); net::CancelableCompletionRepeatingCallback* GetServiceDeleteCallback();
// For use by appcache internals during initialization and shutdown. // For use by appcache internals during initialization and shutdown.
CONTENT_EXPORT void NotifyAppCacheReady();
CONTENT_EXPORT void NotifyAppCacheDestroyed(); // Called when the AppCacheStorageImpl's storage is fully initialized.
//
// After this point, calling AppCacheServiceImpl::storage() is guaranteed to
// return a non-null value.
CONTENT_EXPORT void NotifyStorageReady();
// Called when the AppCacheServiceImpl passed to the constructor is destroyed.
CONTENT_EXPORT void NotifyServiceDestroyed();
// Prior to appcache service being ready, we have to queue // Prior to appcache service being ready, we have to queue
// up requests and defer acting on them until we're ready. // up requests and defer acting on them until we're ready.
......
...@@ -126,12 +126,12 @@ class AppCacheQuotaClientTest : public testing::Test { ...@@ -126,12 +126,12 @@ class AppCacheQuotaClientTest : public testing::Test {
return base::MakeRefCounted<AppCacheQuotaClient>(mock_service_.AsWeakPtr()); return base::MakeRefCounted<AppCacheQuotaClient>(mock_service_.AsWeakPtr());
} }
void Call_NotifyAppCacheReady(AppCacheQuotaClient& client) { void Call_NotifyStorageReady(AppCacheQuotaClient& client) {
client.NotifyAppCacheReady(); client.NotifyStorageReady();
} }
void Call_NotifyAppCacheDestroyed(AppCacheQuotaClient& client) { void Call_NotifyServiceDestroyed(AppCacheQuotaClient& client) {
client.NotifyAppCacheDestroyed(); client.NotifyServiceDestroyed();
} }
void Call_OnQuotaManagerDestroyed(AppCacheQuotaClient& client) { void Call_OnQuotaManagerDestroyed(AppCacheQuotaClient& client) {
...@@ -167,14 +167,14 @@ class AppCacheQuotaClientTest : public testing::Test { ...@@ -167,14 +167,14 @@ class AppCacheQuotaClientTest : public testing::Test {
TEST_F(AppCacheQuotaClientTest, BasicCreateDestroy) { TEST_F(AppCacheQuotaClientTest, BasicCreateDestroy) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
Call_OnQuotaManagerDestroyed(*client); Call_OnQuotaManagerDestroyed(*client);
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
} }
TEST_F(AppCacheQuotaClientTest, QuotaManagerDestroyedInCallback) { TEST_F(AppCacheQuotaClientTest, QuotaManagerDestroyedInCallback) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
client->DeleteOriginData(kOriginA, kTemp, client->DeleteOriginData(kOriginA, kTemp,
base::BindOnce( base::BindOnce(
[](AppCacheQuotaClientTest* test, [](AppCacheQuotaClientTest* test,
...@@ -183,12 +183,12 @@ TEST_F(AppCacheQuotaClientTest, QuotaManagerDestroyedInCallback) { ...@@ -183,12 +183,12 @@ TEST_F(AppCacheQuotaClientTest, QuotaManagerDestroyedInCallback) {
test->Call_OnQuotaManagerDestroyed(*client); test->Call_OnQuotaManagerDestroyed(*client);
}, },
this, client)); this, client));
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
} }
TEST_F(AppCacheQuotaClientTest, EmptyService) { TEST_F(AppCacheQuotaClientTest, EmptyService) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
EXPECT_EQ(0, GetOriginUsage(*client, kOriginA, kTemp)); EXPECT_EQ(0, GetOriginUsage(*client, kOriginA, kTemp));
EXPECT_TRUE(GetOriginsForType(*client, kTemp).empty()); EXPECT_TRUE(GetOriginsForType(*client, kTemp).empty());
...@@ -196,14 +196,14 @@ TEST_F(AppCacheQuotaClientTest, EmptyService) { ...@@ -196,14 +196,14 @@ TEST_F(AppCacheQuotaClientTest, EmptyService) {
EXPECT_EQ(blink::mojom::QuotaStatusCode::kOk, EXPECT_EQ(blink::mojom::QuotaStatusCode::kOk,
DeleteOriginData(*client, kTemp, kOriginA)); DeleteOriginData(*client, kTemp, kOriginA));
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
Call_OnQuotaManagerDestroyed(*client); Call_OnQuotaManagerDestroyed(*client);
} }
TEST_F(AppCacheQuotaClientTest, NoService) { TEST_F(AppCacheQuotaClientTest, NoService) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
EXPECT_EQ(0, GetOriginUsage(*client, kOriginA, kTemp)); EXPECT_EQ(0, GetOriginUsage(*client, kOriginA, kTemp));
EXPECT_TRUE(GetOriginsForType(*client, kTemp).empty()); EXPECT_TRUE(GetOriginsForType(*client, kTemp).empty());
...@@ -216,19 +216,19 @@ TEST_F(AppCacheQuotaClientTest, NoService) { ...@@ -216,19 +216,19 @@ TEST_F(AppCacheQuotaClientTest, NoService) {
TEST_F(AppCacheQuotaClientTest, GetOriginUsage) { TEST_F(AppCacheQuotaClientTest, GetOriginUsage) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
SetUsageMapEntry(kOriginA, 1000); SetUsageMapEntry(kOriginA, 1000);
EXPECT_EQ(1000, GetOriginUsage(*client, kOriginA, kTemp)); EXPECT_EQ(1000, GetOriginUsage(*client, kOriginA, kTemp));
EXPECT_EQ(0, GetOriginUsage(*client, kOriginB, kTemp)); EXPECT_EQ(0, GetOriginUsage(*client, kOriginB, kTemp));
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
Call_OnQuotaManagerDestroyed(*client); Call_OnQuotaManagerDestroyed(*client);
} }
TEST_F(AppCacheQuotaClientTest, GetOriginsForHost) { TEST_F(AppCacheQuotaClientTest, GetOriginsForHost) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
EXPECT_EQ(kOriginA.host(), kOriginB.host()); EXPECT_EQ(kOriginA.host(), kOriginB.host());
EXPECT_NE(kOriginA.host(), kOriginOther.host()); EXPECT_NE(kOriginA.host(), kOriginOther.host());
...@@ -250,13 +250,13 @@ TEST_F(AppCacheQuotaClientTest, GetOriginsForHost) { ...@@ -250,13 +250,13 @@ TEST_F(AppCacheQuotaClientTest, GetOriginsForHost) {
EXPECT_EQ(1ul, origins.size()); EXPECT_EQ(1ul, origins.size());
EXPECT_THAT(origins, testing::Contains(kOriginOther)); EXPECT_THAT(origins, testing::Contains(kOriginOther));
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
Call_OnQuotaManagerDestroyed(*client); Call_OnQuotaManagerDestroyed(*client);
} }
TEST_F(AppCacheQuotaClientTest, GetOriginsForType) { TEST_F(AppCacheQuotaClientTest, GetOriginsForType) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
EXPECT_TRUE(GetOriginsForType(*client, kTemp).empty()); EXPECT_TRUE(GetOriginsForType(*client, kTemp).empty());
...@@ -268,13 +268,13 @@ TEST_F(AppCacheQuotaClientTest, GetOriginsForType) { ...@@ -268,13 +268,13 @@ TEST_F(AppCacheQuotaClientTest, GetOriginsForType) {
EXPECT_THAT(origins, testing::Contains(kOriginA)); EXPECT_THAT(origins, testing::Contains(kOriginA));
EXPECT_THAT(origins, testing::Contains(kOriginB)); EXPECT_THAT(origins, testing::Contains(kOriginB));
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
Call_OnQuotaManagerDestroyed(*client); Call_OnQuotaManagerDestroyed(*client);
} }
TEST_F(AppCacheQuotaClientTest, DeleteOriginData) { TEST_F(AppCacheQuotaClientTest, DeleteOriginData) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
EXPECT_EQ(blink::mojom::QuotaStatusCode::kOk, EXPECT_EQ(blink::mojom::QuotaStatusCode::kOk,
DeleteOriginData(*client, kTemp, kOriginA)); DeleteOriginData(*client, kTemp, kOriginA));
...@@ -287,7 +287,7 @@ TEST_F(AppCacheQuotaClientTest, DeleteOriginData) { ...@@ -287,7 +287,7 @@ TEST_F(AppCacheQuotaClientTest, DeleteOriginData) {
EXPECT_EQ(2, mock_service_.delete_called_count()); EXPECT_EQ(2, mock_service_.delete_called_count());
Call_OnQuotaManagerDestroyed(*client); Call_OnQuotaManagerDestroyed(*client);
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
} }
TEST_F(AppCacheQuotaClientTest, PendingRequests) { TEST_F(AppCacheQuotaClientTest, PendingRequests) {
...@@ -316,7 +316,7 @@ TEST_F(AppCacheQuotaClientTest, PendingRequests) { ...@@ -316,7 +316,7 @@ TEST_F(AppCacheQuotaClientTest, PendingRequests) {
EXPECT_EQ(0, num_delete_origins_completions_); EXPECT_EQ(0, num_delete_origins_completions_);
// Pending requests should get serviced when the appcache is ready. // Pending requests should get serviced when the appcache is ready.
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(2, num_get_origin_usage_completions_); EXPECT_EQ(2, num_get_origin_usage_completions_);
EXPECT_EQ(4, num_get_origins_completions_); EXPECT_EQ(4, num_get_origins_completions_);
...@@ -327,7 +327,7 @@ TEST_F(AppCacheQuotaClientTest, PendingRequests) { ...@@ -327,7 +327,7 @@ TEST_F(AppCacheQuotaClientTest, PendingRequests) {
EXPECT_EQ(1ul, origins_.size()); EXPECT_EQ(1ul, origins_.size());
EXPECT_THAT(origins_, testing::Contains(kOriginOther)); EXPECT_THAT(origins_, testing::Contains(kOriginOther));
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
Call_OnQuotaManagerDestroyed(*client); Call_OnQuotaManagerDestroyed(*client);
} }
...@@ -353,7 +353,7 @@ TEST_F(AppCacheQuotaClientTest, DestroyServiceWithPending) { ...@@ -353,7 +353,7 @@ TEST_F(AppCacheQuotaClientTest, DestroyServiceWithPending) {
EXPECT_EQ(0, num_delete_origins_completions_); EXPECT_EQ(0, num_delete_origins_completions_);
// Kill the service. // Kill the service.
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
// All should have been aborted and called completion. // All should have been aborted and called completion.
EXPECT_EQ(2, num_get_origin_usage_completions_); EXPECT_EQ(2, num_get_origin_usage_completions_);
...@@ -389,7 +389,7 @@ TEST_F(AppCacheQuotaClientTest, DestroyQuotaManagerWithPending) { ...@@ -389,7 +389,7 @@ TEST_F(AppCacheQuotaClientTest, DestroyQuotaManagerWithPending) {
// Kill the quota manager. // Kill the quota manager.
Call_OnQuotaManagerDestroyed(*client); Call_OnQuotaManagerDestroyed(*client);
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
// Callbacks should be deleted and not called. // Callbacks should be deleted and not called.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
...@@ -397,26 +397,26 @@ TEST_F(AppCacheQuotaClientTest, DestroyQuotaManagerWithPending) { ...@@ -397,26 +397,26 @@ TEST_F(AppCacheQuotaClientTest, DestroyQuotaManagerWithPending) {
EXPECT_EQ(0, num_get_origins_completions_); EXPECT_EQ(0, num_get_origins_completions_);
EXPECT_EQ(0, num_delete_origins_completions_); EXPECT_EQ(0, num_delete_origins_completions_);
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
} }
TEST_F(AppCacheQuotaClientTest, DestroyWithDeleteInProgress) { TEST_F(AppCacheQuotaClientTest, DestroyWithDeleteInProgress) {
auto client = CreateClient(); auto client = CreateClient();
Call_NotifyAppCacheReady(*client); Call_NotifyStorageReady(*client);
// Start an async delete. // Start an async delete.
AsyncDeleteOriginData(*client, kTemp, kOriginB); AsyncDeleteOriginData(*client, kTemp, kOriginB);
EXPECT_EQ(0, num_delete_origins_completions_); EXPECT_EQ(0, num_delete_origins_completions_);
// Kill the service. // Kill the service.
Call_NotifyAppCacheDestroyed(*client); Call_NotifyServiceDestroyed(*client);
// Should have been aborted. // Should have been aborted.
EXPECT_EQ(1, num_delete_origins_completions_); EXPECT_EQ(1, num_delete_origins_completions_);
EXPECT_EQ(blink::mojom::QuotaStatusCode::kErrorAbort, delete_status_); EXPECT_EQ(blink::mojom::QuotaStatusCode::kErrorAbort, delete_status_);
// A real completion callback from the service should // A real completion callback from the service should
// be dropped if it comes in after NotifyAppCacheDestroyed. // be dropped if it comes in after NotifyServiceDestroyed.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(1, num_delete_origins_completions_); EXPECT_EQ(1, num_delete_origins_completions_);
EXPECT_EQ(blink::mojom::QuotaStatusCode::kErrorAbort, delete_status_); EXPECT_EQ(blink::mojom::QuotaStatusCode::kErrorAbort, delete_status_);
......
...@@ -403,7 +403,7 @@ AppCacheServiceImpl::~AppCacheServiceImpl() { ...@@ -403,7 +403,7 @@ AppCacheServiceImpl::~AppCacheServiceImpl() {
pending_helpers_.clear(); pending_helpers_.clear();
if (quota_client_) { if (quota_client_) {
GetIOThreadTaskRunner({})->PostTask( GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(&AppCacheQuotaClient::NotifyAppCacheDestroyed, FROM_HERE, base::BindOnce(&AppCacheQuotaClient::NotifyServiceDestroyed,
std::move(quota_client_))); std::move(quota_client_)));
} }
......
...@@ -310,7 +310,7 @@ void AppCacheStorageImpl::InitTask::RunCompleted() { ...@@ -310,7 +310,7 @@ void AppCacheStorageImpl::InitTask::RunCompleted() {
if (storage_->service()->quota_client()) { if (storage_->service()->quota_client()) {
GetIOThreadTaskRunner({})->PostTask( GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&AppCacheQuotaClient::NotifyAppCacheReady, base::BindOnce(&AppCacheQuotaClient::NotifyStorageReady,
base::RetainedRef(storage_->service()->quota_client()))); base::RetainedRef(storage_->service()->quota_client())));
} }
} }
......
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