| 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 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <sys/statvfs.h> | 9 #include <sys/statvfs.h> |
| 10 #include <sys/utsname.h> | 10 #include <sys/utsname.h> |
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 | 12 |
| 13 #if !defined(OS_MACOSX) |
| 14 #include <gdk/gdk.h> |
| 15 #endif |
| 16 |
| 13 #if defined(OS_OPENBSD) | 17 #if defined(OS_OPENBSD) |
| 14 #include <sys/param.h> | 18 #include <sys/param.h> |
| 15 #include <sys/sysctl.h> | 19 #include <sys/sysctl.h> |
| 16 #endif | 20 #endif |
| 17 | 21 |
| 18 #include "base/basictypes.h" | 22 #include "base/basictypes.h" |
| 19 #include "base/file_util.h" | 23 #include "base/file_util.h" |
| 20 #include "base/logging.h" | 24 #include "base/logging.h" |
| 21 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
| 22 | 26 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (uname(&info) < 0) { | 123 if (uname(&info) < 0) { |
| 120 NOTREACHED(); | 124 NOTREACHED(); |
| 121 return ""; | 125 return ""; |
| 122 } | 126 } |
| 123 return std::string(info.machine); | 127 return std::string(info.machine); |
| 124 } | 128 } |
| 125 | 129 |
| 126 #if !defined(OS_MACOSX) | 130 #if !defined(OS_MACOSX) |
| 127 // static | 131 // static |
| 128 void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) { | 132 void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) { |
| 129 // TODO(port): http://crbug.com/21732 | 133 // Note that Bad Things Happen if this isn't called from the UI thread, |
| 130 NOTIMPLEMENTED(); | 134 // but also that there's no way to check that from here. :( |
| 135 GdkScreen* screen = gdk_screen_get_default(); |
| 131 if (width) | 136 if (width) |
| 132 *width = 0; | 137 *width = gdk_screen_get_width(screen); |
| 133 if (height) | 138 if (height) |
| 134 *height = 0; | 139 *height = gdk_screen_get_height(screen); |
| 135 } | 140 } |
| 136 | 141 |
| 137 // static | 142 // static |
| 138 int SysInfo::DisplayCount() { | 143 int SysInfo::DisplayCount() { |
| 139 // TODO(port): http://crbug.com/21732 | 144 // Note that Bad Things Happen if this isn't called from the UI thread, |
| 140 NOTIMPLEMENTED(); | 145 // but also that there's no way to check that from here. :( |
| 141 return 1; | 146 |
| 147 // This query is kinda bogus for Linux -- do we want number of X screens? |
| 148 // The number of monitors Xinerama has? We'll just use whatever GDK uses. |
| 149 GdkScreen* screen = gdk_screen_get_default(); |
| 150 return gdk_screen_get_n_monitors(screen); |
| 142 } | 151 } |
| 143 #endif | 152 #endif |
| 144 | 153 |
| 145 // static | 154 // static |
| 146 size_t SysInfo::VMAllocationGranularity() { | 155 size_t SysInfo::VMAllocationGranularity() { |
| 147 return getpagesize(); | 156 return getpagesize(); |
| 148 } | 157 } |
| 149 | 158 |
| 150 #if defined(OS_LINUX) | 159 #if defined(OS_LINUX) |
| 151 // static | 160 // static |
| 152 size_t SysInfo::MaxSharedMemorySize() { | 161 size_t SysInfo::MaxSharedMemorySize() { |
| 153 static size_t limit; | 162 static size_t limit; |
| 154 static bool limit_valid = false; | 163 static bool limit_valid = false; |
| 155 | 164 |
| 156 if (!limit_valid) { | 165 if (!limit_valid) { |
| 157 std::string contents; | 166 std::string contents; |
| 158 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); | 167 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); |
| 159 limit = strtoul(contents.c_str(), NULL, 0); | 168 limit = strtoul(contents.c_str(), NULL, 0); |
| 160 limit_valid = true; | 169 limit_valid = true; |
| 161 } | 170 } |
| 162 | 171 |
| 163 return limit; | 172 return limit; |
| 164 } | 173 } |
| 165 #endif | 174 #endif |
| 166 | 175 |
| 167 } // namespace base | 176 } // namespace base |
| OLD | NEW |