diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-26 21:51:23 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-26 21:51:23 +0000 |
commit | a0a1c5a43129c46aec7525f0292ebe17434b77e6 (patch) | |
tree | 089aef99bd9338ad9a30a9ba358f85cbe7ae8e2e /base/sys_info.h | |
parent | 3d3b931e213b1a972233465055c8aae1f1044f75 (diff) | |
download | chromium_src-a0a1c5a43129c46aec7525f0292ebe17434b77e6.zip chromium_src-a0a1c5a43129c46aec7525f0292ebe17434b77e6.tar.gz chromium_src-a0a1c5a43129c46aec7525f0292ebe17434b77e6.tar.bz2 |
Parse /etc/lsb-release only once on ChromeOS
This moves all parsing and caching of the contents of /etc/lsb-release
to base::SysInfo. This eliminates redundant parsing from:
* LsbReleaseLogSource
* VersionLoader
* StatisticsProvider
BUG=266903
For chrome_main_deleagate.cc (code removal only)
R=brettw@chromium.org, derat@chromium.org, pneubeck@chromium.org, xiyuan@chromium.org
TBR=cpu@chromium.org
Review URL: https://codereview.chromium.org/23588009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_info.h')
-rw-r--r-- | base/sys_info.h | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/base/sys_info.h b/base/sys_info.h index 38462ed..564832d 100644 --- a/base/sys_info.h +++ b/base/sys_info.h @@ -5,11 +5,13 @@ #ifndef BASE_SYS_INFO_H_ #define BASE_SYS_INFO_H_ +#include <map> #include <string> #include "base/base_export.h" #include "base/basictypes.h" #include "base/files/file_path.h" +#include "base/time/time.h" #include "build/build_config.h" namespace base { @@ -78,19 +80,25 @@ class BASE_EXPORT SysInfo { #endif // defined(OS_POSIX) && !defined(OS_MACOSX) #if defined(OS_CHROMEOS) - // Returns the name of the version entry we wish to look up in the - // Linux Standard Base release information file. - static std::string GetLinuxStandardBaseVersionKey(); - - // Parses /etc/lsb-release to get version information for Google Chrome OS. - // Declared here so it can be exposed for unit testing. - static void ParseLsbRelease(const std::string& lsb_release, - int32* major_version, - int32* minor_version, - int32* bugfix_version); - - // Returns the path to the lsb-release file. - static FilePath GetLsbReleaseFilePath(); + typedef std::map<std::string, std::string> LsbReleaseMap; + + // Returns the contents of /etc/lsb-release as a map. + static const LsbReleaseMap& GetLsbReleaseMap(); + + // If |key| is present in the LsbReleaseMap, sets |value| and returns true. + static bool GetLsbReleaseValue(const std::string& key, std::string* value); + + // Convenience function for GetLsbReleaseValue("CHROMEOS_RELEASE_BOARD",...). + // Returns "unknown" if CHROMEOS_RELEASE_BOARD is not set. + static std::string GetLsbReleaseBoard(); + + // Returns the creation time of /etc/lsb-release. (Used to get the date and + // time of the Chrome OS build). + static Time GetLsbReleaseTime(); + + // Test method to force re-parsing of lsb-release. + static void SetChromeOSVersionInfoForTest(const std::string& lsb_release, + const Time& lsb_release_time); #endif // defined(OS_CHROMEOS) #if defined(OS_ANDROID) |