Simplify initialization of AssistantManager
The code to initialize the |AssistantManager| was quite complex because it had to handle the fact that |AssistantManager| was created on a background thread, and that this background task could be triggered multiple times before it ever finished. To simplify this the |AssistantManager| (and its related classes) is now owned by an |AssistantManagerController| that will: * Ensure the |done_callback| is invoked only once, even if multiple controllers are created (we achieve this by storing the controller in a unique_ptr and ensuring it only calls the callback if the controller was not deleted, meaning only the last controller will call the callback). * Not access the |assistant_manager_| field from the background thread, meaning it can always safely be accessed from the main thread. This simplification will make it easier to move the Libassistant process to a sandbox. Bug: b/171748795 Test: chromeos_unittest --gtest_filter="AssistantManagerServiceTest.*" Change-Id: Icfce1163d5253713094145b5d7e7c637057527c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500452 Commit-Queue: Jeroen Dhollander <jeroendh@chromium.org> Reviewed-by:Xiaohui Chen <xiaohuic@chromium.org> Cr-Commit-Position: refs/heads/master@{#823195}
Showing
This diff is collapsed.
Please register or sign in to comment