version_loader.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2011 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 CHROMEOS_VERSION_VERSION_LOADER_H_
  5. #define CHROMEOS_VERSION_VERSION_LOADER_H_
  6. #include <string>
  7. #include "base/component_export.h"
  8. #include "third_party/abseil-cpp/absl/types/optional.h"
  9. namespace chromeos {
  10. namespace version_loader {
  11. enum VersionFormat {
  12. VERSION_SHORT,
  13. VERSION_SHORT_WITH_DATE,
  14. VERSION_FULL,
  15. };
  16. // Gets the version.
  17. // If |full_version| is true version string with extra info is extracted,
  18. // otherwise it's in short format x.x.xx.x.
  19. // May block.
  20. COMPONENT_EXPORT(CHROMEOS_VERSION)
  21. std::string GetVersion(VersionFormat format);
  22. // Gets the ARC version.
  23. // May block.
  24. COMPONENT_EXPORT(CHROMEOS_VERSION) std::string GetArcVersion();
  25. // Gets the ARC Android SDK version.
  26. // If not found returns absl::nullopt.
  27. // May block.
  28. COMPONENT_EXPORT(CHROMEOS_VERSION)
  29. absl::optional<std::string> GetArcAndroidSdkVersion();
  30. // Gets the firmware info.
  31. // May block.
  32. COMPONENT_EXPORT(CHROMEOS_VERSION) std::string GetFirmware();
  33. // Extracts the firmware from the file.
  34. COMPONENT_EXPORT(CHROMEOS_VERSION)
  35. std::string ParseFirmware(const std::string& contents);
  36. // Returns true if |new_version| is older than |current_version|.
  37. // Version numbers should be dot separated. The sections are compared as
  38. // numbers if possible, as strings otherwise. Earlier sections have
  39. // precedence. If one version is prefix of another, the shorter one is
  40. // considered older. (See test for examples.)
  41. COMPONENT_EXPORT(CHROMEOS_VERSION)
  42. bool IsRollback(const std::string& current_version,
  43. const std::string& new_version);
  44. } // namespace version_loader
  45. } // namespace chromeos
  46. #endif // CHROMEOS_VERSION_VERSION_LOADER_H_