Skip to content

Commit

Permalink
[iOS] Support empty callbacks in all CookieStoreIOS methods.
Browse files Browse the repository at this point in the history
This CL adds the missing tests for empty callbacks, to match the other
CookieStore implementations.
Callers do expect empty callbacks to be supported, resulting in actual
crashes. This CL fixes these crashes.

BUG=587930

Review URL: https://codereview.chromium.org/1717253002

Cr-Commit-Position: refs/heads/master@{#376771}
  • Loading branch information
droger authored and Commit bot committed Feb 22, 2016
1 parent ada03f7 commit 4c3ea11
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ios/net/cookies/cookie_store_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ bool HasExplicitDomain(const std::string& cookie_line) {
CookieStoreIOSClient* client = net::GetCookieStoreIOSClient();
DCHECK(client);
client->DidChangeCookieStorage();
callback.Run(num_deleted_from_nshttp_cookie_storage);
if (!callback.is_null())
callback.Run(num_deleted_from_nshttp_cookie_storage);
}

void CookieStoreIOS::UpdateCachesFromCookieMonster() {
Expand All @@ -1099,20 +1100,23 @@ bool HasExplicitDomain(const std::string& cookie_line) {
DCHECK(thread_checker_.CalledOnValidThread());
if (success)
UpdateCachesFromCookieMonster();
callback.Run(success);
if (!callback.is_null())
callback.Run(success);
}

void CookieStoreIOS::UpdateCachesAfterDelete(const DeleteCallback& callback,
int num_deleted) {
DCHECK(thread_checker_.CalledOnValidThread());
UpdateCachesFromCookieMonster();
callback.Run(num_deleted);
if (!callback.is_null())
callback.Run(num_deleted);
}

void CookieStoreIOS::UpdateCachesAfterClosure(const base::Closure& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
UpdateCachesFromCookieMonster();
callback.Run();
if (!callback.is_null())
callback.Run();
}

net::CookieList
Expand Down

0 comments on commit 4c3ea11

Please sign in to comment.