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

Unified Diff: chrome/browser/chromeos/name_value_pairs_parser.h

Issue 6899021: HWID and VPD values should be accessible via SystemAccess::GetMachineStatistic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unit_test 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/name_value_pairs_parser.h
diff --git a/chrome/browser/chromeos/name_value_pairs_parser.h b/chrome/browser/chromeos/name_value_pairs_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..ae8823b2f2081447c33bb444187004fcf4f09b2d
--- /dev/null
+++ b/chrome/browser/chromeos/name_value_pairs_parser.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_
+#define CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_
+#pragma once
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+
+namespace chromeos {
+
+// The parser is used to get machine info as name-value pairs. Defined
+// here to be accessable by tests.
+class NameValuePairsParser {
+ public:
+ typedef std::map<std::string, std::string> NameValueMap;
+
+ // The obtained info will be written into machine_info.
+ explicit NameValuePairsParser(NameValueMap* map);
+
+ void AddNameValuePair(const std::string& key, const std::string& value);
+
+ // Executes tool and inserts (key, <output>) into map_.
+ bool GetSingleValueFromTool(int argc, const char* argv[],
+ const std::string& key);
+ // Executes tool, parses the output using ParseNameValuePairs,
+ // and inserts the results into name_value_pairs_.
+ bool ParseNameValuePairsFromTool(int argc, const char* argv[],
+ const std::string& eq,
+ const std::string& delim);
+
+ private:
+ // This will parse strings with output in the format:
+ // <key><EQ><value><DELIM>[<key><EQ><value>][...]
+ // e.g. ParseNameValuePairs("key1=value1 key2=value2", "=", " ")
+ bool ParseNameValuePairs(const std::string& in_string,
+ const std::string& eq,
+ const std::string& delim);
+
+ NameValueMap* map_;
+
+ DISALLOW_COPY_AND_ASSIGN(NameValuePairsParser);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_NAME_VALUE_PAIRS_PARSER_H_

Powered by Google App Engine
This is Rietveld 408576698