| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 size_t MaxSharedMemorySize() { | 31 size_t MaxSharedMemorySize() { |
| 32 std::string contents; | 32 std::string contents; |
| 33 base::ReadFileToString(base::FilePath("/proc/sys/kernel/shmmax"), &contents); | 33 base::ReadFileToString(base::FilePath("/proc/sys/kernel/shmmax"), &contents); |
| 34 DCHECK(!contents.empty()); | 34 DCHECK(!contents.empty()); |
| 35 if (!contents.empty() && contents[contents.length() - 1] == '\n') { | 35 if (!contents.empty() && contents[contents.length() - 1] == '\n') { |
| 36 contents.erase(contents.length() - 1); | 36 contents.erase(contents.length() - 1); |
| 37 } | 37 } |
| 38 | 38 |
| 39 int64 limit; | 39 uint64 limit; |
| 40 if (!base::StringToInt64(contents, &limit)) { | 40 if (!base::StringToUint64(contents, &limit)) { |
| 41 limit = 0; | 41 limit = 0; |
| 42 } | 42 } |
| 43 if (limit < 0 || | 43 if (limit > std::numeric_limits<size_t>::max()) { |
| 44 static_cast<uint64>(limit) > std::numeric_limits<size_t>::max()) { | |
| 45 limit = 0; | 44 limit = 0; |
| 46 } | 45 } |
| 47 DCHECK(limit > 0); | 46 DCHECK(limit > 0); |
| 48 return static_cast<size_t>(limit); | 47 return static_cast<size_t>(limit); |
| 49 } | 48 } |
| 50 | 49 |
| 51 base::LazyInstance< | 50 base::LazyInstance< |
| 52 base::internal::LazySysInfoValue<int64, AmountOfPhysicalMemory> >::Leaky | 51 base::internal::LazySysInfoValue<int64, AmountOfPhysicalMemory> >::Leaky |
| 53 g_lazy_physical_memory = LAZY_INSTANCE_INITIALIZER; | 52 g_lazy_physical_memory = LAZY_INSTANCE_INITIALIZER; |
| 54 base::LazyInstance< | 53 base::LazyInstance< |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (line.compare(0, strlen(kCpuModelPrefix), kCpuModelPrefix) == 0) { | 90 if (line.compare(0, strlen(kCpuModelPrefix), kCpuModelPrefix) == 0) { |
| 92 size_t pos = line.find(": "); | 91 size_t pos = line.find(": "); |
| 93 return line.substr(pos + 2); | 92 return line.substr(pos + 2); |
| 94 } | 93 } |
| 95 } | 94 } |
| 96 } | 95 } |
| 97 return std::string(); | 96 return std::string(); |
| 98 } | 97 } |
| 99 | 98 |
| 100 } // namespace base | 99 } // namespace base |
| OLD | NEW |