DescriptionFixing an edge case in CRWBrowsingDataStore
Edge case:
When there are consecutive makeActive and makeInactive calls and the operations
finish fast, each of the callbacks that they receive lead to the changing of the
CRWBrowsingDataStore's mode.
This can lead to a jarring API as the mode changes frequently when callbacks are
received.
The correct behavior is to have the mode in |SYNCHRONIZING| until all the
callbacks are received.
When consecutive |makeActive|, |makeInactive| calls are received, the mode has
to change like so:
ACTIVE/INACTIVE -> SYNCHRONIZING -> INACTIVE/ACTIVE.
The state of pending callbacks is now tracked using an ivar in the .mm
The completionHandler API is also vastly improved as a result. The
completionHandler now returns a BOOL that indicates if the operation was
successful. This is inspired from the |UIView animateWithDuration:|.
If multiple |makeActive|, |makeInactive| calls are driven. The completionHandler
of all but the last one (incl. the penultimate one) are called with a
success=NO. The last completionHandler is the actual one that changes the mode of
the CRWBrowsingDataStore and is called with a success=YES.
There is a need to override |automaticallyNotifiesObserversForKey| because
the default KVO behavior is to call the observer methods even though the
internal ivar may not have changed.
This affects CRWBrowsingDataStore because a call to setMode:SYNCHRONIZING even
though the mode is already SYNCHRONIZING will trigger an observer notification.
We want to finely control this observer notification since
BrowsingDataPartition will listen to this (in a future CL) and will maintain
state accordingly. It will lead to simpler logic in BrowsingDataParition if the
observer is notified only when the mode actually changes.
An example of an observer is included in the unittest.
BUG=480654
Committed: https://crrev.com/c426d7e90a927cf77347d1817fa72b97bc59b1eb
Cr-Commit-Position: refs/heads/master@{#332239}
Patch Set 1 #Patch Set 2 : y #
Total comments: 15
Patch Set 3 : y #
Total comments: 2
Patch Set 4 : y #
Messages
Total messages: 11 (3 generated)
|