| 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 #include "chrome/browser/chromeos/system/name_value_pairs_parser.h" | 5 #include "chrome/browser/chromeos/system/name_value_pairs_parser.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/string_tokenizer.h" | 10 #include "base/string_tokenizer.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool NameValuePairsParser::GetSingleValueFromTool(int argc, | 67 bool NameValuePairsParser::GetSingleValueFromTool(int argc, |
| 68 const char* argv[], | 68 const char* argv[], |
| 69 const std::string& key) { | 69 const std::string& key) { |
| 70 CommandLine command_line(argc, argv); | 70 CommandLine command_line(argc, argv); |
| 71 std::string output_string; | 71 std::string output_string; |
| 72 // TODO(stevenjb,satorux): Make this non blocking: crosbug.com/5603. | 72 // TODO(stevenjb,satorux): Make this non blocking: crosbug.com/5603. |
| 73 base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join; | 73 base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join; |
| 74 if (argc < 1 || !base::GetAppOutput(command_line, &output_string)) { | 74 if (argc < 1 || !base::GetAppOutput(command_line, &output_string)) { |
| 75 LOG(WARNING) << "Error excuting: " << command_line.command_line_string(); | 75 LOG(WARNING) << "Error excuting: " << command_line.GetCommandLineString(); |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 TrimWhitespaceASCII(output_string, TRIM_ALL, &output_string); | 78 TrimWhitespaceASCII(output_string, TRIM_ALL, &output_string); |
| 79 AddNameValuePair(key, output_string); | 79 AddNameValuePair(key, output_string); |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool NameValuePairsParser::ParseNameValuePairsFromTool( | 83 bool NameValuePairsParser::ParseNameValuePairsFromTool( |
| 84 int argc, | 84 int argc, |
| 85 const char* argv[], | 85 const char* argv[], |
| 86 const std::string& eq, | 86 const std::string& eq, |
| 87 const std::string& delim) { | 87 const std::string& delim) { |
| 88 CommandLine command_line(argc, argv); | 88 CommandLine command_line(argc, argv); |
| 89 std::string output_string; | 89 std::string output_string; |
| 90 // TODO(stevenjb,satorux): Make this non blocking: crosbug.com/5603. | 90 // TODO(stevenjb,satorux): Make this non blocking: crosbug.com/5603. |
| 91 base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join; | 91 base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join; |
| 92 if (argc < 1 || !base::GetAppOutput(command_line, &output_string)) { | 92 if (argc < 1 || !base::GetAppOutput(command_line, &output_string)) { |
| 93 LOG(WARNING) << "Error excuting: " << command_line.command_line_string(); | 93 LOG(WARNING) << "Error excuting: " << command_line.GetCommandLineString(); |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 if (!ParseNameValuePairs(output_string, eq, delim)) { | 96 if (!ParseNameValuePairs(output_string, eq, delim)) { |
| 97 LOG(WARNING) << "Error parsing values while excuting: " | 97 LOG(WARNING) << "Error parsing values while excuting: " |
| 98 << command_line.command_line_string(); | 98 << command_line.GetCommandLineString(); |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 return true; | 101 return true; |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace system | 104 } // namespace system |
| 105 } // namespace chromeos | 105 } // namespace chromeos |
| OLD | NEW |