[Android] Fix timing issue in enabling/disabling printing.
There are a couple timing issues in the previous
implementation of the code that enables/disables the print
activity that is accessible via share.
1.) Multiple calls to enablePrintShareOption could result
in the second call having the callback run immediately
without the component first being enabled (since it
would have been triggered in an AsyncTask in the first
call).
2.) Back to back enable/disable calls could result in
unpredictable execution ordering as they run their
tasks on the thread pool instead of in serial. Because
the initial UI is only shown after the first callback is
run, this would require a show, followed by a hide, followed
by a show where the task enqueued by the hide is run after
the enabling call in the second show.
To work around this (and due to the expected usage pattern of
this class), just wait for the task to be run in either of these
states to avoid this being possible. It would also be possible
to use the SERIAL executor, but that might end up slowing down
the default share flow where we don't expect this interleaving
issue.
BUG=649453,664486
Review-Url: https://codereview.chromium.org/2523873003
Cr-Commit-Position: refs/heads/master@{#434676}
Showing
Please register or sign in to comment