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

Side by Side Diff: chrome/browser/chromeos/version_loader.h

Issue 6883142: Show ChromeOS bios firmware in about dialog. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/chromeos/version_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 10 matching lines...) Expand all
21 // ChromeOSVersionLoader callback to a method of your choice with the version 21 // ChromeOSVersionLoader callback to a method of your choice with the version
22 // (or an empty string if the version couldn't be found). 22 // (or an empty string if the version couldn't be found).
23 // To use ChromeOSVersionLoader do the following: 23 // To use ChromeOSVersionLoader do the following:
24 // 24 //
25 // . In your class define a member field of type chromeos::VersionLoader and 25 // . In your class define a member field of type chromeos::VersionLoader and
26 // CancelableRequestConsumerBase. 26 // CancelableRequestConsumerBase.
27 // . Define the callback method, something like: 27 // . Define the callback method, something like:
28 // void OnGetChromeOSVersion(chromeos::VersionLoader::Handle, 28 // void OnGetChromeOSVersion(chromeos::VersionLoader::Handle,
29 // std::string version); 29 // std::string version);
30 // . When you want the version invoke: loader.GetVersion(&consumer, callback); 30 // . When you want the version invoke: loader.GetVersion(&consumer, callback);
31 //
32 // This class also provides the ability to load the bios firmware using
33 // loader.GetFirmware(&consumer, callback);
31 class VersionLoader : public CancelableRequestProvider { 34 class VersionLoader : public CancelableRequestProvider {
32 public: 35 public:
33 VersionLoader(); 36 VersionLoader();
34 37
35 enum VersionFormat { 38 enum VersionFormat {
36 VERSION_SHORT, 39 VERSION_SHORT,
37 VERSION_SHORT_WITH_DATE, 40 VERSION_SHORT_WITH_DATE,
38 VERSION_FULL, 41 VERSION_FULL,
39 }; 42 };
40 43
41 // Signature 44 // Signature
42 typedef Callback2<Handle, std::string>::Type GetVersionCallback; 45 typedef Callback2<Handle, std::string>::Type GetVersionCallback;
46 typedef CancelableRequest<GetVersionCallback> GetVersionRequest;
43 47
44 typedef CancelableRequest<GetVersionCallback> GetVersionRequest; 48 typedef Callback2<Handle, std::string>::Type GetFirmwareCallback;
49 typedef CancelableRequest<GetFirmwareCallback> GetFirmwareRequest;
45 50
46 // Asynchronously requests the version. 51 // Asynchronously requests the version.
47 // If |full_version| is true version string with extra info is extracted, 52 // If |full_version| is true version string with extra info is extracted,
48 // otherwise it's in short format x.x.xx.x. 53 // otherwise it's in short format x.x.xx.x.
49 Handle GetVersion(CancelableRequestConsumerBase* consumer, 54 Handle GetVersion(CancelableRequestConsumerBase* consumer,
50 GetVersionCallback* callback, 55 GetVersionCallback* callback,
51 VersionFormat format); 56 VersionFormat format);
52 57
58 Handle GetFirmware(CancelableRequestConsumerBase* consumer,
59 GetFirmwareCallback* callback);
60
53 static const char kFullVersionPrefix[]; 61 static const char kFullVersionPrefix[];
54 static const char kVersionPrefix[]; 62 static const char kVersionPrefix[];
63 static const char kFirmwarePrefix[];
55 64
56 private: 65 private:
57 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFullVersion); 66 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFullVersion);
58 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseVersion); 67 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseVersion);
68 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFirmware);
59 69
60 // VersionLoader calls into the Backend on the file thread to load 70 // VersionLoader calls into the Backend on the file thread to load
61 // and extract the version. 71 // and extract the version.
62 class Backend : public base::RefCountedThreadSafe<Backend> { 72 class Backend : public base::RefCountedThreadSafe<Backend> {
63 public: 73 public:
64 Backend() {} 74 Backend() {}
65 75
66 // Calls ParseVersion to get the version # and notifies request. 76 // Calls ParseVersion to get the version # and notifies request.
67 // This is invoked on the file thread. 77 // This is invoked on the file thread.
68 // If |full_version| is true then extra info is passed in version string. 78 // If |full_version| is true then extra info is passed in version string.
69 void GetVersion(scoped_refptr<GetVersionRequest> request, 79 void GetVersion(scoped_refptr<GetVersionRequest> request,
70 VersionFormat format); 80 VersionFormat format);
71 81
82 // Calls ParseFirmware to get the firmware # and notifies request.
83 // This is invoked on the file thread.
84 void GetFirmware(scoped_refptr<GetFirmwareRequest> request);
85
72 private: 86 private:
73 friend class base::RefCountedThreadSafe<Backend>; 87 friend class base::RefCountedThreadSafe<Backend>;
74 88
75 ~Backend() {} 89 ~Backend() {}
76 90
77 DISALLOW_COPY_AND_ASSIGN(Backend); 91 DISALLOW_COPY_AND_ASSIGN(Backend);
78 }; 92 };
79 93
80 // Extracts the version from the file. 94 // Extracts the version from the file.
81 // |prefix| specifies what key defines version data. 95 // |prefix| specifies what key defines version data.
82 static std::string ParseVersion(const std::string& contents, 96 static std::string ParseVersion(const std::string& contents,
83 const std::string& prefix); 97 const std::string& prefix);
84 98
99 // Extracts the firmware from the file.
100 static std::string ParseFirmware(const std::string& contents);
101
85 scoped_refptr<Backend> backend_; 102 scoped_refptr<Backend> backend_;
86 103
87 DISALLOW_COPY_AND_ASSIGN(VersionLoader); 104 DISALLOW_COPY_AND_ASSIGN(VersionLoader);
88 }; 105 };
89 106
90 } // namespace chromeos 107 } // namespace chromeos
91 108
92 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ 109 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/chromeos/version_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698