[Android] Reimplement asynchronous methods in AccountManagerFacade
Before this CL, asynchronous methods in AccountManagerFacade were using AsyncTask to avoid blocking the main thread if account list cache hasn't been populated yet. However, this approach has two major drawbacks: 1. Every call to these methods blocks one thread from thread pool until the cache is populated. 2. Even if the cache is already populated, call still creates AsyncTask, incurring unnecessary allocations and thread hops. This CL introduces AccountManagerFacade.runAfterCacheIsPopulated that keeps a list of callbacks to execute after the cache is populated. If the cache has already been populated, this method just posts the callback to the main thread. All asynchronous account-related methods in AccountManagerFacade are reimplemented using runAfterCacheIsPopulated. Bug: 887969 Change-Id: I856b6c7f9395a70857d079dedfbf3f4f6403f901 Reviewed-on: https://chromium-review.googlesource.com/c/1238559 Commit-Queue: Boris Sazonov <bsazonov@chromium.org> Reviewed-by:Mihai Sardarescu <msarda@chromium.org> Cr-Commit-Position: refs/heads/master@{#597536}
Showing
Please register or sign in to comment