Shift cookie system callbacks to OnceCallback to match mojo.
Mojo provides OnceCallbacks to services for notification of
completion of operations (which makes sense--operations
can't conceptually complete multiple times). Unfortunately,
CookieStore, while asynchronous, uses the default repeating
callbacks. This CL shifts the CookieStore over to using
OnceCallbacks, so that a cookie service may be layered on
top of it. This change is made simpler and smaller by the
fact that there is an automatic cast from a repeated Callback
to a OnceCallback, so consumers of the CookieStore
interface do not need to be converted. However, all
subclasses of CookieStore do.
See https://docs.google.com/document/d/1jsaJAT-WbFS2ZwLEPkAgGcMTQ6MQLIQlyQfd1JeEupg/edit#heading=h.5ztx0u98smg8
for details on OnceCallback and conversions. A couple of
things to note about conversions:
* OnceCallbacks can't be copied, they need to be moved
(std::move).
* Bind produces Callbacks, BindOnce produces
OnceCallbacks.
* If you Bind a OnceCallback, that's similar to binding a
unique_ptr<>; you have to use Passed() and it's not clear
what happens if you call the result multiple times.
BindOnce() Just Works, and correctly expresses the
semantics (since if a repeating Callback actually used a
OnceCallback, it's not clear what the repeating Callback
would do on the next call).
BUG=721395
Review-Url: https://codereview.chromium.org/2937963003
Cr-Commit-Position: refs/heads/master@{#481573}
31 files changed