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

Unified Diff: chrome/browser/chromeos/system/statistics_provider.cc

Issue 11778025: Decouple loading of channel info and the rest of machine statistics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build error in unit tests - need to declare the mock virtual function. Created 7 years, 11 months 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/system/statistics_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/system/statistics_provider.cc
diff --git a/chrome/browser/chromeos/system/statistics_provider.cc b/chrome/browser/chromeos/system/statistics_provider.cc
index 29db4593f6969efbd3b114b85137be05d2d3e9c0..d459b7c66dda00b2eb7ecb4b41918b8c33ba1b38 100644
--- a/chrome/browser/chromeos/system/statistics_provider.cc
+++ b/chrome/browser/chromeos/system/statistics_provider.cc
@@ -71,6 +71,7 @@ class StatisticsProviderImpl : public StatisticsProvider {
public:
// StatisticsProvider implementation:
virtual void Init() OVERRIDE;
+ virtual void StartLoadingMachineStatistics() OVERRIDE;
virtual bool GetMachineStatistic(const std::string& name,
std::string* result) OVERRIDE;
@@ -88,13 +89,11 @@ class StatisticsProviderImpl : public StatisticsProvider {
// info file immediately.
void LoadMachineOSInfoFile();
- // Starts loading the machine statistcs.
- void StartLoadingMachineStatistics();
-
// Loads the machine statistcs by examining the system.
void LoadMachineStatistics();
bool initialized_;
+ bool load_statistics_started_;
NameValuePairsParser::NameValueMap machine_info_;
base::WaitableEvent on_statistics_loaded_;
@@ -105,15 +104,14 @@ void StatisticsProviderImpl::Init() {
DCHECK(!initialized_);
initialized_ = true;
- // Load the machine info file immediately to get the channel info and delay
- // loading the remaining statistics.
+ // Load the machine info file immediately to get the channel info.
LoadMachineOSInfoFile();
- StartLoadingMachineStatistics();
}
bool StatisticsProviderImpl::GetMachineStatistic(
const std::string& name, std::string* result) {
DCHECK(initialized_);
+ DCHECK(load_statistics_started_);
VLOG(1) << "Statistic is requested for " << name;
// Block if the statistics are not loaded yet. Per LOG(WARNING) below,
@@ -151,6 +149,7 @@ bool StatisticsProviderImpl::GetMachineStatistic(
// manual_reset needs to be true, as we want to keep the signaled state.
StatisticsProviderImpl::StatisticsProviderImpl()
: initialized_(false),
+ load_statistics_started_(false),
on_statistics_loaded_(true /* manual_reset */,
false /* initially_signaled */) {
}
@@ -171,6 +170,10 @@ void StatisticsProviderImpl::LoadMachineOSInfoFile() {
}
void StatisticsProviderImpl::StartLoadingMachineStatistics() {
+ DCHECK(initialized_);
+ DCHECK(!load_statistics_started_);
+ load_statistics_started_ = true;
+
VLOG(1) << "Started loading statistics";
BrowserThread::PostBlockingPoolTask(
FROM_HERE,
@@ -219,8 +222,9 @@ StatisticsProviderImpl* StatisticsProviderImpl::GetInstance() {
class StatisticsProviderStubImpl : public StatisticsProvider {
public:
// StatisticsProvider implementation:
- virtual void Init() OVERRIDE {
- }
+ virtual void Init() OVERRIDE {}
+
+ virtual void StartLoadingMachineStatistics() OVERRIDE {}
virtual bool GetMachineStatistic(const std::string& name,
std::string* result) OVERRIDE {
« no previous file with comments | « chrome/browser/chromeos/system/statistics_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698