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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 private: | 72 private: |
73 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFullVersion); | 73 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFullVersion); |
74 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseVersion); | 74 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseVersion); |
75 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFirmware); | 75 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFirmware); |
76 | 76 |
77 // VersionLoader calls into the Backend on the file thread to load | 77 // VersionLoader calls into the Backend on the file thread to load |
78 // and extract the version. | 78 // and extract the version. |
79 class Backend : public base::RefCountedThreadSafe<Backend> { | 79 class Backend : public base::RefCountedThreadSafe<Backend> { |
80 public: | 80 public: |
81 Backend() : parse_as_platform_(false) {} | 81 Backend() {} |
82 | 82 |
83 // Calls ParseVersion to get the version # and notifies request. | 83 // Calls ParseVersion to get the version # and notifies request. |
84 // This is invoked on the file thread. | 84 // This is invoked on the file thread. |
85 // If |full_version| is true then extra info is passed in version string. | 85 // If |full_version| is true then extra info is passed in version string. |
86 void GetVersion(scoped_refptr<GetVersionRequest> request, | 86 void GetVersion(scoped_refptr<GetVersionRequest> request, |
87 VersionFormat format); | 87 VersionFormat format); |
88 | 88 |
89 // Calls ParseFirmware to get the firmware # and notifies request. | 89 // Calls ParseFirmware to get the firmware # and notifies request. |
90 // This is invoked on the file thread. | 90 // This is invoked on the file thread. |
91 void GetFirmware(scoped_refptr<GetFirmwareRequest> request); | 91 void GetFirmware(scoped_refptr<GetFirmwareRequest> request); |
92 | 92 |
93 void set_parse_as_platform(bool value) { parse_as_platform_ = value; } | |
94 | |
95 private: | 93 private: |
96 friend class base::RefCountedThreadSafe<Backend>; | 94 friend class base::RefCountedThreadSafe<Backend>; |
97 | 95 |
98 bool parse_as_platform_; | |
99 | |
100 ~Backend() {} | 96 ~Backend() {} |
101 | 97 |
102 DISALLOW_COPY_AND_ASSIGN(Backend); | 98 DISALLOW_COPY_AND_ASSIGN(Backend); |
103 }; | 99 }; |
104 | 100 |
105 // Extracts the version from the file. | 101 // Extracts the version from the file. |
106 // |prefix| specifies what key defines version data. | 102 // |prefix| specifies what key defines version data. |
107 static std::string ParseVersion(const std::string& contents, | 103 static std::string ParseVersion(const std::string& contents, |
108 const std::string& prefix); | 104 const std::string& prefix); |
109 | 105 |
110 // Extracts the firmware from the file. | 106 // Extracts the firmware from the file. |
111 static std::string ParseFirmware(const std::string& contents); | 107 static std::string ParseFirmware(const std::string& contents); |
112 | 108 |
113 scoped_refptr<Backend> backend_; | 109 scoped_refptr<Backend> backend_; |
114 | 110 |
115 DISALLOW_COPY_AND_ASSIGN(VersionLoader); | 111 DISALLOW_COPY_AND_ASSIGN(VersionLoader); |
116 }; | 112 }; |
117 | 113 |
118 } // namespace chromeos | 114 } // namespace chromeos |
119 | 115 |
120 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ | 116 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ |
OLD | NEW |