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

Side by Side Diff: base/sys_info_chromeos.cc

Issue 2489853002: Added function to provide the short board name of the device (Closed)
Patch Set: Fixed review comments Created 4 years 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 unified diff | Download patch
OLDNEW
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // static 193 // static
194 std::string SysInfo::GetLsbReleaseBoard() { 194 std::string SysInfo::GetLsbReleaseBoard() {
195 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD"; 195 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD";
196 std::string board; 196 std::string board;
197 if (!GetLsbReleaseValue(kMachineInfoBoard, &board)) 197 if (!GetLsbReleaseValue(kMachineInfoBoard, &board))
198 board = "unknown"; 198 board = "unknown";
199 return board; 199 return board;
200 } 200 }
201 201
202 // static 202 // static
203 std::string SysInfo::GetStrippedReleaseBoard() {
204 std::string board = GetLsbReleaseBoard();
205 const size_t index = board.find("-signed-");
206 if (index != std::string::npos) {
Alexei Svitkine (slow) 2016/11/28 16:03:28 Nit: No {}
igorcov 2016/11/28 16:37:08 Done.
207 board.resize(index);
208 }
209
210 return base::ToLowerASCII(board);
211 }
212
213 // static
203 Time SysInfo::GetLsbReleaseTime() { 214 Time SysInfo::GetLsbReleaseTime() {
204 return GetChromeOSVersionInfo().lsb_release_time(); 215 return GetChromeOSVersionInfo().lsb_release_time();
205 } 216 }
206 217
207 // static 218 // static
208 bool SysInfo::IsRunningOnChromeOS() { 219 bool SysInfo::IsRunningOnChromeOS() {
209 return GetChromeOSVersionInfo().is_running_on_chromeos(); 220 return GetChromeOSVersionInfo().is_running_on_chromeos();
210 } 221 }
211 222
212 // static 223 // static
213 void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release, 224 void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release,
214 const Time& lsb_release_time) { 225 const Time& lsb_release_time) {
215 std::unique_ptr<Environment> env(Environment::Create()); 226 std::unique_ptr<Environment> env(Environment::Create());
216 env->SetVar(kLsbReleaseKey, lsb_release); 227 env->SetVar(kLsbReleaseKey, lsb_release);
217 env->SetVar(kLsbReleaseTimeKey, 228 env->SetVar(kLsbReleaseTimeKey,
218 DoubleToString(lsb_release_time.ToDoubleT())); 229 DoubleToString(lsb_release_time.ToDoubleT()));
219 g_chrome_os_version_info.Get().Parse(); 230 g_chrome_os_version_info.Get().Parse();
220 } 231 }
221 232
222 } // namespace base 233 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698