summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/sys_info.h34
-rw-r--r--base/sys_info_chromeos.cc221
-rw-r--r--base/sys_info_unittest.cc58
-rw-r--r--chrome/app/chrome_main_delegate.cc8
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc8
-rw-r--r--chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc12
-rw-r--r--chrome/browser/chromeos/extensions/info_private_api.cc7
-rw-r--r--chrome/browser/chromeos/external_metrics.cc11
-rw-r--r--chrome/browser/chromeos/system/statistics_provider.cc37
-rw-r--r--chrome/browser/chromeos/system/statistics_provider.h3
-rw-r--r--chrome/browser/chromeos/system_logs/lsb_release_log_source.cc76
-rw-r--r--chrome/browser/chromeos/system_logs/lsb_release_log_source.h13
-rw-r--r--chrome/browser/chromeos/system_logs/lsb_release_log_source_unittest.cc59
-rw-r--r--chrome/browser/chromeos/version_loader.cc83
-rw-r--r--chrome/browser/chromeos/version_loader.h20
-rw-r--r--chrome/browser/chromeos/version_loader_unittest.cc55
-rw-r--r--chrome/browser/policy/cloud/device_management_service.cc8
-rw-r--r--chrome/browser/ui/webui/help/help_handler.cc48
-rw-r--r--chrome/browser/ui/webui/help/help_handler.h3
-rw-r--r--chrome/chrome_tests_unit.gypi1
20 files changed, 264 insertions, 501 deletions
diff --git a/base/sys_info.h b/base/sys_info.h
index 38462ed..564832d 100644
--- a/base/sys_info.h
+++ b/base/sys_info.h
@@ -5,11 +5,13 @@
#ifndef BASE_SYS_INFO_H_
#define BASE_SYS_INFO_H_
+#include <map>
#include <string>
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/files/file_path.h"
+#include "base/time/time.h"
#include "build/build_config.h"
namespace base {
@@ -78,19 +80,25 @@ class BASE_EXPORT SysInfo {
#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
#if defined(OS_CHROMEOS)
- // Returns the name of the version entry we wish to look up in the
- // Linux Standard Base release information file.
- static std::string GetLinuxStandardBaseVersionKey();
-
- // Parses /etc/lsb-release to get version information for Google Chrome OS.
- // Declared here so it can be exposed for unit testing.
- static void ParseLsbRelease(const std::string& lsb_release,
- int32* major_version,
- int32* minor_version,
- int32* bugfix_version);
-
- // Returns the path to the lsb-release file.
- static FilePath GetLsbReleaseFilePath();
+ typedef std::map<std::string, std::string> LsbReleaseMap;
+
+ // Returns the contents of /etc/lsb-release as a map.
+ static const LsbReleaseMap& GetLsbReleaseMap();
+
+ // If |key| is present in the LsbReleaseMap, sets |value| and returns true.
+ static bool GetLsbReleaseValue(const std::string& key, std::string* value);
+
+ // Convenience function for GetLsbReleaseValue("CHROMEOS_RELEASE_BOARD",...).
+ // Returns "unknown" if CHROMEOS_RELEASE_BOARD is not set.
+ static std::string GetLsbReleaseBoard();
+
+ // Returns the creation time of /etc/lsb-release. (Used to get the date and
+ // time of the Chrome OS build).
+ static Time GetLsbReleaseTime();
+
+ // Test method to force re-parsing of lsb-release.
+ static void SetChromeOSVersionInfoForTest(const std::string& lsb_release,
+ const Time& lsb_release_time);
#endif // defined(OS_CHROMEOS)
#if defined(OS_ANDROID)
diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc
index 4c1a7af..9d7505e 100644
--- a/base/sys_info_chromeos.cc
+++ b/base/sys_info_chromeos.cc
@@ -5,115 +5,190 @@
#include "base/sys_info.h"
#include "base/basictypes.h"
+#include "base/environment.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
+#include "base/strings/string_split.h"
#include "base/strings/string_tokenizer.h"
+#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
namespace base {
-static const char* kLinuxStandardBaseVersionKeys[] = {
+namespace {
+
+const char* kLinuxStandardBaseVersionKeys[] = {
"CHROMEOS_RELEASE_VERSION",
"GOOGLE_RELEASE",
"DISTRIB_RELEASE",
- NULL
};
+const size_t kLinuxStandardBaseVersionKeysLength =
+ arraysize(kLinuxStandardBaseVersionKeys);
const char kLinuxStandardBaseReleaseFile[] = "/etc/lsb-release";
-struct ChromeOSVersionNumbers {
- ChromeOSVersionNumbers()
- : major_version(0),
- minor_version(0),
- bugfix_version(0),
- parsed(false) {
+const char kLsbReleaseKey[] = "LSB_RELEASE";
+const char kLsbReleaseTimeKey[] = "LSB_RELEASE_TIME"; // Seconds since epoch
+
+const char kLsbReleaseSourceKey[] = "lsb-release";
+const char kLsbReleaseSourceEnv[] = "env";
+const char kLsbReleaseSourceFile[] = "file";
+
+class ChromeOSVersionInfo {
+ public:
+ ChromeOSVersionInfo() {
+ Parse();
+ }
+
+ void Parse() {
+ lsb_release_map_.clear();
+ major_version_ = 0;
+ minor_version_ = 0;
+ bugfix_version_ = 0;
+
+ std::string lsb_release, lsb_release_time_str;
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ bool parsed_from_env =
+ env->GetVar(kLsbReleaseKey, &lsb_release) &&
+ env->GetVar(kLsbReleaseTimeKey, &lsb_release_time_str);
+ if (parsed_from_env) {
+ double us = 0;
+ if (StringToDouble(lsb_release_time_str, &us))
+ lsb_release_time_ = base::Time::FromDoubleT(us);
+ } else {
+ // If the LSB_RELEASE and LSB_RELEASE_TIME environment variables are not
+ // set, fall back to a blocking read of the lsb_release file. This should
+ // only happen in non Chrome OS environments.
+ ThreadRestrictions::ScopedAllowIO allow_io;
+ FilePath path(kLinuxStandardBaseReleaseFile);
+ ReadFileToString(path, &lsb_release);
+ base::PlatformFileInfo fileinfo;
+ if (file_util::GetFileInfo(path, &fileinfo))
+ lsb_release_time_ = fileinfo.creation_time;
+ }
+ ParseLsbRelease(lsb_release);
+ // For debugging:
+ lsb_release_map_[kLsbReleaseSourceKey] =
+ parsed_from_env ? kLsbReleaseSourceEnv : kLsbReleaseSourceFile;
+ }
+
+ bool GetLsbReleaseValue(const std::string& key, std::string* value) {
+ SysInfo::LsbReleaseMap::const_iterator iter = lsb_release_map_.find(key);
+ if (iter == lsb_release_map_.end())
+ return false;
+ *value = iter->second;
+ return true;
}
- int32 major_version;
- int32 minor_version;
- int32 bugfix_version;
- bool parsed;
+ void GetVersionNumbers(int32* major_version,
+ int32* minor_version,
+ int32* bugfix_version) {
+ *major_version = major_version_;
+ *minor_version = minor_version_;
+ *bugfix_version = bugfix_version_;
+ }
+
+ const base::Time& lsb_release_time() const { return lsb_release_time_; }
+ const SysInfo::LsbReleaseMap& lsb_release_map() const {
+ return lsb_release_map_;
+ }
+
+ private:
+ void ParseLsbRelease(const std::string& lsb_release) {
+ // Parse and cache lsb_release key pairs. There should only be a handful
+ // of entries so the overhead for this will be small, and it can be
+ // useful for debugging.
+ std::vector<std::pair<std::string, std::string> > pairs;
+ base::SplitStringIntoKeyValuePairs(lsb_release, '=', '\n', &pairs);
+ for (size_t i = 0; i < pairs.size(); ++i) {
+ std::string key, value;
+ TrimWhitespaceASCII(pairs[i].first, TRIM_ALL, &key);
+ TrimWhitespaceASCII(pairs[i].second, TRIM_ALL, &value);
+ if (key.empty())
+ continue;
+ lsb_release_map_[key] = value;
+ }
+ // Parse the version from the first matching recognized version key.
+ std::string version;
+ for (size_t i = 0; i < kLinuxStandardBaseVersionKeysLength; ++i) {
+ std::string key = kLinuxStandardBaseVersionKeys[i];
+ if (GetLsbReleaseValue(key, &version) && !version.empty())
+ break;
+ }
+ StringTokenizer tokenizer(version, ".");
+ if (tokenizer.GetNext()) {
+ StringToInt(StringPiece(tokenizer.token_begin(), tokenizer.token_end()),
+ &major_version_);
+ }
+ if (tokenizer.GetNext()) {
+ StringToInt(StringPiece(tokenizer.token_begin(), tokenizer.token_end()),
+ &minor_version_);
+ }
+ if (tokenizer.GetNext()) {
+ StringToInt(StringPiece(tokenizer.token_begin(), tokenizer.token_end()),
+ &bugfix_version_);
+ }
+ }
+
+ base::Time lsb_release_time_;
+ SysInfo::LsbReleaseMap lsb_release_map_;
+ int32 major_version_;
+ int32 minor_version_;
+ int32 bugfix_version_;
};
-static LazyInstance<ChromeOSVersionNumbers>
- g_chrome_os_version_numbers = LAZY_INSTANCE_INITIALIZER;
+static LazyInstance<ChromeOSVersionInfo>
+ g_chrome_os_version_info = LAZY_INSTANCE_INITIALIZER;
+
+ChromeOSVersionInfo& GetChromeOSVersionInfo() {
+ return g_chrome_os_version_info.Get();
+}
+
+} // namespace
// static
void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
int32* minor_version,
int32* bugfix_version) {
- if (!g_chrome_os_version_numbers.Get().parsed) {
- // The other implementations of SysInfo don't block on the disk.
- // See http://code.google.com/p/chromium/issues/detail?id=60394
- // Perhaps the caller ought to cache this?
- // Temporary allowing while we work the bug out.
- ThreadRestrictions::ScopedAllowIO allow_io;
-
- FilePath path(kLinuxStandardBaseReleaseFile);
- std::string contents;
- if (ReadFileToString(path, &contents)) {
- g_chrome_os_version_numbers.Get().parsed = true;
- ParseLsbRelease(contents,
- &(g_chrome_os_version_numbers.Get().major_version),
- &(g_chrome_os_version_numbers.Get().minor_version),
- &(g_chrome_os_version_numbers.Get().bugfix_version));
- }
- }
- *major_version = g_chrome_os_version_numbers.Get().major_version;
- *minor_version = g_chrome_os_version_numbers.Get().minor_version;
- *bugfix_version = g_chrome_os_version_numbers.Get().bugfix_version;
+ return GetChromeOSVersionInfo().GetVersionNumbers(
+ major_version, minor_version, bugfix_version);
}
// static
-std::string SysInfo::GetLinuxStandardBaseVersionKey() {
- return std::string(kLinuxStandardBaseVersionKeys[0]);
+const SysInfo::LsbReleaseMap& SysInfo::GetLsbReleaseMap() {
+ return GetChromeOSVersionInfo().lsb_release_map();
}
// static
-void SysInfo::ParseLsbRelease(const std::string& lsb_release,
- int32* major_version,
- int32* minor_version,
- int32* bugfix_version) {
- size_t version_key_index = std::string::npos;
- for (int i = 0; kLinuxStandardBaseVersionKeys[i] != NULL; ++i) {
- version_key_index = lsb_release.find(kLinuxStandardBaseVersionKeys[i]);
- if (std::string::npos != version_key_index) {
- break;
- }
- }
- if (std::string::npos == version_key_index) {
- return;
- }
+bool SysInfo::GetLsbReleaseValue(const std::string& key, std::string* value) {
+ return GetChromeOSVersionInfo().GetLsbReleaseValue(key, value);
+}
- size_t start_index = lsb_release.find_first_of('=', version_key_index);
- start_index++; // Move past '='.
- size_t length = lsb_release.find_first_of('\n', start_index) - start_index;
- std::string version = lsb_release.substr(start_index, length);
- StringTokenizer tokenizer(version, ".");
- for (int i = 0; i < 3 && tokenizer.GetNext(); ++i) {
- if (0 == i) {
- StringToInt(StringPiece(tokenizer.token_begin(),
- tokenizer.token_end()),
- major_version);
- *minor_version = *bugfix_version = 0;
- } else if (1 == i) {
- StringToInt(StringPiece(tokenizer.token_begin(),
- tokenizer.token_end()),
- minor_version);
- } else { // 2 == i
- StringToInt(StringPiece(tokenizer.token_begin(),
- tokenizer.token_end()),
- bugfix_version);
- }
- }
+// static
+std::string SysInfo::GetLsbReleaseBoard() {
+ const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD";
+ std::string board;
+ if (!GetLsbReleaseValue(kMachineInfoBoard, &board))
+ board = "unknown";
+ return board;
+}
+
+// static
+base::Time SysInfo::GetLsbReleaseTime() {
+ return GetChromeOSVersionInfo().lsb_release_time();
}
// static
-FilePath SysInfo::GetLsbReleaseFilePath() {
- return FilePath(kLinuxStandardBaseReleaseFile);
+void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release,
+ const Time& lsb_release_time) {
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ env->SetVar(kLsbReleaseKey, lsb_release);
+ env->SetVar(kLsbReleaseTimeKey,
+ base::DoubleToString(lsb_release_time.ToDoubleT()));
+ g_chrome_os_version_info.Get().Parse();
}
} // namespace base
diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc
index 8153f2b..d123357 100644
--- a/base/sys_info_unittest.cc
+++ b/base/sys_info_unittest.cc
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/environment.h"
#include "base/file_util.h"
#include "base/sys_info.h"
#include "base/threading/platform_thread.h"
+#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -37,7 +39,7 @@ TEST_F(SysInfoTest, AmountOfFreeDiskSpace) {
<< tmp_path.value();
}
-#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
+#if defined(OS_WIN) || defined(OS_MACOSX)
TEST_F(SysInfoTest, OperatingSystemVersionNumbers) {
int32 os_major_version = -1;
int32 os_minor_version = -1;
@@ -62,17 +64,18 @@ TEST_F(SysInfoTest, Uptime) {
}
#if defined(OS_CHROMEOS)
+
TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) {
int32 os_major_version = -1;
int32 os_minor_version = -1;
int32 os_bugfix_version = -1;
- std::string lsb_release("FOO=1234123.34.5\n");
- lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey());
- lsb_release.append("=1.2.3.4\n");
- base::SysInfo::ParseLsbRelease(lsb_release,
- &os_major_version,
- &os_minor_version,
- &os_bugfix_version);
+ const char* kLsbRelease =
+ "FOO=1234123.34.5\n"
+ "CHROMEOS_RELEASE_VERSION=1.2.3.4\n";
+ base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
+ base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
+ &os_minor_version,
+ &os_bugfix_version);
EXPECT_EQ(1, os_major_version);
EXPECT_EQ(2, os_minor_version);
EXPECT_EQ(3, os_bugfix_version);
@@ -82,13 +85,13 @@ TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) {
int32 os_major_version = -1;
int32 os_minor_version = -1;
int32 os_bugfix_version = -1;
- std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey());
- lsb_release.append("=1.2.3.4\n");
- lsb_release.append("FOO=1234123.34.5\n");
- base::SysInfo::ParseLsbRelease(lsb_release,
- &os_major_version,
- &os_minor_version,
- &os_bugfix_version);
+ const char* kLsbRelease =
+ "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"
+ "FOO=1234123.34.5\n";
+ base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
+ base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
+ &os_minor_version,
+ &os_bugfix_version);
EXPECT_EQ(1, os_major_version);
EXPECT_EQ(2, os_minor_version);
EXPECT_EQ(3, os_bugfix_version);
@@ -98,14 +101,23 @@ TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) {
int32 os_major_version = -1;
int32 os_minor_version = -1;
int32 os_bugfix_version = -1;
- std::string lsb_release("FOO=1234123.34.5\n");
- base::SysInfo::ParseLsbRelease(lsb_release,
- &os_major_version,
- &os_minor_version,
- &os_bugfix_version);
- EXPECT_EQ(-1, os_major_version);
- EXPECT_EQ(-1, os_minor_version);
- EXPECT_EQ(-1, os_bugfix_version);
+ const char* kLsbRelease = "FOO=1234123.34.5\n";
+ base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
+ base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
+ &os_minor_version,
+ &os_bugfix_version);
+ EXPECT_EQ(0, os_major_version);
+ EXPECT_EQ(0, os_minor_version);
+ EXPECT_EQ(0, os_bugfix_version);
+}
+
+TEST_F(SysInfoTest, GoogleChromeOSLsbReleaseTime) {
+ const char* kLsbRelease = "CHROMEOS_RELEASE_VERSION=1.2.3.4";
+ base::Time lsb_release_time = base::Time::Now();
+ base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, lsb_release_time);
+ base::Time parsed_lsb_release_time = base::SysInfo::GetLsbReleaseTime();
+ EXPECT_EQ(lsb_release_time.ToDoubleT(),
+ parsed_lsb_release_time.ToDoubleT());
}
#endif // OS_CHROMEOS
diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc
index 08b9e43..2ab55a5 100644
--- a/chrome/app/chrome_main_delegate.cc
+++ b/chrome/app/chrome_main_delegate.cc
@@ -744,14 +744,6 @@ void ChromeMainDelegate::PreSandboxStartup() {
#endif
}
#endif
-
-#if defined(OS_CHROMEOS)
- // Read and cache ChromeOS version from file,
- // to be used from inside the sandbox.
- int32 major_version, minor_version, bugfix_version;
- base::SysInfo::OperatingSystemVersionNumbers(
- &major_version, &minor_version, &bugfix_version);
-#endif
}
void ChromeMainDelegate::SandboxInitialized(const std::string& process_type) {
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index d1a6d86..fd251f28 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -21,6 +21,7 @@
#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
+#include "base/sys_info.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part_chromeos.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -388,6 +389,13 @@ void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() {
// channel info is read and made available early.
system::StatisticsProvider::GetInstance()->Init();
+#if defined(GOOGLE_CHROME_BUILD)
+ const char kChromeOSReleaseTrack[] = "CHROMEOS_RELEASE_TRACK";
+ std::string channel;
+ if (base::SysInfo::GetLsbReleaseValue(kChromeOSReleaseTrack, &channel))
+ chrome::VersionInfo::SetChannel(channel);
+#endif
+
ChromeBrowserMainPartsLinux::PreEarlyInitialization();
}
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc
index fb1d24e..71fcde5 100644
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/chromeos/extensions/file_manager/private_api_strings.h"
+#include "base/sys_info.h"
#include "chrome/browser/chromeos/file_manager/open_with_browser.h"
-#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/common/extensions/extension_l10n_util.h"
#include "grit/app_locale_settings.h"
#include "grit/generated_resources.h"
@@ -516,14 +516,8 @@ bool FileBrowserPrivateGetStringsFunction::RunImpl() {
webui::SetFontAndTextDirection(dict);
- std::string board;
- chromeos::system::StatisticsProvider* provider =
- chromeos::system::StatisticsProvider::GetInstance();
- if (!provider->GetMachineStatistic(chromeos::system::kMachineInfoBoard,
- &board)) {
- board = "unknown";
- }
- dict->SetString(chromeos::system::kMachineInfoBoard, board);
+ dict->SetString("CHROMEOS_RELEASE_BOARD",
+ base::SysInfo::GetLsbReleaseBoard());
dict->SetString("UI_LOCALE", extension_l10n_util::CurrentLocaleOrDefault());
diff --git a/chrome/browser/chromeos/extensions/info_private_api.cc b/chrome/browser/chromeos/extensions/info_private_api.cc
index 7f31d3b..f7b54fc 100644
--- a/chrome/browser/chromeos/extensions/info_private_api.cc
+++ b/chrome/browser/chromeos/extensions/info_private_api.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/extensions/info_private_api.h"
+#include "base/sys_info.h"
#include "base/values.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
@@ -79,11 +80,7 @@ base::Value* ChromeosInfoPrivateGetFunction::GetValue(
return new base::StringValue(
chromeos::StartupUtils::GetInitialLocale());
} else if (property_name == kPropertyBoard) {
- std::string board;
- chromeos::system::StatisticsProvider* provider =
- chromeos::system::StatisticsProvider::GetInstance();
- provider->GetMachineStatistic(chromeos::system::kMachineInfoBoard, &board);
- return new base::StringValue(board);
+ return new base::StringValue(base::SysInfo::GetLsbReleaseBoard());
} else if (property_name == kPropertyOwner) {
return Value::CreateBooleanValue(
chromeos::UserManager::Get()->IsCurrentUserOwner());
diff --git a/chrome/browser/chromeos/external_metrics.cc b/chrome/browser/chromeos/external_metrics.cc
index b0ae298..55d0d3b 100644
--- a/chrome/browser/chromeos/external_metrics.cc
+++ b/chrome/browser/chromeos/external_metrics.cc
@@ -97,17 +97,8 @@ void SetupProgressiveScanFieldTrial() {
}
// Finds out if we're on a 2GB Parrot.
-//
-// This code reads and parses /etc/lsb-release. There are at least four other
-// places that open and parse /etc/lsb-release, and I wish I could fix the
-// mess. At least this code is temporary.
-
bool Is2GBParrot() {
- base::FilePath path("/etc/lsb-release");
- std::string contents;
- if (!base::ReadFileToString(path, &contents))
- return false;
- if (contents.find("CHROMEOS_RELEASE_BOARD=parrot") == std::string::npos)
+ if (base::SysInfo::GetLsbReleaseBoard() != "parrot")
return false;
// There are 2GB and 4GB models.
return base::SysInfo::AmountOfPhysicalMemory() <= 2LL * 1024 * 1024 * 1024;
diff --git a/chrome/browser/chromeos/system/statistics_provider.cc b/chrome/browser/chromeos/system/statistics_provider.cc
index 8680f94..6de3b6f 100644
--- a/chrome/browser/chromeos/system/statistics_provider.cc
+++ b/chrome/browser/chromeos/system/statistics_provider.cc
@@ -20,11 +20,6 @@
#include "chromeos/system/name_value_pairs_parser.h"
#include "content/public/browser/browser_thread.h"
-#if defined(GOOGLE_CHROME_BUILD)
-// TODO(phajdan.jr): Drop that dependency, http://crbug.com/180711 .
-#include "chrome/common/chrome_version_info.h"
-#endif
-
using content::BrowserThread;
namespace chromeos {
@@ -56,11 +51,6 @@ const char kEchoCouponFile[] = "/var/cache/echo/vpd_echo.txt";
const char kEchoCouponEq[] = "=";
const char kEchoCouponDelim[] = "\n";
-// File to get machine OS info from, and key/value delimiters of the file.
-const char kMachineOSInfoFile[] = "/etc/lsb-release";
-const char kMachineOSInfoEq[] = "=";
-const char kMachineOSInfoDelim[] = "\n";
-
// File to get VPD info from, and key/value delimiters of the file.
const char kVpdFile[] = "/var/log/vpd_2.0.txt";
const char kVpdEq[] = "=";
@@ -78,8 +68,6 @@ const CommandLine::CharType kOemManifestFilePath[] =
// Key values for GetMachineStatistic()/GetMachineFlag() calls.
const char kDevSwitchBootMode[] = "devsw_boot";
const char kHardwareClass[] = "hardware_class";
-const char kMachineInfoBoard[] =
- "CHROMEOS_RELEASE_BOARD";
const char kOffersCouponCodeKey[] = "ubind_attribute";
const char kOffersGroupCodeKey[] = "gbind_attribute";
const char kOemCanExitEnterpriseEnrollmentKey[] =
@@ -113,13 +101,6 @@ class StatisticsProviderImpl : public StatisticsProvider {
typedef std::map<std::string, bool> MachineFlags;
friend struct DefaultSingletonTraits<StatisticsProviderImpl>;
- // Loads the machine info file, which is necessary to get the Chrome channel.
- // Treat MachineOSInfoFile specially, as distribution channel information
- // (stable, beta, dev, canary) is required at earlier stage than everything
- // else. Rather than posting a delayed task, read and parse the machine OS
- // info file immediately.
- void LoadMachineOSInfoFile();
-
// Loads the machine statistcs by examining the system.
void LoadMachineStatistics();
@@ -135,9 +116,6 @@ class StatisticsProviderImpl : public StatisticsProvider {
void StatisticsProviderImpl::Init() {
DCHECK(!initialized_);
initialized_ = true;
-
- // Load the machine info file immediately to get the channel info.
- LoadMachineOSInfoFile();
}
bool StatisticsProviderImpl::GetMachineStatistic(
@@ -201,21 +179,6 @@ StatisticsProviderImpl::StatisticsProviderImpl()
false /* initially_signaled */) {
}
-void StatisticsProviderImpl::LoadMachineOSInfoFile() {
- NameValuePairsParser parser(&machine_info_);
- if (parser.GetNameValuePairsFromFile(base::FilePath(kMachineOSInfoFile),
- kMachineOSInfoEq,
- kMachineOSInfoDelim)) {
-#if defined(GOOGLE_CHROME_BUILD)
- const char kChromeOSReleaseTrack[] = "CHROMEOS_RELEASE_TRACK";
- NameValuePairsParser::NameValueMap::iterator iter =
- machine_info_.find(kChromeOSReleaseTrack);
- if (iter != machine_info_.end())
- chrome::VersionInfo::SetChannel(iter->second);
-#endif
- }
-}
-
void StatisticsProviderImpl::StartLoadingMachineStatistics() {
DCHECK(initialized_);
DCHECK(!load_statistics_started_);
diff --git a/chrome/browser/chromeos/system/statistics_provider.h b/chrome/browser/chromeos/system/statistics_provider.h
index 48e7dd8..35ab756 100644
--- a/chrome/browser/chromeos/system/statistics_provider.h
+++ b/chrome/browser/chromeos/system/statistics_provider.h
@@ -16,9 +16,6 @@ extern const char kDevSwitchBootMode[];
// HWID key.
extern const char kHardwareClass[];
-// Machine board key.
-extern const char kMachineInfoBoard[];
-
// OEM customization flag that permits exiting enterprise enrollment flow in
// OOBE when 'oem_enterprise_managed' flag is set.
extern const char kOemCanExitEnterpriseEnrollmentKey[];
diff --git a/chrome/browser/chromeos/system_logs/lsb_release_log_source.cc b/chrome/browser/chromeos/system_logs/lsb_release_log_source.cc
index d6b0564..789673a 100644
--- a/chrome/browser/chromeos/system_logs/lsb_release_log_source.cc
+++ b/chrome/browser/chromeos/system_logs/lsb_release_log_source.cc
@@ -4,79 +4,21 @@
#include "chrome/browser/chromeos/system_logs/lsb_release_log_source.h"
-#include <string>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/logging.h"
-#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
-#include "content/public/browser/browser_thread.h"
-
-using content::BrowserThread;
-
-const char kInvalidLogEntry[] = "<invalid characters in log entry>";
-const char kEmptyLogEntry[] = "<no value>";
-
-namespace {
-
-typedef std::pair<std::string, std::string> KeyValuePair;
-
-} // namespace
+#include "base/memory/scoped_ptr.h"
+#include "base/sys_info.h"
namespace chromeos {
void LsbReleaseLogSource::Fetch(const SysLogsSourceCallback& callback) {
DCHECK(!callback.is_null());
-
- SystemLogsResponse* response = new SystemLogsResponse;
- BrowserThread::PostBlockingPoolTaskAndReply(
- FROM_HERE,
- base::Bind(&LsbReleaseLogSource::ReadLSBRelease, response),
- base::Bind(callback,
- base::Owned(response)));
-}
-
-void LsbReleaseLogSource::ReadLSBRelease(SystemLogsResponse* response) {
- DCHECK(response);
-
- const base::FilePath lsb_release_file("/etc/lsb-release");
- std::string lsb_data;
- bool read_success = base::ReadFileToString(lsb_release_file, &lsb_data);
- // if we were using an internal temp file, the user does not need the
- // logs to stay past the ReadFile call - delete the file
- if (!read_success) {
- LOG(ERROR) << "Can't access /etc/lsb-release file.";
- return;
- }
- ParseLSBRelease(lsb_data, response);
-}
-
-void LsbReleaseLogSource::ParseLSBRelease(const std::string& lsb_data,
- SystemLogsResponse* response) {
- std::vector<KeyValuePair> pairs;
- base::SplitStringIntoKeyValuePairs(lsb_data, '=', '\n', &pairs);
- for (size_t i = 0; i < pairs.size(); ++i) {
- std::string key, value;
- TrimWhitespaceASCII(pairs[i].first, TRIM_ALL, &key);
- TrimWhitespaceASCII(pairs[i].second, TRIM_ALL, &value);
-
- if (key.empty())
- continue;
- if (!IsStringUTF8(value) || !IsStringUTF8(key)) {
- LOG(WARNING) << "Invalid characters in system log entry: " << key;
- (*response)[key] = kInvalidLogEntry;
- continue;
- }
-
- if (value.empty())
- (*response)[key] = kEmptyLogEntry;
- else
- (*response)[key] = value;
+ scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse);
+ const base::SysInfo::LsbReleaseMap& lsb_map =
+ base::SysInfo::GetLsbReleaseMap();
+ for (base::SysInfo::LsbReleaseMap::const_iterator iter = lsb_map.begin();
+ iter != lsb_map.end(); ++iter) {
+ (*response)[iter->first] = iter->second;
}
+ callback.Run(response.get());
}
} // namespace chromeos
-
diff --git a/chrome/browser/chromeos/system_logs/lsb_release_log_source.h b/chrome/browser/chromeos/system_logs/lsb_release_log_source.h
index 146c7532..29a071a 100644
--- a/chrome/browser/chromeos/system_logs/lsb_release_log_source.h
+++ b/chrome/browser/chromeos/system_logs/lsb_release_log_source.h
@@ -17,20 +17,7 @@ class LsbReleaseLogSource : public SystemLogsSource {
// SystemLogsSource override.
virtual void Fetch(const SysLogsSourceCallback& callback) OVERRIDE;
- // For testing. Parses a key=value pairs from a string. There can be only one
- // pair per line and the value must confine to a single line.
- // Example:
- // foo = 1
- // bar = 2
- // Note: it automatically strips whitespaces from the front and back of values
- // and keys.
- static void ParseLSBRelease(const std::string& lsb_data,
- SystemLogsResponse* response);
-
private:
- // Gets the info from the /etc/lsb-release and parses it
- static void ReadLSBRelease(SystemLogsResponse* response);
-
DISALLOW_COPY_AND_ASSIGN(LsbReleaseLogSource);
};
diff --git a/chrome/browser/chromeos/system_logs/lsb_release_log_source_unittest.cc b/chrome/browser/chromeos/system_logs/lsb_release_log_source_unittest.cc
deleted file mode 100644
index 66c1fed7..0000000
--- a/chrome/browser/chromeos/system_logs/lsb_release_log_source_unittest.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2012 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/system_logs/lsb_release_log_source.h"
-
-#include "base/basictypes.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-
-TEST(LSBReleaseLogSource, BasicFunctionality) {
- std::string data("key=value\nkey2 = value2 ");
- SystemLogsResponse response;
- LsbReleaseLogSource::ParseLSBRelease(data, &response);
- EXPECT_EQ(2U, response.size());
- EXPECT_EQ("value", response["key"]);
-
- // Make sure extra white space is removed correctly. First from the key and
- // then from the value.
- EXPECT_EQ(1U, response.count("key2"));
- EXPECT_EQ("value2", response["key2"]);
-}
-
-TEST(LSBReleaseLogSource, ValueMissing) {
- std::string data("key=value\nkey2=\nkey3");
- SystemLogsResponse response;
- LsbReleaseLogSource::ParseLSBRelease(data, &response);
- EXPECT_EQ(2U, response.size());
- EXPECT_EQ("value", response["key"]);
- EXPECT_EQ("<no value>", response["key2"]);
- EXPECT_EQ(0U, response.count("key3"));
-}
-
-TEST(LSBReleaseLogSource, BrokenUTF8) {
- std::string data("key=value\nkey2=\nkey3=\xFCts\nkey4=value4\nkey5\xFC=foo");
- SystemLogsResponse response;
- LsbReleaseLogSource::ParseLSBRelease(data, &response);
- EXPECT_EQ("<invalid characters in log entry>", response["key3"]);
- EXPECT_EQ("value4", response["key4"]);
- EXPECT_EQ(0U, response.count("key5"));
-}
-
-TEST(LSBReleasLogSource, NoKeyValuePair) {
- SystemLogsResponse response;
-
- std::string contents1("random text without a meaning");
- LsbReleaseLogSource::ParseLSBRelease(contents1, &response);
- EXPECT_TRUE(response.empty());
-}
-
-TEST(LSBReleasLogSource, EmptyInput) {
- SystemLogsResponse response;
- std::string contents2("");
- LsbReleaseLogSource::ParseLSBRelease(contents2, &response);
- EXPECT_TRUE(response.empty());
-}
-
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/version_loader.cc b/chrome/browser/chromeos/version_loader.cc
index 5ee7046..c25c9c5a 100644
--- a/chrome/browser/chromeos/version_loader.cc
+++ b/chrome/browser/chromeos/version_loader.cc
@@ -14,6 +14,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "base/sys_info.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
@@ -24,6 +25,19 @@ using content::BrowserThread;
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";
+
// Converts const string* to const string&.
void VersionLoaderCallbackHelper(
base::Callback<void(const std::string&)> callback,
@@ -35,29 +49,10 @@ void VersionLoaderCallbackHelper(
namespace chromeos {
-// File to look for version number in.
-static const char kPathVersion[] = "/etc/lsb-release";
-
-// File to look for firmware number in.
-static const char kPathFirmware[] = "/var/log/bios_info.txt";
-
VersionLoader::VersionLoader() : backend_(new Backend()) {}
VersionLoader::~VersionLoader() {}
-// Beginning of line we look for that gives full version number.
-// Format: x.x.xx.x (Developer|Official build extra info) board info
-// static
-const char VersionLoader::kFullVersionPrefix[] =
- "CHROMEOS_RELEASE_DESCRIPTION=";
-
-// Same but for short version (x.x.xx.x).
-// static
-const char VersionLoader::kVersionPrefix[] = "CHROMEOS_RELEASE_VERSION=";
-
-// Beginning of line we look for that gives the firmware version.
-const char VersionLoader::kFirmwarePrefix[] = "version";
-
CancelableTaskTracker::TaskId VersionLoader::GetVersion(
VersionFormat format,
const GetVersionCallback& callback,
@@ -83,30 +78,6 @@ CancelableTaskTracker::TaskId VersionLoader::GetFirmware(
}
// static
-std::string VersionLoader::ParseVersion(const std::string& contents,
- const std::string& prefix) {
- // The file contains lines such as:
- // XXX=YYY
- // AAA=ZZZ
- // Split the lines and look for the one that starts with prefix. The version
- // file is small, which is why we don't try and be tricky.
- std::vector<std::string> lines;
- base::SplitString(contents, '\n', &lines);
- for (size_t i = 0; i < lines.size(); ++i) {
- if (StartsWithASCII(lines[i], prefix, false)) {
- std::string version = lines[i].substr(std::string(prefix).size());
- if (version.size() > 1 && version[0] == '"' &&
- version[version.size() - 1] == '"') {
- // Trim trailing and leading quotes.
- version = version.substr(1, version.size() - 2);
- }
- return version;
- }
- }
- return std::string();
-}
-
-// static
std::string VersionLoader::ParseFirmware(const std::string& contents) {
// The file contains lines such as:
// vendor | ...
@@ -133,24 +104,18 @@ void VersionLoader::Backend::GetVersion(VersionFormat format,
std::string* version) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
- std::string contents;
- const base::FilePath file_path(kPathVersion);
- if (base::ReadFileToString(file_path, &contents)) {
- *version = ParseVersion(
- contents,
- (format == VERSION_FULL) ? kFullVersionPrefix : kVersionPrefix);
+ std::string key = (format == VERSION_FULL) ? kFullVersionKey : kVersionKey;
+ if (!base::SysInfo::GetLsbReleaseValue(key, version)) {
+ LOG(ERROR) << "No LSB version key: " << key;
+ *version = "0.0.0.0";
}
-
if (format == VERSION_SHORT_WITH_DATE) {
- base::PlatformFileInfo fileinfo;
- if (file_util::GetFileInfo(file_path, &fileinfo)) {
- base::Time::Exploded ctime;
- fileinfo.creation_time.UTCExplode(&ctime);
- *version += base::StringPrintf("-%02u.%02u.%02u",
- ctime.year % 100,
- ctime.month,
- ctime.day_of_month);
- }
+ base::Time::Exploded ctime;
+ base::SysInfo::GetLsbReleaseTime().UTCExplode(&ctime);
+ *version += base::StringPrintf("-%02u.%02u.%02u",
+ ctime.year % 100,
+ ctime.month,
+ ctime.day_of_month);
}
}
diff --git a/chrome/browser/chromeos/version_loader.h b/chrome/browser/chromeos/version_loader.h
index 66a36cd..6361bcb 100644
--- a/chrome/browser/chromeos/version_loader.h
+++ b/chrome/browser/chromeos/version_loader.h
@@ -53,13 +53,7 @@ class VersionLoader {
CancelableTaskTracker::TaskId GetFirmware(const GetFirmwareCallback& callback,
CancelableTaskTracker* tracker);
- static const char kFullVersionPrefix[];
- static const char kVersionPrefix[];
- static const char kFirmwarePrefix[];
-
private:
- FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFullVersion);
- FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseVersion);
FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFirmware);
// VersionLoader calls into the Backend in the blocking thread pool to load
@@ -68,13 +62,12 @@ class VersionLoader {
public:
Backend() {}
- // Calls ParseVersion to get the version # and notifies request.
- // This is invoked in the blocking thread pool.
- // If |full_version| is true then extra info is passed in version string.
+ // Gets the version number from base::SysInfo. This is invoked on the
+ // blocking thread pool.
void GetVersion(VersionFormat format, std::string* version);
- // Calls ParseFirmware to get the firmware # and notifies request.
- // This is invoked in the blocking thread pool.
+ // Calls ParseFirmware to get the firmware value. This is invoked on the
+ // blocking thread pool.
void GetFirmware(std::string* firmware);
private:
@@ -85,11 +78,6 @@ class VersionLoader {
DISALLOW_COPY_AND_ASSIGN(Backend);
};
- // Extracts the version from the file.
- // |prefix| specifies what key defines version data.
- static std::string ParseVersion(const std::string& contents,
- const std::string& prefix);
-
// Extracts the firmware from the file.
static std::string ParseFirmware(const std::string& contents);
diff --git a/chrome/browser/chromeos/version_loader_unittest.cc b/chrome/browser/chromeos/version_loader_unittest.cc
index bc2dd6d..7b2ce30 100644
--- a/chrome/browser/chromeos/version_loader_unittest.cc
+++ b/chrome/browser/chromeos/version_loader_unittest.cc
@@ -12,19 +12,6 @@ namespace chromeos {
typedef testing::Test VersionLoaderTest;
-static const char kTest1[] =
- "DIST_ID=1\nCHROMEOS_RELEASE_DESCRIPTION=0.2.3.3\nFOO=BAR";
-static const char kTest2[] = "DIST_ID=1\nCHROMEOS_RELEASE_DESCRIPTION=0.2.3.3";
-static const char kTest3[] = "CHROMEOS_RELEASE_DESCRIPTION=\"0.2.3.3\"";
-static const char kTest4[] = "CHROMEOS_RELEASE_DESCRIPTION=\"\"\"";
-static const char kTest5[] = "CHROMEOS_RELEASE_DESCRIPTION=\"\"";
-
-static const char kTest6[] =
- "CHROMEOS_RELEASE_DESCRIPTION=1\nCHROMEOS_RELEASE_VERSION=0.2.3.3\nFOO=BAR";
-static const char kTest7[] = "DIST_ID=1\nCHROMEOS_RELEASE_VERSION=0.2.3.3";
-static const char kTest8[] = "CHROMEOS_RELEASE_VERSION=\"0.2.3.3\"";
-static const char kTest9[] = "CHROMEOS_RELEASE_VERSION=\"\"";
-
static const char kTest10[] = "vendor | FOO";
static const char kTest11[] = "firmware | FOO";
static const char kTest12[] = "firmware | FOO";
@@ -32,46 +19,10 @@ static const char kTest13[] = "version | 0.2.3.3";
static const char kTest14[] = "version | 0.2.3.3";
static const char kTest15[] = "version 0.2.3.3";
-TEST_F(VersionLoaderTest, ParseFullVersion) {
- EXPECT_EQ("0.2.3.3",
- VersionLoader::ParseVersion(kTest1,
- VersionLoader::kFullVersionPrefix));
- EXPECT_EQ("0.2.3.3",
- VersionLoader::ParseVersion(kTest2,
- VersionLoader::kFullVersionPrefix));
- EXPECT_EQ("0.2.3.3",
- VersionLoader::ParseVersion(kTest3,
- VersionLoader::kFullVersionPrefix));
- EXPECT_EQ("\"",
- VersionLoader::ParseVersion(kTest4,
- VersionLoader::kFullVersionPrefix));
- EXPECT_EQ(std::string(),
- VersionLoader::ParseVersion(kTest5,
- VersionLoader::kFullVersionPrefix));
- EXPECT_EQ(std::string(),
- VersionLoader::ParseVersion(std::string(),
- VersionLoader::kFullVersionPrefix));
-}
-
-TEST_F(VersionLoaderTest, ParseVersion) {
- EXPECT_EQ("0.2.3.3",
- VersionLoader::ParseVersion(kTest6,
- VersionLoader::kVersionPrefix));
- EXPECT_EQ("0.2.3.3",
- VersionLoader::ParseVersion(kTest7,
- VersionLoader::kVersionPrefix));
- EXPECT_EQ("0.2.3.3",
- VersionLoader::ParseVersion(kTest8,
- VersionLoader::kVersionPrefix));
- EXPECT_EQ(std::string(),
- VersionLoader::ParseVersion(kTest9,
- VersionLoader::kFullVersionPrefix));
-}
-
TEST_F(VersionLoaderTest, ParseFirmware) {
- EXPECT_EQ(std::string(), VersionLoader::ParseFirmware(kTest10));
- EXPECT_EQ(std::string(), VersionLoader::ParseFirmware(kTest11));
- EXPECT_EQ(std::string(), VersionLoader::ParseFirmware(kTest12));
+ EXPECT_EQ("", VersionLoader::ParseFirmware(kTest10));
+ EXPECT_EQ("", VersionLoader::ParseFirmware(kTest11));
+ EXPECT_EQ("", VersionLoader::ParseFirmware(kTest12));
EXPECT_EQ("0.2.3.3", VersionLoader::ParseFirmware(kTest13));
EXPECT_EQ("0.2.3.3", VersionLoader::ParseFirmware(kTest14));
EXPECT_EQ("0.2.3.3", VersionLoader::ParseFirmware(kTest15));
diff --git a/chrome/browser/policy/cloud/device_management_service.cc b/chrome/browser/policy/cloud/device_management_service.cc
index 4e13def..0e784d0 100644
--- a/chrome/browser/policy/cloud/device_management_service.cc
+++ b/chrome/browser/policy/cloud/device_management_service.cc
@@ -71,7 +71,6 @@ const int kPolicyNotFound = 902; // This error is not sent as HTTP status code.
#if defined(OS_CHROMEOS)
// Machine info keys.
const char kMachineInfoHWClass[] = "hardware_class";
-const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD";
#endif
bool IsProxyError(const net::URLRequestStatus status) {
@@ -177,12 +176,9 @@ const std::string& GetPlatformString() {
chromeos::system::StatisticsProvider::GetInstance();
std::string hwclass;
- std::string board;
- if (!provider->GetMachineStatistic(kMachineInfoHWClass, &hwclass) ||
- !provider->GetMachineStatistic(kMachineInfoBoard, &board)) {
+ if (!provider->GetMachineStatistic(kMachineInfoHWClass, &hwclass))
LOG(ERROR) << "Failed to get machine information";
- }
- os_name += ",CrOS," + board;
+ os_name += ",CrOS," + base::SysInfo::GetLsbReleaseBoard();
os_hardware += "," + hwclass;
#endif
diff --git a/chrome/browser/ui/webui/help/help_handler.cc b/chrome/browser/ui/webui/help/help_handler.cc
index 6fdc04f..f1891ac 100644
--- a/chrome/browser/ui/webui/help/help_handler.cc
+++ b/chrome/browser/ui/webui/help/help_handler.cc
@@ -125,11 +125,6 @@ bool CanChangeChannel() {
return false;
}
-// Pointer to a |StringValue| holding the date of the build date to Chromium
-// OS. Because this value is obtained by reading a file, it is cached here to
-// prevent the need to read from the file system multiple times unnecessarily.
-Value* g_build_date_string = NULL;
-
#endif // defined(OS_CHROMEOS)
} // namespace
@@ -343,18 +338,10 @@ void HelpHandler::OnPageLoaded(const ListValue* args) {
"help.HelpPage.updateEnableReleaseChannel",
base::FundamentalValue(CanChangeChannel()));
- if (g_build_date_string == NULL) {
- // If |g_build_date_string| is |NULL|, the date has not yet been assigned.
- // Get the date of the last lsb-release file modification.
- base::FileUtilProxy::GetFileInfo(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(),
- base::SysInfo::GetLsbReleaseFilePath(),
- base::Bind(&HelpHandler::ProcessLsbFileInfo,
- weak_factory_.GetWeakPtr()));
- } else {
- web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate",
- *g_build_date_string);
- }
+ base::Time build_time = base::SysInfo::GetLsbReleaseTime();
+ string16 build_date = base::TimeFormatFriendlyDate(build_time);
+ web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate",
+ base::StringValue(build_date));
#endif // defined(OS_CHROMEOS)
version_updater_->CheckForUpdate(
@@ -546,31 +533,4 @@ void HelpHandler::OnTargetChannel(const std::string& channel) {
"help.HelpPage.updateTargetChannel", base::StringValue(channel));
}
-void HelpHandler::ProcessLsbFileInfo(
- base::PlatformFileError error, const base::PlatformFileInfo& file_info) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // If |g_build_date_string| is not |NULL|, then the file's information has
- // already been retrieved by another tab.
- if (g_build_date_string == NULL) {
- base::Time time;
- if (error == base::PLATFORM_FILE_OK) {
- // Retrieves the time at which the Chrome OS build was created.
- // Each time a new build is created, /etc/lsb-release is modified with the
- // new version numbers of the release.
- time = file_info.last_modified;
- } else {
- // If the time of the build cannot be retrieved, return and do not
- // display the "Build Date" section.
- return;
- }
-
- // Note that this string will be internationalized.
- string16 build_date = base::TimeFormatFriendlyDate(time);
- g_build_date_string = Value::CreateStringValue(build_date);
- }
-
- web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate",
- *g_build_date_string);
-}
#endif // defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/webui/help/help_handler.h b/chrome/browser/ui/webui/help/help_handler.h
index 0f25dab..7c657c3 100644
--- a/chrome/browser/ui/webui/help/help_handler.h
+++ b/chrome/browser/ui/webui/help/help_handler.h
@@ -81,9 +81,6 @@ class HelpHandler : public content::WebUIMessageHandler,
void OnOSFirmware(const std::string& firmware);
void OnCurrentChannel(const std::string& channel);
void OnTargetChannel(const std::string& channel);
-
- void ProcessLsbFileInfo(
- base::PlatformFileError rv, const base::PlatformFileInfo& file_info);
#endif
// Specialized instance of the VersionUpdater used to update the browser.
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index cb16621..76b465e 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -716,7 +716,6 @@
'browser/chromeos/settings/session_manager_operation_unittest.cc',
'browser/chromeos/settings/stub_cros_settings_provider_unittest.cc',
'browser/chromeos/system/automatic_reboot_manager_unittest.cc',
- 'browser/chromeos/system_logs/lsb_release_log_source_unittest.cc',
'browser/chromeos/version_loader_unittest.cc',
'browser/command_updater_unittest.cc',
'browser/component_updater/test/component_installers_unittest.cc',