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

Unified Diff: chrome/browser/metrics/metrics_service.h

Issue 10078017: Added asynchronous notification of readiness to the StatisticsProvider, and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Ilya's comments Created 8 years, 7 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
Index: chrome/browser/metrics/metrics_service.h
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index 82c89cf8047bbe49cc34c2ad2c061e3de9feec4a..68b3da861d4a6fe05b387f9ff31a4fe7aa658f8d 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -14,6 +14,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/cancelable_callback.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
@@ -28,6 +29,7 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/external_metrics.h"
+#include "chrome/browser/chromeos/system/statistics_provider.h"
#endif
class BookmarkModel;
@@ -66,6 +68,9 @@ class MetricsService
: public chrome_browser_metrics::TrackingSynchronizerObserver,
public content::NotificationObserver,
public content::URLFetcherDelegate,
+#if defined(OS_CHROMEOS)
+ public chromeos::system::StatisticsProvider::Observer,
+#endif
public MetricsServiceBase {
public:
MetricsService();
@@ -158,14 +163,22 @@ class MetricsService
NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN
};
- // First part of the init task. Called on the FILE thread to load hardware
- // class information.
- static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self,
- base::MessageLoopProxy* target_loop);
+ // First init task, that starts retrieving the hardware class. It proceeds
+ // to InitTaskGetPluginInfo after reading the hardware_class, or after
+ // timing out waiting for it.
+ void InitTaskGetHardwareClass();
- // Callback from InitTaskGetHardwareClass() that continues the init task by
- // loading plugin information.
- void OnInitTaskGotHardwareClass(const std::string& hardware_class);
+#if defined(OS_CHROMEOS)
+ // chromeos::system::StatisticsProvider::Observer implementation:
+ virtual void OnMachineStatisticsReady() OVERRIDE;
+
+ // Handles a timeout while waiting for the StatisticsProvider to become ready
+ // during initialization.
+ void OnStatisticsProviderTimeout();
+#endif
+
+ // Second init task, that starts retrieving plugin info.
+ void InitTaskGetPluginInfo();
// Callback from PluginService::GetPlugins() that continues the init task by
// launching a task to gather Google Update statistics.
@@ -440,6 +453,11 @@ class MetricsService
#if defined(OS_CHROMEOS)
// The external metric service is used to log ChromeOS UMA events.
scoped_refptr<chromeos::ExternalMetrics> external_metrics_;
+
+ // Used to resume initialization of the MetricsService when the
+ // StatisticsProvider becomes ready, or after timing out while waiting for it.
+ base::CancelableClosure on_timeout_callback_;
+ base::CancelableClosure on_ready_callback_;
#endif
// Reduntant marker to check that we completed our shutdown, and set the

Powered by Google App Engine
This is Rietveld 408576698