Commit 8af80017 authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

AppCache: Modernize lifecycle markers in AppCacheQuotaClientTest.

This CL replaces smart pointers (scoped_refptr) with references where
the pointers are guaranteed to be non-null, and the objects are only
used during the method call.

This removes the test's reliance on QuotaClient being ref-counted, which
will come in handy when QuotaClient gets mojofied.

Bug: 1016065
Change-Id: I0ec5ea2f40c03bbdb4e6af504d6f2b4902115c31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2496743
Auto-Submit: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821432}
parent 7ed44a41
...@@ -60,6 +60,7 @@ AppCacheQuotaClient::~AppCacheQuotaClient() { ...@@ -60,6 +60,7 @@ AppCacheQuotaClient::~AppCacheQuotaClient() {
void AppCacheQuotaClient::OnQuotaManagerDestroyed() { void AppCacheQuotaClient::OnQuotaManagerDestroyed() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DeletePendingRequests(); DeletePendingRequests();
if (!current_delete_request_callback_.is_null()) { if (!current_delete_request_callback_.is_null()) {
current_delete_request_callback_.Reset(); current_delete_request_callback_.Reset();
...@@ -169,6 +170,8 @@ void AppCacheQuotaClient::PerformStorageCleanup(blink::mojom::StorageType type, ...@@ -169,6 +170,8 @@ void AppCacheQuotaClient::PerformStorageCleanup(blink::mojom::StorageType type,
} }
void AppCacheQuotaClient::DidDeleteAppCachesForOrigin(int rv) { void AppCacheQuotaClient::DidDeleteAppCachesForOrigin(int rv) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Finish the request by calling our callers callback. // Finish the request by calling our callers callback.
std::move(current_delete_request_callback_) std::move(current_delete_request_callback_)
.Run(NetErrorCodeToQuotaStatus(rv)); .Run(NetErrorCodeToQuotaStatus(rv));
...@@ -181,6 +184,7 @@ void AppCacheQuotaClient::DidDeleteAppCachesForOrigin(int rv) { ...@@ -181,6 +184,7 @@ void AppCacheQuotaClient::DidDeleteAppCachesForOrigin(int rv) {
void AppCacheQuotaClient::GetOriginsHelper(const std::string& opt_host, void AppCacheQuotaClient::GetOriginsHelper(const std::string& opt_host,
GetOriginsForTypeCallback callback) { GetOriginsForTypeCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
if (service_is_destroyed_) { if (service_is_destroyed_) {
...@@ -215,7 +219,9 @@ void AppCacheQuotaClient::GetOriginsHelper(const std::string& opt_host, ...@@ -215,7 +219,9 @@ void AppCacheQuotaClient::GetOriginsHelper(const std::string& opt_host,
} }
void AppCacheQuotaClient::ProcessPendingRequests() { void AppCacheQuotaClient::ProcessPendingRequests() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(appcache_is_ready_); DCHECK(appcache_is_ready_);
while (!pending_batch_requests_.empty()) while (!pending_batch_requests_.empty())
RunFront(&pending_batch_requests_); RunFront(&pending_batch_requests_);
...@@ -224,12 +230,15 @@ void AppCacheQuotaClient::ProcessPendingRequests() { ...@@ -224,12 +230,15 @@ void AppCacheQuotaClient::ProcessPendingRequests() {
} }
void AppCacheQuotaClient::DeletePendingRequests() { void AppCacheQuotaClient::DeletePendingRequests() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
pending_batch_requests_.clear(); pending_batch_requests_.clear();
pending_serial_requests_.clear(); pending_serial_requests_.clear();
} }
net::CancelableCompletionRepeatingCallback* net::CancelableCompletionRepeatingCallback*
AppCacheQuotaClient::GetServiceDeleteCallback() { AppCacheQuotaClient::GetServiceDeleteCallback() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Lazily created due to base::CancelableCallback's threading restrictions, // Lazily created due to base::CancelableCallback's threading restrictions,
// there is no way to detach from the thread created on. // there is no way to detach from the thread created on.
if (!service_delete_callback_) { if (!service_delete_callback_) {
...@@ -244,6 +253,7 @@ AppCacheQuotaClient::GetServiceDeleteCallback() { ...@@ -244,6 +253,7 @@ AppCacheQuotaClient::GetServiceDeleteCallback() {
void AppCacheQuotaClient::NotifyAppCacheReady() { void AppCacheQuotaClient::NotifyAppCacheReady() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Can reoccur during reinitialization. // Can reoccur during reinitialization.
if (!appcache_is_ready_) { if (!appcache_is_ready_) {
appcache_is_ready_ = true; appcache_is_ready_ = true;
......
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