Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: base/sys_info.h

Issue 23588009: Parse /etc/lsb-release only once on ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/sys_info_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_SYS_INFO_H_ 5 #ifndef BASE_SYS_INFO_H_
6 #define BASE_SYS_INFO_H_ 6 #define BASE_SYS_INFO_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 10
10 #include "base/base_export.h" 11 #include "base/base_export.h"
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/time/time.h"
13 #include "build/build_config.h" 15 #include "build/build_config.h"
14 16
15 namespace base { 17 namespace base {
16 18
17 class BASE_EXPORT SysInfo { 19 class BASE_EXPORT SysInfo {
18 public: 20 public:
19 // Return the number of logical processors/cores on the current machine. 21 // Return the number of logical processors/cores on the current machine.
20 static int NumberOfProcessors(); 22 static int NumberOfProcessors();
21 23
22 // Return the number of bytes of physical memory on the current machine. 24 // Return the number of bytes of physical memory on the current machine.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // Return the smallest amount of memory (in bytes) which the VM system will 73 // Return the smallest amount of memory (in bytes) which the VM system will
72 // allocate. 74 // allocate.
73 static size_t VMAllocationGranularity(); 75 static size_t VMAllocationGranularity();
74 76
75 #if defined(OS_POSIX) && !defined(OS_MACOSX) 77 #if defined(OS_POSIX) && !defined(OS_MACOSX)
76 // Returns the maximum SysV shared memory segment size. 78 // Returns the maximum SysV shared memory segment size.
77 static size_t MaxSharedMemorySize(); 79 static size_t MaxSharedMemorySize();
78 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 80 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
79 81
80 #if defined(OS_CHROMEOS) 82 #if defined(OS_CHROMEOS)
81 // Returns the name of the version entry we wish to look up in the 83 typedef std::map<std::string, std::string> LsbReleaseMap;
82 // Linux Standard Base release information file.
83 static std::string GetLinuxStandardBaseVersionKey();
84 84
85 // Parses /etc/lsb-release to get version information for Google Chrome OS. 85 // Returns the contents of /etc/lsb-release as a map.
86 // Declared here so it can be exposed for unit testing. 86 static const LsbReleaseMap& GetLsbReleaseMap();
87 static void ParseLsbRelease(const std::string& lsb_release,
88 int32* major_version,
89 int32* minor_version,
90 int32* bugfix_version);
91 87
92 // Returns the path to the lsb-release file. 88 // If |key| is present in the LsbReleaseMap, sets |value| and returns true.
93 static FilePath GetLsbReleaseFilePath(); 89 static bool GetLsbReleaseValue(const std::string& key, std::string* value);
90
91 // Convenience function for GetLsbReleaseValue("CHROMEOS_RELEASE_BOARD",...).
92 // Returns "unknown" if CHROMEOS_RELEASE_BOARD is not set.
93 static std::string GetLsbReleaseBoard();
94
95 // Returns the creation time of /etc/lsb-release. (Used to get the date and
96 // time of the Chrome OS build).
97 static Time GetLsbReleaseTime();
98
99 // Test method to force re-parsing of lsb-release.
100 static void SetChromeOSVersionInfoForTest(const std::string& lsb_release,
101 const Time& lsb_release_time);
94 #endif // defined(OS_CHROMEOS) 102 #endif // defined(OS_CHROMEOS)
95 103
96 #if defined(OS_ANDROID) 104 #if defined(OS_ANDROID)
97 // Returns the Android build's codename. 105 // Returns the Android build's codename.
98 static std::string GetAndroidBuildCodename(); 106 static std::string GetAndroidBuildCodename();
99 107
100 // Returns the Android build ID. 108 // Returns the Android build ID.
101 static std::string GetAndroidBuildID(); 109 static std::string GetAndroidBuildID();
102 110
103 // Returns the device's name. 111 // Returns the device's name.
104 static std::string GetDeviceName(); 112 static std::string GetDeviceName();
105 113
106 static int DalvikHeapSizeMB(); 114 static int DalvikHeapSizeMB();
107 static int DalvikHeapGrowthLimitMB(); 115 static int DalvikHeapGrowthLimitMB();
108 #endif // defined(OS_ANDROID) 116 #endif // defined(OS_ANDROID)
109 }; 117 };
110 118
111 } // namespace base 119 } // namespace base
112 120
113 #endif // BASE_SYS_INFO_H_ 121 #endif // BASE_SYS_INFO_H_
OLDNEW
« no previous file with comments | « no previous file | base/sys_info_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698