OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 class SysInfo { | 14 class SysInfo { |
15 public: | 15 public: |
16 // Return the number of logical processors/cores on the current machine. | 16 // Return the number of logical processors/cores on the current machine. |
17 // WARNING: On POSIX, this method uses static variables and is not threadsafe | |
18 // until it's been initialized by being called once without a race. | |
19 static int NumberOfProcessors(); | 17 static int NumberOfProcessors(); |
20 | 18 |
21 // Return the number of bytes of physical memory on the current machine. | 19 // Return the number of bytes of physical memory on the current machine. |
22 static int64 AmountOfPhysicalMemory(); | 20 static int64 AmountOfPhysicalMemory(); |
23 | 21 |
24 // Return the number of megabytes of physical memory on the current machine. | 22 // Return the number of megabytes of physical memory on the current machine. |
25 static int AmountOfPhysicalMemoryMB() { | 23 static int AmountOfPhysicalMemoryMB() { |
26 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); | 24 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); |
27 } | 25 } |
28 | 26 |
(...skipping 10 matching lines...) Expand all Loading... |
39 // TODO: find a better place for GetEnvVar. | 37 // TODO: find a better place for GetEnvVar. |
40 static std::wstring GetEnvVar(const wchar_t* var); | 38 static std::wstring GetEnvVar(const wchar_t* var); |
41 | 39 |
42 // Returns the name of the host operating system. | 40 // Returns the name of the host operating system. |
43 static std::string OperatingSystemName(); | 41 static std::string OperatingSystemName(); |
44 | 42 |
45 // Returns the version of the host operating system. | 43 // Returns the version of the host operating system. |
46 static std::string OperatingSystemVersion(); | 44 static std::string OperatingSystemVersion(); |
47 | 45 |
48 // Retrieves detailed numeric values for the OS version. | 46 // Retrieves detailed numeric values for the OS version. |
49 // WARNING: On OS X, this method uses static variables and is not threadsafe | |
50 // until it's been initialized by being called once without a race. | |
51 // TODO(port): Implement a Linux version of this method and enable the | 47 // TODO(port): Implement a Linux version of this method and enable the |
52 // corresponding unit test. | 48 // corresponding unit test. |
53 static void OperatingSystemVersionNumbers(int32 *major_version, | 49 static void OperatingSystemVersionNumbers(int32 *major_version, |
54 int32 *minor_version, | 50 int32 *minor_version, |
55 int32 *bugfix_version); | 51 int32 *bugfix_version); |
56 | 52 |
57 // Returns the CPU architecture of the system. Exact return value may differ | 53 // Returns the CPU architecture of the system. Exact return value may differ |
58 // across platforms. | 54 // across platforms. |
59 static std::string CPUArchitecture(); | 55 static std::string CPUArchitecture(); |
60 | 56 |
61 // Returns the pixel dimensions of the primary display via the | 57 // Returns the pixel dimensions of the primary display via the |
62 // width and height parameters. | 58 // width and height parameters. |
63 static void GetPrimaryDisplayDimensions(int* width, int* height); | 59 static void GetPrimaryDisplayDimensions(int* width, int* height); |
64 | 60 |
65 // Return the number of displays. | 61 // Return the number of displays. |
66 static int DisplayCount(); | 62 static int DisplayCount(); |
67 | 63 |
68 // Return the smallest amount of memory (in bytes) which the VM system will | 64 // Return the smallest amount of memory (in bytes) which the VM system will |
69 // allocate. | 65 // allocate. |
70 static size_t VMAllocationGranularity(); | 66 static size_t VMAllocationGranularity(); |
71 | |
72 #if defined(OS_MACOSX) | |
73 // Under the OS X Sandbox, our access to the system is limited, this call | |
74 // caches the system info on startup before we turn the Sandbox on. | |
75 // The above functions are all wired up to return the cached value so the rest | |
76 // of the code can call them in the Sandbox without worrying. | |
77 static void CacheSysInfo(); | |
78 #endif | |
79 }; | 67 }; |
80 | 68 |
81 } // namespace base | 69 } // namespace base |
82 | 70 |
83 #endif // BASE_SYS_INFO_H_ | 71 #endif // BASE_SYS_INFO_H_ |
OLD | NEW |