| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/system/name_value_pairs_parser.h" | 5 #include "chromeos/system/name_value_pairs_parser.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_tokenizer.h" | 13 #include "base/strings/string_tokenizer.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 | 15 |
| 16 namespace chromeos { // NOLINT | 16 namespace chromeos { // NOLINT |
| 17 namespace system { | 17 namespace system { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const char kQuoteChars[] = "\""; | 21 const char kQuoteChars[] = "\""; |
| 22 const char kTrimChars[] = "\" "; | 22 const char kTrimChars[] = "\" "; |
| 23 | 23 |
| 24 bool GetToolOutput(int argc, const char* argv[], std::string& output) { | 24 bool GetToolOutput(int argc, const char* argv[], std::string& output) { |
| 25 DCHECK_GE(argc, 1); | 25 DCHECK_GE(argc, 1); |
| 26 | 26 |
| 27 if (!file_util::PathExists(base::FilePath(argv[0]))) { | 27 if (!base::PathExists(base::FilePath(argv[0]))) { |
| 28 LOG(WARNING) << "Tool for statistics not found: " << argv[0]; | 28 LOG(WARNING) << "Tool for statistics not found: " << argv[0]; |
| 29 return false; | 29 return false; |
| 30 } | 30 } |
| 31 | 31 |
| 32 std::vector<std::string> args; | 32 std::vector<std::string> args; |
| 33 for (int argn = 0; argn < argc; ++argn) | 33 for (int argn = 0; argn < argc; ++argn) |
| 34 args.push_back(argv[argn]); | 34 args.push_back(argv[argn]); |
| 35 if (!base::GetAppOutput(args, &output)) { | 35 if (!base::GetAppOutput(args, &output)) { |
| 36 LOG(WARNING) << "Error executing " << argv[0]; | 36 LOG(WARNING) << "Error executing " << argv[0]; |
| 37 return false; | 37 return false; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 std::string output_string; | 140 std::string output_string; |
| 141 if (!GetToolOutput(argc, argv, output_string)) | 141 if (!GetToolOutput(argc, argv, output_string)) |
| 142 return false; | 142 return false; |
| 143 | 143 |
| 144 return ParseNameValuePairsWithComments( | 144 return ParseNameValuePairsWithComments( |
| 145 output_string, eq, delim, comment_delim); | 145 output_string, eq, delim, comment_delim); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace system | 148 } // namespace system |
| 149 } // namespace chromeos | 149 } // namespace chromeos |
| OLD | NEW |