Chrome Version: ToT
OS: ChromeOS
Issue: some BrowserContextKeyedService subclasses depend on ArcService subclasses (e.g. observing), but teardown (e.g. RemoveObserver) in dtor may not work well.
Note that: this is internal clean up now, because we haven't hit the serious problem on shutdown, yet.
Details:
Practically, ArcService subclasses and BrowserContextKeyedService subclasses are working as singleton in Chrome. But, those destroying timing is fixed.
Now ArcService classes are destroyed before Profile's destruction, because some ArcService classes depend on Profile.
BrowserContextKeyedService classes are destroyed on Profile destruction.
So; some BrowserContextKeyedService depend on some ArcServices (e.g. EventRouter or ArcAppPrefsList) and trying to clean teardown in their dtor, but these won't work well because, in the dtor, ArcServices are already destroyed.
For better shutdown, we want to destroy objects in following order:
- BrowserContextKeyedService
- ArcService
- Profile
However, this is not that easy now because of the current code structure.
To resolve this situation, there could be several approaches;
- Make (some part of) ArcService as BrowserContextKeyedService and create dependencies.
- If an ArcService has an Observer, add, e.g., OnShutdown() callback, which is called in its dtor. So that BrowserContextKeyedService can know on destruction, and can necessary teardown.
- Similar to above, provide OnShutdown() callback in ArcServiceManager::Observer (instead of each ArcService).
Comment 1 by yusukes@chromium.org
, Dec 9 2016