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

Unified Diff: base/sys_info_linux.cc

Issue 28833002: Enable SysInfo::AmountOfPhysicalMemory to be called from within the Linux sandbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/zygote/zygote_main_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_linux.cc
diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc
index acc477134cd38bed2ba37e6add9f84370bfc87ca..8237d1050d3f62a8fcc4e489fc2c2ae9762ea2d8 100644
--- a/base/sys_info_linux.cc
+++ b/base/sys_info_linux.cc
@@ -28,7 +28,13 @@ namespace base {
// static
int64 SysInfo::AmountOfPhysicalMemory() {
- return AmountOfMemory(_SC_PHYS_PAGES);
+ static int64 physical_memory;
+ static bool physical_memory_valid = false;
+ if (!physical_memory_valid) {
jar (doing other things) 2013/10/18 19:24:14 I'm hopeful this is done on only one thread... as
jln (very slow on Chromium) 2013/10/18 21:08:42 Should we just use LazyInstance these things? It's
jar (doing other things) 2013/10/18 22:19:30 +1. If in doubt about multi-threading, I'd rather
+ physical_memory = AmountOfMemory(_SC_PHYS_PAGES);
+ physical_memory_valid = true;
+ }
+ return physical_memory;
}
// static
« no previous file with comments | « no previous file | content/zygote/zygote_main_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698