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/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 bool NameValuePairsParser::GetSingleValueFromTool(int argc, | 69 bool NameValuePairsParser::GetSingleValueFromTool(int argc, |
70 const char* argv[], | 70 const char* argv[], |
71 const std::string& key) { | 71 const std::string& key) { |
72 DCHECK_GE(argc, 1); | 72 DCHECK_GE(argc, 1); |
73 | 73 |
74 if (!file_util::PathExists(FilePath(argv[0]))) { | 74 if (!file_util::PathExists(FilePath(argv[0]))) { |
75 LOG(ERROR) << argv[0] << " not found"; | 75 LOG(WARNING) << "Tool for statistics not found: " << argv[0]; |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 CommandLine command_line(argc, argv); | 79 CommandLine command_line(argc, argv); |
80 std::string output_string; | 80 std::string output_string; |
81 if (!base::GetAppOutput(command_line, &output_string)) { | 81 if (!base::GetAppOutput(command_line, &output_string)) { |
82 LOG(ERROR) << "Error executing: " << command_line.GetCommandLineString(); | 82 LOG(WARNING) << "Error executing: " << command_line.GetCommandLineString(); |
83 return false; | 83 return false; |
84 } | 84 } |
85 TrimWhitespaceASCII(output_string, TRIM_ALL, &output_string); | 85 TrimWhitespaceASCII(output_string, TRIM_ALL, &output_string); |
86 AddNameValuePair(key, output_string); | 86 AddNameValuePair(key, output_string); |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
| 90 void NameValuePairsParser::GetNameValuePairsFromFile(const FilePath& file_path, |
| 91 const std::string& eq, |
| 92 const std::string& delim) { |
| 93 std::string contents; |
| 94 if (file_util::ReadFileToString(file_path, &contents)) { |
| 95 ParseNameValuePairs(contents, eq, delim); |
| 96 } else { |
| 97 LOG(WARNING) << "Unable to read statistics file: " << file_path.value(); |
| 98 } |
| 99 } |
| 100 |
90 } // namespace system | 101 } // namespace system |
91 } // namespace chromeos | 102 } // namespace chromeos |
OLD | NEW |