soda_installer_impl_chromeos.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2020 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. #ifndef COMPONENTS_SODA_SODA_INSTALLER_IMPL_CHROMEOS_H_
  5. #define COMPONENTS_SODA_SODA_INSTALLER_IMPL_CHROMEOS_H_
  6. #include "base/component_export.h"
  7. #include "base/files/file_path.h"
  8. #include "chromeos/dbus/dlcservice/dlcservice_client.h"
  9. #include "components/soda/soda_installer.h"
  10. class PrefService;
  11. namespace speech {
  12. // Installer of SODA (Speech On-Device API) for the Live Caption feature on
  13. // ChromeOS.
  14. class COMPONENT_EXPORT(SODA_INSTALLER) SodaInstallerImplChromeOS
  15. : public SodaInstaller {
  16. public:
  17. SodaInstallerImplChromeOS();
  18. ~SodaInstallerImplChromeOS() override;
  19. SodaInstallerImplChromeOS(const SodaInstallerImplChromeOS&) = delete;
  20. SodaInstallerImplChromeOS& operator=(const SodaInstallerImplChromeOS&) =
  21. delete;
  22. // Where the SODA DLC was installed. Cached on completed installation.
  23. // Empty if SODA DLC not installed yet.
  24. base::FilePath GetSodaBinaryPath() const override;
  25. // Where the SODA language pack DLC was installed for a given language.
  26. // Cached on completed installation. Empty if not installed yet.
  27. base::FilePath GetLanguagePath(const std::string& language) const override;
  28. // SodaInstaller:
  29. void InstallLanguage(const std::string& language,
  30. PrefService* global_prefs) override;
  31. std::vector<std::string> GetAvailableLanguages() const override;
  32. private:
  33. // SodaInstaller:
  34. void InstallSoda(PrefService* global_prefs) override;
  35. // Here "uninstall" is used in the DLC sense of the term: Uninstallation will
  36. // disable a DLC but not immediately remove it from disk.
  37. // Once a refcount to the DLC reaches 0 (meaning all profiles which had it
  38. // installed have called to uninstall it), the DLC will remain in cache; if it
  39. // is then not installed within a (DLC-service-defined) window of time, the
  40. // DLC is automatically purged from disk.
  41. void UninstallSoda(PrefService* global_prefs) override;
  42. void SetSodaBinaryPath(base::FilePath new_path);
  43. void SetLanguagePath(base::FilePath new_path);
  44. // These functions are the InstallCallbacks for DlcserviceClient::Install().
  45. void OnSodaInstalled(
  46. const base::Time start_time,
  47. const chromeos::DlcserviceClient::InstallResult& install_result);
  48. void OnLanguageInstalled(
  49. const LanguageCode language_code,
  50. const base::Time start_time,
  51. const chromeos::DlcserviceClient::InstallResult& install_result);
  52. // These functions are the ProgressCallbacks for DlcserviceClient::Install().
  53. void OnSodaProgress(double progress);
  54. void OnLanguageProgress(double progress);
  55. void OnSodaCombinedProgress();
  56. // This is the UninstallCallback for DlcserviceClient::Uninstall().
  57. void OnDlcUninstalled(const std::string& dlc_id, const std::string& err);
  58. double soda_progress_ = 0.0;
  59. base::FilePath soda_lib_path_;
  60. base::FilePath language_path_;
  61. };
  62. } // namespace speech
  63. #endif // COMPONENTS_SODA_SODA_INSTALLER_IMPL_CHROMEOS_H_