| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 void Parse() { | 55 void Parse() { |
| 56 lsb_release_map_.clear(); | 56 lsb_release_map_.clear(); |
| 57 major_version_ = 0; | 57 major_version_ = 0; |
| 58 minor_version_ = 0; | 58 minor_version_ = 0; |
| 59 bugfix_version_ = 0; | 59 bugfix_version_ = 0; |
| 60 is_running_on_chromeos_ = false; | 60 is_running_on_chromeos_ = false; |
| 61 | 61 |
| 62 std::string lsb_release, lsb_release_time_str; | 62 std::string lsb_release, lsb_release_time_str; |
| 63 scoped_ptr<Environment> env(Environment::Create()); | 63 std::unique_ptr<Environment> env(Environment::Create()); |
| 64 bool parsed_from_env = | 64 bool parsed_from_env = |
| 65 env->GetVar(kLsbReleaseKey, &lsb_release) && | 65 env->GetVar(kLsbReleaseKey, &lsb_release) && |
| 66 env->GetVar(kLsbReleaseTimeKey, &lsb_release_time_str); | 66 env->GetVar(kLsbReleaseTimeKey, &lsb_release_time_str); |
| 67 if (parsed_from_env) { | 67 if (parsed_from_env) { |
| 68 double us = 0; | 68 double us = 0; |
| 69 if (StringToDouble(lsb_release_time_str, &us)) | 69 if (StringToDouble(lsb_release_time_str, &us)) |
| 70 lsb_release_time_ = Time::FromDoubleT(us); | 70 lsb_release_time_ = Time::FromDoubleT(us); |
| 71 } else { | 71 } else { |
| 72 // If the LSB_RELEASE and LSB_RELEASE_TIME environment variables are not | 72 // If the LSB_RELEASE and LSB_RELEASE_TIME environment variables are not |
| 73 // set, fall back to a blocking read of the lsb_release file. This should | 73 // set, fall back to a blocking read of the lsb_release file. This should |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 | 206 |
| 207 // static | 207 // static |
| 208 bool SysInfo::IsRunningOnChromeOS() { | 208 bool SysInfo::IsRunningOnChromeOS() { |
| 209 return GetChromeOSVersionInfo().is_running_on_chromeos(); | 209 return GetChromeOSVersionInfo().is_running_on_chromeos(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // static | 212 // static |
| 213 void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release, | 213 void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release, |
| 214 const Time& lsb_release_time) { | 214 const Time& lsb_release_time) { |
| 215 scoped_ptr<Environment> env(Environment::Create()); | 215 std::unique_ptr<Environment> env(Environment::Create()); |
| 216 env->SetVar(kLsbReleaseKey, lsb_release); | 216 env->SetVar(kLsbReleaseKey, lsb_release); |
| 217 env->SetVar(kLsbReleaseTimeKey, | 217 env->SetVar(kLsbReleaseTimeKey, |
| 218 DoubleToString(lsb_release_time.ToDoubleT())); | 218 DoubleToString(lsb_release_time.ToDoubleT())); |
| 219 g_chrome_os_version_info.Get().Parse(); | 219 g_chrome_os_version_info.Get().Parse(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace base | 222 } // namespace base |
| OLD | NEW |