1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_STARTUP_SETTINGS_CACHE_H_ 6 #define CHROME_BROWSER_CHROMEOS_STARTUP_SETTINGS_CACHE_H_ 7 8 #include <string> 9 10 namespace chromeos { 11 namespace startup_settings_cache { 12 13 // On Chrome OS, the application locale is stored in local state prefs. The 14 // zygote needs the locale so it can load the correct resource bundle and 15 // provide localized strings to renderers. However, the zygote forks and engages 16 // the sandbox before the browser loads local state. 17 // 18 // Instead, cache the locale in a separate JSON file and read it on zygote 19 // startup. The additional disk read on startup is unfortunately, but it's only 20 // ~20 bytes and this approach performs better than other approaches (passing a 21 // resource bundle file descriptor to zygote on renderer fork, or pre-load the 22 // local state file on startup). On coral (dual core Celeron N3350 1.1 GHz) the 23 // file read takes < 2.5 ms and the write takes < 1 ms. https://crbug.com/510455 24 std::string ReadAppLocale(); 25 26 // Writes the locale string to a JSON file on disk. See above. 27 void WriteAppLocale(std::string app_locale); 28 29 } // namespace startup_settings_cache 30 } // namespace chromeos 31 32 #endif // CHROME_BROWSER_CHROMEOS_STARTUP_SETTINGS_CACHE_H_ 33