OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | |
12 | |
11 namespace chromeos { | 13 namespace chromeos { |
12 namespace system { | 14 namespace system { |
13 | 15 |
14 // This interface provides access to Chrome OS statistics. | 16 // This interface provides access to Chrome OS statistics. |
15 class StatisticsProvider { | 17 class StatisticsProvider { |
16 public: | 18 public: |
17 // Retrieve the named machine statistic (e.g. "hardware_class"). | 19 // Retrieve the named machine statistic (e.g. "hardware_class"). |
18 // This does not update the statistcs. If the |name| is not set, |result| | 20 // This does not update the statistcs. If the |name| is not set, |result| |
19 // preserves old value. | 21 // preserves the previous value. |
Ilya Sherman
2012/04/20 21:18:37
nit: Perhaps "is unchanged" rather than "preserves
Joao da Silva
2012/04/23 09:36:50
Rephrased as suggested. It's not a DCHECK, since i
| |
22 // This call may block if the statistics aren't ready yet, up to a timeout; | |
23 // it may also fail because the statistics weren't ready before the timeout. | |
24 // To make sure this won't block nor fail, invoke GetMachineStatistic() after | |
25 // WhenReady() has invoked its callback. | |
20 virtual bool GetMachineStatistic(const std::string& name, | 26 virtual bool GetMachineStatistic(const std::string& name, |
21 std::string* result) = 0; | 27 std::string* result) = 0; |
22 | 28 |
29 // Invokes |callback| on the UI loop once the statistics have been loaded. | |
30 // |callback| is immediately posted to the UI loop if the statistics are | |
31 // already available. | |
32 virtual void WhenReady(const base::Closure& callback) = 0; | |
33 | |
23 static StatisticsProvider* GetInstance(); | 34 static StatisticsProvider* GetInstance(); |
24 | 35 |
25 protected: | 36 protected: |
26 virtual ~StatisticsProvider() {} | 37 virtual ~StatisticsProvider() {} |
27 }; | 38 }; |
28 | 39 |
29 } // namespace system | 40 } // namespace system |
30 } // namespace chromeos | 41 } // namespace chromeos |
31 | 42 |
32 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ | 43 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ |
OLD | NEW |