| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 #ifndef _CRASH_REPORTER_CRASH_COLLECTOR_H_ | 5 #ifndef _CRASH_REPORTER_CRASH_COLLECTOR_H_ |
| 6 #define _CRASH_REPORTER_CRASH_COLLECTOR_H_ | 6 #define _CRASH_REPORTER_CRASH_COLLECTOR_H_ |
| 7 | 7 |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 IsFeedbackAllowedFunction is_metrics_allowed, | 32 IsFeedbackAllowedFunction is_metrics_allowed, |
| 33 SystemLogging *logger); | 33 SystemLogging *logger); |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 friend class CrashCollectorTest; | 36 friend class CrashCollectorTest; |
| 37 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityCorrectBasename); | 37 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityCorrectBasename); |
| 38 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityStrangeNames); | 38 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityStrangeNames); |
| 39 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityUsual); | 39 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityUsual); |
| 40 FRIEND_TEST(CrashCollectorTest, GetCrashDirectoryInfo); | 40 FRIEND_TEST(CrashCollectorTest, GetCrashDirectoryInfo); |
| 41 FRIEND_TEST(CrashCollectorTest, GetCrashPath); | 41 FRIEND_TEST(CrashCollectorTest, GetCrashPath); |
| 42 FRIEND_TEST(CrashCollectorTest, GetLogContents); |
| 42 FRIEND_TEST(CrashCollectorTest, ForkExecAndPipe); | 43 FRIEND_TEST(CrashCollectorTest, ForkExecAndPipe); |
| 43 FRIEND_TEST(CrashCollectorTest, FormatDumpBasename); | 44 FRIEND_TEST(CrashCollectorTest, FormatDumpBasename); |
| 44 FRIEND_TEST(CrashCollectorTest, Initialize); | 45 FRIEND_TEST(CrashCollectorTest, Initialize); |
| 46 FRIEND_TEST(CrashCollectorTest, IsCommentLine); |
| 45 FRIEND_TEST(CrashCollectorTest, MetaData); | 47 FRIEND_TEST(CrashCollectorTest, MetaData); |
| 46 FRIEND_TEST(CrashCollectorTest, ReadKeyValueFile); | 48 FRIEND_TEST(CrashCollectorTest, ReadKeyValueFile); |
| 47 FRIEND_TEST(CrashCollectorTest, Sanitize); | 49 FRIEND_TEST(CrashCollectorTest, Sanitize); |
| 48 FRIEND_TEST(CrashCollectorTest, WriteNewFile); | 50 FRIEND_TEST(CrashCollectorTest, WriteNewFile); |
| 49 | 51 |
| 50 // Set maximum enqueued crashes in a crash directory. | 52 // Set maximum enqueued crashes in a crash directory. |
| 51 static const int kMaxCrashDirectorySize; | 53 static const int kMaxCrashDirectorySize; |
| 52 | 54 |
| 53 // Writes |data| of |size| to |filename|, which must be a new file. | 55 // Writes |data| of |size| to |filename|, which must be a new file. |
| 54 // If the file already exists or writing fails, return a negative value. | 56 // If the file already exists or writing fails, return a negative value. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Create a file path to a file in |crash_directory| with the given | 97 // Create a file path to a file in |crash_directory| with the given |
| 96 // |basename| and |extension|. | 98 // |basename| and |extension|. |
| 97 FilePath GetCrashPath(const FilePath &crash_directory, | 99 FilePath GetCrashPath(const FilePath &crash_directory, |
| 98 const std::string &basename, | 100 const std::string &basename, |
| 99 const std::string &extension); | 101 const std::string &extension); |
| 100 | 102 |
| 101 // Check given crash directory still has remaining capacity for another | 103 // Check given crash directory still has remaining capacity for another |
| 102 // crash. | 104 // crash. |
| 103 bool CheckHasCapacity(const FilePath &crash_directory); | 105 bool CheckHasCapacity(const FilePath &crash_directory); |
| 104 | 106 |
| 107 // Checks if the line starts with '#' after optional whitespace. |
| 108 static bool IsCommentLine(const std::string &line); |
| 109 |
| 105 // Read the given file of form [<key><separator><value>\n...] and return | 110 // Read the given file of form [<key><separator><value>\n...] and return |
| 106 // a map of its contents. | 111 // a map of its contents. |
| 107 bool ReadKeyValueFile(const FilePath &file, | 112 bool ReadKeyValueFile(const FilePath &file, |
| 108 char separator, | 113 char separator, |
| 109 std::map<std::string, std::string> *dictionary); | 114 std::map<std::string, std::string> *dictionary); |
| 110 | 115 |
| 116 // Write a log applicable to |exec_name| to |output_file| based on the |
| 117 // log configuration file at |config_path|. |
| 118 bool GetLogContents(const FilePath &config_path, |
| 119 const std::string &exec_name, |
| 120 const FilePath &output_file); |
| 121 |
| 111 // Add non-standard meta data to the crash metadata file. Call | 122 // Add non-standard meta data to the crash metadata file. Call |
| 112 // before calling WriteCrashMetaData. Key must not contain "=" or | 123 // before calling WriteCrashMetaData. Key must not contain "=" or |
| 113 // "\n" characters. Value must not contain "\n" characters. | 124 // "\n" characters. Value must not contain "\n" characters. |
| 114 void AddCrashMetaData(const std::string &key, const std::string &value); | 125 void AddCrashMetaData(const std::string &key, const std::string &value); |
| 115 | 126 |
| 116 // Write a file of metadata about crash. | 127 // Write a file of metadata about crash. |
| 117 void WriteCrashMetaData(const FilePath &meta_path, | 128 void WriteCrashMetaData(const FilePath &meta_path, |
| 118 const std::string &exec_name, | 129 const std::string &exec_name, |
| 119 const std::string &payload_path); | 130 const std::string &payload_path); |
| 120 | 131 |
| 121 CountCrashFunction count_crash_function_; | 132 CountCrashFunction count_crash_function_; |
| 122 IsFeedbackAllowedFunction is_feedback_allowed_function_; | 133 IsFeedbackAllowedFunction is_feedback_allowed_function_; |
| 123 SystemLogging *logger_; | 134 SystemLogging *logger_; |
| 124 std::string extra_metadata_; | 135 std::string extra_metadata_; |
| 125 const char *forced_crash_directory_; | 136 const char *forced_crash_directory_; |
| 126 const char *lsb_release_; | 137 const char *lsb_release_; |
| 127 }; | 138 }; |
| 128 | 139 |
| 129 #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ | 140 #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ |
| OLD | NEW |