Chromium Code Reviews| 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..d76b63e291324697f54fe84e973633ceb29b4856 100644 |
| --- a/chrome/browser/chromeos/system/statistics_provider.h |
| +++ b/chrome/browser/chromeos/system/statistics_provider.h |
| @@ -8,6 +8,8 @@ |
| #include <string> |
| +#include "base/callback.h" |
| + |
| namespace chromeos { |
| namespace system { |
| @@ -15,11 +17,20 @@ namespace system { |
| 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. |
| + // This does not update the statistcs. |result| is not updated if |name| is |
| + // not set. |
| + // This call may block if the statistics aren't ready yet, up to a timeout; |
| + // it may also fail because the statistics weren't ready before the timeout. |
| + // To make sure this won't block nor fail, invoke GetMachineStatistic() after |
| + // WhenReady() has invoked its callback. |
| virtual bool GetMachineStatistic(const std::string& name, |
|
jar (doing other things)
2012/04/24 18:37:40
nit: I had to read the comment a few times to pars
Joao da Silva
2012/04/27 09:47:48
Thanks, that's a much better wording :-)
|
| std::string* result) = 0; |
| + // Invokes |callback| on the UI loop once the statistics have been loaded. |
| + // |callback| is immediately posted to the UI loop if the statistics are |
| + // already available. |
| + virtual void WhenReady(const base::Closure& callback) = 0; |
|
jar (doing other things)
2012/04/24 18:37:40
You should probably use a more standard pattern, a
Joao da Silva
2012/04/27 09:47:48
I've been encouraged in other CLs to use callbacks
jar (doing other things)
2012/04/27 18:00:38
I like callbacks better, as you noted, when there
Joao da Silva
2012/05/15 13:52:47
Added an observer as suggested.
|
| + |
| static StatisticsProvider* GetInstance(); |
| protected: |