Skip to content

Commit

Permalink
os_languages_page: Do not poll language packs if flag is disabled
Browse files Browse the repository at this point in the history
The polling is not useful when the language packs in settings flag is
disabled. Disabling the poll will reduce the number of extension API
requests made.

loadTimeData is not expected to change throughout the duration of a
<settings-languages> element.

Bug: b:298128915
Change-Id: I07fca4f7b42ee744f0eb4cd2919613142296aabe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4941330
Reviewed-by: Claudio M <claudiomagni@chromium.org>
Commit-Queue: Michael Cui <mlcui@google.com>
Cr-Commit-Position: refs/heads/main@{#1209952}
  • Loading branch information
mlcui-corp authored and Chromium LUCI CQ committed Oct 16, 2023
1 parent 604a49a commit 8371b51
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'chrome://resources/cr_components/settings_prefs/prefs.js';
import {PrefsMixin} from 'chrome://resources/cr_components/settings_prefs/prefs_mixin.js';
import {CrSettingsPrefs} from 'chrome://resources/cr_components/settings_prefs/prefs_types.js';
import {assert} from 'chrome://resources/js/assert.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.js';
import {PromiseResolver} from 'chrome://resources/js/promise_resolver.js';
import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

Expand Down Expand Up @@ -329,12 +330,14 @@ export class SettingsLanguagesElement extends SettingsLanguagesElementBase
this.languageSettingsPrivate_.getSpellcheckDictionaryStatuses().then(
this.boundOnSpellcheckDictionariesChanged_);

// Poll language packs now to prevent test flakiness.
// Do so in the next microtask to prevent `connectedCallback()` from
// failing and stalling tests.
Promise.resolve().then(() => this.pollLanguagePacks_());
this.languagePackPollIntervalId = setInterval(
() => this.pollLanguagePacks_(), LANGUAGE_PACKS_POLLING_RATE_MS);
if (loadTimeData.getBoolean('languagePacksInSettingsEnabled')) {
// Poll language packs now to prevent test flakiness.
// Do so in the next microtask to prevent `connectedCallback()` from
// failing and stalling tests.
Promise.resolve().then(() => this.pollLanguagePacks_());
this.languagePackPollIntervalId = setInterval(
() => this.pollLanguagePacks_(), LANGUAGE_PACKS_POLLING_RATE_MS);
}

this.resolver_.resolve(undefined);
});
Expand Down

0 comments on commit 8371b51

Please sign in to comment.