| 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_VERSION_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "chrome/browser/cancelable_request.h" | 12 #include "chrome/browser/cancelable_request.h" |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 | 15 |
| 16 // ChromeOSVersionLoader loads the version of Chrome OS from the file system. | 16 // ChromeOSVersionLoader loads the version of Chrome OS from the file system. |
| 17 // Loading is done asynchronously on the file thread. Once loaded, | 17 // Loading is done asynchronously on the file thread. Once loaded, |
| 18 // ChromeOSVersionLoader callback to a method of your choice with the version | 18 // ChromeOSVersionLoader callback to a method of your choice with the version |
| 19 // (or an empty string if the version couldn't be found). | 19 // (or an empty string if the version couldn't be found). |
| 20 // To use ChromeOSVersionLoader do the following: | 20 // To use ChromeOSVersionLoader do the following: |
| 21 // | 21 // |
| 22 // . In your class define a member field of type chromeos::VersionLoader and | 22 // . In your class define a member field of type chromeos::VersionLoader and |
| 23 // CancelableRequestConsumerBase. | 23 // CancelableRequestConsumerBase. |
| 24 // . Define the callback method, something like: | 24 // . Define the callback method, something like: |
| 25 // void OnGetChromeOSVersion(chromeos::VersionLoader::Handle, | 25 // void OnGetChromeOSVersion(chromeos::VersionLoader::Handle, |
| 26 // std::string version); | 26 // const std::string& version); |
| 27 // . When you want the version invoke: loader.GetVersion(&consumer, callback); | 27 // . When you want the version invoke: loader.GetVersion(&consumer, callback); |
| 28 // | 28 // |
| 29 // This class also provides the ability to load the bios firmware using | 29 // This class also provides the ability to load the bios firmware using |
| 30 // loader.GetFirmware(&consumer, callback); | 30 // loader.GetFirmware(&consumer, callback); |
| 31 class VersionLoader : public CancelableRequestProvider { | 31 class VersionLoader : public CancelableRequestProvider { |
| 32 public: | 32 public: |
| 33 VersionLoader(); | 33 VersionLoader(); |
| 34 virtual ~VersionLoader(); | 34 virtual ~VersionLoader(); |
| 35 | 35 |
| 36 enum VersionFormat { | 36 enum VersionFormat { |
| 37 VERSION_SHORT, | 37 VERSION_SHORT, |
| 38 VERSION_SHORT_WITH_DATE, | 38 VERSION_SHORT_WITH_DATE, |
| 39 VERSION_FULL, | 39 VERSION_FULL, |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 // Signature | 42 // Signature |
| 43 typedef base::Callback<void(Handle, std::string)> GetVersionCallback; | 43 typedef base::Callback<void(Handle, const std::string&)> GetVersionCallback; |
| 44 typedef CancelableRequest<GetVersionCallback> GetVersionRequest; | 44 typedef CancelableRequest<GetVersionCallback> GetVersionRequest; |
| 45 | 45 |
| 46 typedef base::Callback<void(Handle, std::string)> GetFirmwareCallback; | 46 typedef base::Callback<void(Handle, const std::string&)> GetFirmwareCallback; |
| 47 typedef CancelableRequest<GetFirmwareCallback> GetFirmwareRequest; | 47 typedef CancelableRequest<GetFirmwareCallback> GetFirmwareRequest; |
| 48 | 48 |
| 49 // Asynchronously requests the version. | 49 // Asynchronously requests the version. |
| 50 // If |full_version| is true version string with extra info is extracted, | 50 // If |full_version| is true version string with extra info is extracted, |
| 51 // otherwise it's in short format x.x.xx.x. | 51 // otherwise it's in short format x.x.xx.x. |
| 52 Handle GetVersion(CancelableRequestConsumerBase* consumer, | 52 Handle GetVersion(CancelableRequestConsumerBase* consumer, |
| 53 const GetVersionCallback& callback, | 53 const GetVersionCallback& callback, |
| 54 VersionFormat format); | 54 VersionFormat format); |
| 55 | 55 |
| 56 Handle GetFirmware(CancelableRequestConsumerBase* consumer, | 56 Handle GetFirmware(CancelableRequestConsumerBase* consumer, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 static std::string ParseFirmware(const std::string& contents); | 104 static std::string ParseFirmware(const std::string& contents); |
| 105 | 105 |
| 106 scoped_refptr<Backend> backend_; | 106 scoped_refptr<Backend> backend_; |
| 107 | 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(VersionLoader); | 108 DISALLOW_COPY_AND_ASSIGN(VersionLoader); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 } // namespace chromeos | 111 } // namespace chromeos |
| 112 | 112 |
| 113 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ | 113 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ |
| OLD | NEW |