Commit 02f7f306 authored by David Roger's avatar David Roger Committed by Commit Bot

[iOS] Build testing factories before profile initialization

On iOS the testing factories are built after initialization, which
causes their re-creation. This causes crashes because the destruction
happens in a random order and doesn't follow the dependencies.
The fix is to add the testing factories before initialization, so that
factories are not destroyed.

This crash does not happen now, but prevents adding more factories
that return true in ServiceIsCreatedWithBrowserState().

Change-Id: I6603ff6cbfecff645b23d879693e6524c7074c0e
Reviewed-on: https://chromium-review.googlesource.com/c/1353943
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612163}
parent 09f852a1
......@@ -142,8 +142,6 @@ TestChromeBrowserState::TestChromeBrowserState(
testing_prefs_(nullptr),
otr_browser_state_(nullptr),
original_browser_state_(nullptr) {
Init();
for (const auto& pair : testing_factories) {
pair.first->SetTestingFactory(this, std::move(pair.second));
}
......@@ -151,6 +149,8 @@ TestChromeBrowserState::TestChromeBrowserState(
for (const auto& pair : refcounted_testing_factories) {
pair.first->SetTestingFactory(this, std::move(pair.second));
}
Init();
}
TestChromeBrowserState::~TestChromeBrowserState() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment