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

Unified Diff: src/platform/update_engine/omaha_request_prep_action.cc

Issue 2105016: AU: Common code to parse simple key/value store files (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Created 10 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: src/platform/update_engine/omaha_request_prep_action.cc
diff --git a/src/platform/update_engine/omaha_request_prep_action.cc b/src/platform/update_engine/omaha_request_prep_action.cc
index 2b019b375a8444efa52a8c45375a66dd981a586c..25772d03ae6493eb4c72bc7571c1deef9fe90bd4 100644
--- a/src/platform/update_engine/omaha_request_prep_action.cc
+++ b/src/platform/update_engine/omaha_request_prep_action.cc
@@ -5,10 +5,13 @@
#include "update_engine/omaha_request_prep_action.h"
#include <sys/utsname.h>
#include <errno.h>
+#include <map>
#include <string>
#include "base/string_util.h"
+#include "update_engine/simple_key_value_store.h"
#include "update_engine/utils.h"
+using std::map;
using std::string;
// This gathers local system information and prepares info used by the
@@ -102,19 +105,10 @@ string OmahaRequestPrepAction::GetLsbValue(
string file_data;
if (!utils::ReadFileToString(root_ + files[i], &file_data))
continue;
- string::size_type pos = 0;
- if (!utils::StringHasPrefix(file_data, key + "=")) {
- pos = file_data.find(string("\n") + key + "=");
- if (pos != string::npos)
- pos++; // advance past \n
- }
- if (pos == string::npos)
- continue;
- pos += key.size() + 1; // advance past the key and the '='
- string::size_type endpos = file_data.find('\n', pos);
- string::size_type length =
- (endpos == string::npos ? string::npos : endpos - pos);
- return file_data.substr(pos, length);
+
+ map<string, string> data = simple_key_value_store::ParseString(file_data);
+ if (utils::MapContainsKey(data, key))
+ return data[key];
}
// not found
return default_value;

Powered by Google App Engine
This is Rietveld 408576698