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

Unified Diff: chrome/browser/chromeos/version_loader.cc

Issue 799683003: Move chromeos::version_loader to src/chromeos/system (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/version_loader.h ('k') | chrome/browser/chromeos/version_loader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/version_loader.cc
diff --git a/chrome/browser/chromeos/version_loader.cc b/chrome/browser/chromeos/version_loader.cc
deleted file mode 100644
index 84346340a901f825531e8972b8a9e77413d5d02f..0000000000000000000000000000000000000000
--- a/chrome/browser/chromeos/version_loader.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/chromeos/version_loader.h"
-
-#include <vector>
-
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/location.h"
-#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/sys_info.h"
-#include "base/time/time.h"
-
-namespace chromeos {
-namespace version_loader {
-
-namespace {
-
-// Beginning of line we look for that gives full version number.
-// Format: x.x.xx.x (Developer|Official build extra info) board info
-const char kFullVersionKey[] = "CHROMEOS_RELEASE_DESCRIPTION";
-
-// Same but for short version (x.x.xx.x).
-const char kVersionKey[] = "CHROMEOS_RELEASE_VERSION";
-
-// Beginning of line we look for that gives the firmware version.
-const char kFirmwarePrefix[] = "version";
-
-// File to look for firmware number in.
-const char kPathFirmware[] = "/var/log/bios_info.txt";
-
-} // namespace
-
-std::string GetVersion(VersionFormat format) {
- std::string version;
- std::string key = (format == VERSION_FULL ?
- kFullVersionKey : kVersionKey);
- if (!base::SysInfo::GetLsbReleaseValue(key, &version)) {
- LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS())
- << "No LSB version key: " << key;
- version = "0.0.0.0";
- }
- if (format == VERSION_SHORT_WITH_DATE) {
- base::Time::Exploded ctime;
- base::SysInfo::GetLsbReleaseTime().UTCExplode(&ctime);
- version += base::StringPrintf("-%02u.%02u.%02u",
- ctime.year % 100,
- ctime.month,
- ctime.day_of_month);
- }
-
- return version;
-}
-
-std::string GetFirmware() {
- std::string firmware;
- std::string contents;
- const base::FilePath file_path(kPathFirmware);
- if (base::ReadFileToString(file_path, &contents)) {
- firmware = ParseFirmware(contents);
- }
- return firmware;
-}
-
-std::string ParseFirmware(const std::string& contents) {
- // The file contains lines such as:
- // vendor | ...
- // version | ...
- // release_date | ...
- // We don't make any assumption that the spaces between "version" and "|" is
- // fixed. So we just match kFirmwarePrefix at the start of the line and find
- // the first character that is not "|" or space
-
- std::vector<std::string> lines;
- base::SplitString(contents, '\n', &lines);
- for (size_t i = 0; i < lines.size(); ++i) {
- if (StartsWithASCII(lines[i], kFirmwarePrefix, false)) {
- std::string str = lines[i].substr(std::string(kFirmwarePrefix).size());
- size_t found = str.find_first_not_of("| ");
- if (found != std::string::npos)
- return str.substr(found);
- }
- }
- return std::string();
-}
-
-} // namespace version_loader
-} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/version_loader.h ('k') | chrome/browser/chromeos/version_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698