WebView: Fix deadlock in CookieManager.

The new implementation of CookieManager::SetAcceptFileSchemeCookies
introduced by the network servicification can deadlock when the
embedding app is using the CookieManager API in a silly (but not
forbidden) way.

The deadlock occurs because the calling thread holds
accept_file_scheme_cookies_lock_ while waiting synchronously for a task
to complete on the CookieManagerClient thread, but it's possible that a
task was already queued on that thread which is going to call
GetCookieStore() and then attempt to acquire
accept_file_scheme_cookies_lock_ to create the cookie store.

Avoid this by moving the code which updates accept_file_scheme_cookies_
to run as part of the posted task instead.

Also, add thread annotations to CookieManager to clarify which locks
protect which state, as the existing comment was not correct.

Fixed: 992829
Change-Id: I61aa3a505add2866fdf4317ffa7cf33e684ddc55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890953
Reviewed-by: Tobias Sargeant <[email protected]>
Reviewed-by: Changwan Ryu <[email protected]>
Reviewed-by: Nate Fischer <[email protected]>
Commit-Queue: Richard Coles <[email protected]>
Cr-Commit-Position: refs/heads/master@{#711806}
2 files changed