| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 pos = 0; | 226 pos = 0; |
| 227 while (pos < tokens[1].length() && isspace(tokens[1][pos])) { | 227 while (pos < tokens[1].length() && isspace(tokens[1][pos])) { |
| 228 pos++; | 228 pos++; |
| 229 } | 229 } |
| 230 tokens[1].erase(0, pos); | 230 tokens[1].erase(0, pos); |
| 231 *key = tokens[0]; | 231 *key = tokens[0]; |
| 232 *value = tokens[1]; | 232 *value = tokens[1]; |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 #if !defined(WEBRTC_CHROMIUM_BUILD) | |
| 237 static bool ExpectLineFromStream(FileStream* stream, | |
| 238 std::string* out) { | |
| 239 StreamResult res = stream->ReadLine(out); | |
| 240 if (res != SR_SUCCESS) { | |
| 241 if (res != SR_EOS) { | |
| 242 LOG(LS_ERROR) << "Error when reading from stream"; | |
| 243 } else { | |
| 244 LOG(LS_ERROR) << "Incorrect number of lines in stream"; | |
| 245 } | |
| 246 return false; | |
| 247 } | |
| 248 return true; | |
| 249 } | |
| 250 | |
| 251 static void ExpectEofFromStream(FileStream* stream) { | |
| 252 std::string unused; | |
| 253 StreamResult res = stream->ReadLine(&unused); | |
| 254 if (res == SR_SUCCESS) { | |
| 255 LOG(LS_WARNING) << "Ignoring unexpected extra lines from stream"; | |
| 256 } else if (res != SR_EOS) { | |
| 257 LOG(LS_WARNING) << "Error when checking for extra lines from stream"; | |
| 258 } | |
| 259 } | |
| 260 | |
| 261 #endif | |
| 262 | |
| 263 std::string ReadLinuxUname() { | 236 std::string ReadLinuxUname() { |
| 264 struct utsname buf; | 237 struct utsname buf; |
| 265 if (uname(&buf) < 0) { | 238 if (uname(&buf) < 0) { |
| 266 LOG_ERR(LS_ERROR) << "Can't call uname()"; | 239 LOG_ERR(LS_ERROR) << "Can't call uname()"; |
| 267 return std::string(); | 240 return std::string(); |
| 268 } | 241 } |
| 269 std::ostringstream sstr; | 242 std::ostringstream sstr; |
| 270 sstr << buf.sysname << " " | 243 sstr << buf.sysname << " " |
| 271 << buf.release << " " | 244 << buf.release << " " |
| 272 << buf.version << " " | 245 << buf.version << " " |
| 273 << buf.machine; | 246 << buf.machine; |
| 274 return sstr.str(); | 247 return sstr.str(); |
| 275 } | 248 } |
| 276 | 249 |
| 277 int ReadCpuMaxFreq() { | 250 int ReadCpuMaxFreq() { |
| 278 FileStream fs; | 251 FileStream fs; |
| 279 std::string str; | 252 std::string str; |
| 280 int freq = -1; | 253 int freq = -1; |
| 281 if (!fs.Open(kCpuMaxFreqFile, "r", NULL) || | 254 if (!fs.Open(kCpuMaxFreqFile, "r", NULL) || |
| 282 SR_SUCCESS != fs.ReadLine(&str) || | 255 SR_SUCCESS != fs.ReadLine(&str) || |
| 283 !FromString(str, &freq)) { | 256 !FromString(str, &freq)) { |
| 284 return -1; | 257 return -1; |
| 285 } | 258 } |
| 286 return freq; | 259 return freq; |
| 287 } | 260 } |
| 288 | 261 |
| 289 } // namespace rtc | 262 } // namespace rtc |
| 290 | 263 |
| 291 #endif // defined(WEBRTC_LINUX) | 264 #endif // defined(WEBRTC_LINUX) |
| OLD | NEW |