Index: base/cpu.cc |
diff --git a/base/cpu.cc b/base/cpu.cc |
index 25328167425d4c0a242e0bfccaa47845737e81f9..848208f7c1024fb9dda6d6e15e8a8b17628e538f 100644 |
--- a/base/cpu.cc |
+++ b/base/cpu.cc |
@@ -16,7 +16,6 @@ |
#if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) |
#include "base/files/file_util.h" |
-#include "base/lazy_instance.h" |
#endif |
#if defined(ARCH_CPU_X86_FAMILY) |
@@ -94,9 +93,8 @@ uint64_t _xgetbv(uint32_t xcr) { |
#endif // ARCH_CPU_X86_FAMILY |
#if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) |
-class LazyCpuInfoValue { |
- public: |
- LazyCpuInfoValue() { |
+std::string* CpuInfoBrand() { |
+ static std::string* brand = []() { |
// This function finds the value from /proc/cpuinfo under the key "model |
// name" or "Processor". "model name" is used in Linux 3.8 and later (3.7 |
// and later for arm64) and is shown once per CPU. "Processor" is used in |
@@ -109,30 +107,23 @@ class LazyCpuInfoValue { |
ReadFileToString(FilePath("/proc/cpuinfo"), &contents); |
DCHECK(!contents.empty()); |
if (contents.empty()) { |
- return; |
+ return new std::string(); |
} |
std::istringstream iss(contents); |
std::string line; |
while (std::getline(iss, line)) { |
- if (brand_.empty() && |
- (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0 || |
+ if ((line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0 || |
line.compare(0, strlen(kProcessorPrefix), kProcessorPrefix) == 0)) { |
- brand_.assign(line.substr(strlen(kModelNamePrefix))); |
+ return new std::string(line.substr(strlen(kModelNamePrefix))); |
} |
} |
- } |
- |
- const std::string& brand() const { return brand_; } |
- private: |
- std::string brand_; |
- DISALLOW_COPY_AND_ASSIGN(LazyCpuInfoValue); |
-}; |
- |
-base::LazyInstance<LazyCpuInfoValue>::Leaky g_lazy_cpuinfo = |
- LAZY_INSTANCE_INITIALIZER; |
+ return new std::string(); |
+ }(); |
+ return brand; |
+} |
#endif // defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || |
// defined(OS_LINUX)) |
@@ -221,7 +212,7 @@ void CPU::Initialize() { |
has_non_stop_time_stamp_counter_ = (cpu_info[3] & (1 << 8)) != 0; |
} |
#elif defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) |
- cpu_brand_.assign(g_lazy_cpuinfo.Get().brand()); |
+ cpu_brand_.assign(*CpuInfoBrand()); |
#endif |
} |