[startup] Wait until settings are loaded to load locale data

If we want to give users a setting to choose their locale, then we need
to wait until settings are available to load the locale data.

This CL reorders startup so that we load up settings/prefs first.
Also promisify prefs loading so that it's easier to follow ordering
in MainImpl.

Bug: 1167695
Change-Id: I0955e04a0b5f204c8784be2cad7e6b9fa5443b8b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2635657
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
This commit is contained in:
Peter Marshall
2021-01-18 13:06:56 +00:00
committed by Commit Bot
parent b06ebb493f
commit 913ec149dd
+7 -10
View File
@@ -84,8 +84,14 @@ export class MainImpl {
await Root.Runtime.appStarted;
Root.Runtime.Runtime.setPlatform(Host.Platform.platform());
Root.Runtime.Runtime.setL10nCallback(ls);
const prefs = await new Promise(resolve => {
Host.InspectorFrontendHost.InspectorFrontendHostInstance.getPreferences(resolve);
});
console.timeStamp('Main._gotPreferences');
this._createSettings(prefs);
await this.requestAndRegisterLocaleData();
Host.InspectorFrontendHost.InspectorFrontendHostInstance.getPreferences(this._gotPreferences.bind(this));
this._createAppUI();
}
async requestAndRegisterLocaleData() {
@@ -101,15 +107,6 @@ export class MainImpl {
}
}
/**
* @param {!Object<string, string>} prefs
*/
_gotPreferences(prefs) {
console.timeStamp('Main._gotPreferences');
this._createSettings(prefs);
this._createAppUI();
}
/**
* @param {!Object<string, string>} prefs
* Note: this function is called from testSettings in Tests.js.