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

Unified Diff: chrome/browser/chromeos/system/statistics_provider.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/chromeos/system/statistics_provider.h
diff --git a/chrome/browser/chromeos/system/statistics_provider.h b/chrome/browser/chromeos/system/statistics_provider.h
index 1908087826ccb6b91d74b66b56b69ea3cdbde80e..9541e4c2ca90f727c2a221390980f53e27188f3a 100644
--- a/chrome/browser/chromeos/system/statistics_provider.h
+++ b/chrome/browser/chromeos/system/statistics_provider.h
@@ -14,12 +14,34 @@ namespace system {
// This interface provides access to Chrome OS statistics.
class StatisticsProvider {
public:
- // Retrieve the named machine statistic (e.g. "hardware_class").
- // This does not update the statistcs. If the |name| is not set, |result|
- // preserves old value.
+ class Observer {
+ public:
+ virtual ~Observer() {}
+
+ // Invoked on the UI thread once the statistics have been loaded.
+ // Any calls to GetMachineStatistic() after this callback are guaranteed
+ // not to block.
+ virtual void OnMachineStatisticsReady() = 0;
+ };
+
+ // Get the machine statistic with a key of |name| (e.g., "hardware_class").
+ // Returns true if the key was found, and data was returned in |result|.
+ // Returns false otherwise, and the contents of |result| are undefined.
+ // This call may block for an arbitrary length of time (waiting for statistics
+ // to load, or a timeout to take place). If this function is called anytime
+ // after OnMachineStatisticsReady() has been invoked on an observer,
+ // then this function is guaranteed not to block.
virtual bool GetMachineStatistic(const std::string& name,
std::string* result) = 0;
+ // Invokes OnMachineStatisticsReady() on the |observer| once the machine
+ // statistics are ready. That call can be executed synchronously if the
+ // statistics are already ready.
+ virtual void AddObserver(Observer* observer) = 0;
+
+ // Removes the given |observer|. Observers must be removed before shutdown.
+ virtual void RemoveObserver(Observer* observer) = 0;
+
static StatisticsProvider* GetInstance();
protected:

Powered by Google App Engine
This is Rietveld 408576698