Commit fe595425 authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

Comment ListenToCookieChanges call in StoragePartitionImplMap::Get.

This adds a comment before the CookieStoreContext::ListenToCookieChanges
call, and renames one of its parameters to hopefully make it clearer.
If anyone else ever misreads the code the way I did, hopefully this
change will help explain things.

Change-Id: Id5256b85c179f9a16a2c5b0df18288bb3122e245
Reviewed-on: https://chromium-review.googlesource.com/c/1413890Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623156}
parent ada0422f
...@@ -25,7 +25,7 @@ CookieStoreContext::~CookieStoreContext() { ...@@ -25,7 +25,7 @@ CookieStoreContext::~CookieStoreContext() {
void CookieStoreContext::Initialize( void CookieStoreContext::Initialize(
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
base::OnceCallback<void(bool)> callback) { base::OnceCallback<void(bool)> success_callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK(!initialize_called_) << __func__ << " called twice"; DCHECK(!initialize_called_) << __func__ << " called twice";
...@@ -43,12 +43,13 @@ void CookieStoreContext::Initialize( ...@@ -43,12 +43,13 @@ void CookieStoreContext::Initialize(
task_runner->PostTask( task_runner->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), result)); FROM_HERE, base::BindOnce(std::move(callback), result));
}, },
base::SequencedTaskRunnerHandle::Get(), std::move(callback)))); base::SequencedTaskRunnerHandle::Get(),
std::move(success_callback))));
} }
void CookieStoreContext::ListenToCookieChanges( void CookieStoreContext::ListenToCookieChanges(
::network::mojom::NetworkContext* network_context, ::network::mojom::NetworkContext* network_context,
base::OnceCallback<void(bool)> callback) { base::OnceCallback<void(bool)> success_callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK(initialize_called_) << __func__ << " called before Initialize()"; DCHECK(initialize_called_) << __func__ << " called before Initialize()";
...@@ -69,7 +70,8 @@ void CookieStoreContext::ListenToCookieChanges( ...@@ -69,7 +70,8 @@ void CookieStoreContext::ListenToCookieChanges(
task_runner->PostTask( task_runner->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), result)); FROM_HERE, base::BindOnce(std::move(callback), result));
}, },
base::SequencedTaskRunnerHandle::Get(), std::move(callback)))); base::SequencedTaskRunnerHandle::Get(),
std::move(success_callback))));
} }
void CookieStoreContext::CreateService(blink::mojom::CookieStoreRequest request, void CookieStoreContext::CreateService(blink::mojom::CookieStoreRequest request,
...@@ -87,24 +89,24 @@ void CookieStoreContext::CreateService(blink::mojom::CookieStoreRequest request, ...@@ -87,24 +89,24 @@ void CookieStoreContext::CreateService(blink::mojom::CookieStoreRequest request,
void CookieStoreContext::InitializeOnIOThread( void CookieStoreContext::InitializeOnIOThread(
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
base::OnceCallback<void(bool)> callback) { base::OnceCallback<void(bool)> success_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!cookie_store_manager_) << __func__ << " called more than once"; DCHECK(!cookie_store_manager_) << __func__ << " called more than once";
cookie_store_manager_ = cookie_store_manager_ =
std::make_unique<CookieStoreManager>(std::move(service_worker_context)); std::make_unique<CookieStoreManager>(std::move(service_worker_context));
cookie_store_manager_->LoadAllSubscriptions(std::move(callback)); cookie_store_manager_->LoadAllSubscriptions(std::move(success_callback));
} }
void CookieStoreContext::ListenToCookieChangesOnIOThread( void CookieStoreContext::ListenToCookieChangesOnIOThread(
::network::mojom::CookieManagerPtrInfo cookie_manager_ptr_info, ::network::mojom::CookieManagerPtrInfo cookie_manager_ptr_info,
base::OnceCallback<void(bool)> callback) { base::OnceCallback<void(bool)> success_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(cookie_store_manager_); DCHECK(cookie_store_manager_);
cookie_store_manager_->ListenToCookieChanges( cookie_store_manager_->ListenToCookieChanges(
::network::mojom::CookieManagerPtr(std::move(cookie_manager_ptr_info)), ::network::mojom::CookieManagerPtr(std::move(cookie_manager_ptr_info)),
std::move(callback)); std::move(success_callback));
} }
void CookieStoreContext::CreateServiceOnIOThread( void CookieStoreContext::CreateServiceOnIOThread(
......
...@@ -52,13 +52,13 @@ class CONTENT_EXPORT CookieStoreContext ...@@ -52,13 +52,13 @@ class CONTENT_EXPORT CookieStoreContext
// errors. // errors.
void Initialize( void Initialize(
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
base::OnceCallback<void(bool)> callback); base::OnceCallback<void(bool)> success_callback);
// Starts listening to cookie changes from a network service instance. // Starts listening to cookie changes from a network service instance.
// //
// The callback is called with the (success / failure) result of subscribing. // The callback is called with the (success / failure) result of subscribing.
void ListenToCookieChanges(::network::mojom::NetworkContext* network_context, void ListenToCookieChanges(::network::mojom::NetworkContext* network_context,
base::OnceCallback<void(bool)> callback); base::OnceCallback<void(bool)> success_callback);
// Routes a mojo request to the CookieStoreManager on the IO thread. // Routes a mojo request to the CookieStoreManager on the IO thread.
void CreateService(blink::mojom::CookieStoreRequest request, void CreateService(blink::mojom::CookieStoreRequest request,
...@@ -71,11 +71,11 @@ class CONTENT_EXPORT CookieStoreContext ...@@ -71,11 +71,11 @@ class CONTENT_EXPORT CookieStoreContext
void InitializeOnIOThread( void InitializeOnIOThread(
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
base::OnceCallback<void(bool)> callback); base::OnceCallback<void(bool)> success_callback);
void ListenToCookieChangesOnIOThread( void ListenToCookieChangesOnIOThread(
::network::mojom::CookieManagerPtrInfo cookie_manager_ptr_info, ::network::mojom::CookieManagerPtrInfo cookie_manager_ptr_info,
base::OnceCallback<void(bool)> callback); base::OnceCallback<void(bool)> success_callback);
void CreateServiceOnIOThread(blink::mojom::CookieStoreRequest request, void CreateServiceOnIOThread(blink::mojom::CookieStoreRequest request,
const url::Origin& origin); const url::Origin& origin);
......
...@@ -455,8 +455,9 @@ StoragePartitionImpl* StoragePartitionImplMap::Get( ...@@ -455,8 +455,9 @@ StoragePartitionImpl* StoragePartitionImplMap::Get(
partition->GetPath(), in_memory)); partition->GetPath(), in_memory));
} }
// Arm the serviceworker cookie change observation API.
partition->GetCookieStoreContext()->ListenToCookieChanges( partition->GetCookieStoreContext()->ListenToCookieChanges(
partition->GetNetworkContext(), base::DoNothing()); partition->GetNetworkContext(), /*success_callback=*/base::DoNothing());
if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) { if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
// This needs to happen after SetURLRequestContext() since we need this // This needs to happen after SetURLRequestContext() since we need this
......
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