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, ForkExecAndPipe); |
42 FRIEND_TEST(CrashCollectorTest, FormatDumpBasename); | 43 FRIEND_TEST(CrashCollectorTest, FormatDumpBasename); |
43 FRIEND_TEST(CrashCollectorTest, Initialize); | 44 FRIEND_TEST(CrashCollectorTest, Initialize); |
44 FRIEND_TEST(CrashCollectorTest, MetaData); | 45 FRIEND_TEST(CrashCollectorTest, MetaData); |
45 FRIEND_TEST(CrashCollectorTest, ReadKeyValueFile); | 46 FRIEND_TEST(CrashCollectorTest, ReadKeyValueFile); |
46 FRIEND_TEST(CrashCollectorTest, Sanitize); | 47 FRIEND_TEST(CrashCollectorTest, Sanitize); |
| 48 FRIEND_TEST(CrashCollectorTest, WriteNewFile); |
47 | 49 |
48 // Set maximum enqueued crashes in a crash directory. | 50 // Set maximum enqueued crashes in a crash directory. |
49 static const int kMaxCrashDirectorySize; | 51 static const int kMaxCrashDirectorySize; |
50 | 52 |
| 53 // 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. |
| 55 // Otherwise returns the number of bytes written. |
| 56 int WriteNewFile(const FilePath &filename, const char *data, int size); |
| 57 |
| 58 int ForkExecAndPipe(std::vector<const char *> &arguments, |
| 59 const char *output_file); |
| 60 |
51 // Return a filename that has only [a-z0-1_] characters by mapping | 61 // Return a filename that has only [a-z0-1_] characters by mapping |
52 // all others into '_'. | 62 // all others into '_'. |
53 std::string Sanitize(const std::string &name); | 63 std::string Sanitize(const std::string &name); |
54 | 64 |
55 // For testing, set the directory always returned by | 65 // For testing, set the directory always returned by |
56 // GetCreatedCrashDirectoryByEuid. | 66 // GetCreatedCrashDirectoryByEuid. |
57 void ForceCrashDirectory(const char *forced_directory) { | 67 void ForceCrashDirectory(const char *forced_directory) { |
58 forced_crash_directory_ = forced_directory; | 68 forced_crash_directory_ = forced_directory; |
59 } | 69 } |
60 | 70 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 120 |
111 CountCrashFunction count_crash_function_; | 121 CountCrashFunction count_crash_function_; |
112 IsFeedbackAllowedFunction is_feedback_allowed_function_; | 122 IsFeedbackAllowedFunction is_feedback_allowed_function_; |
113 SystemLogging *logger_; | 123 SystemLogging *logger_; |
114 std::string extra_metadata_; | 124 std::string extra_metadata_; |
115 const char *forced_crash_directory_; | 125 const char *forced_crash_directory_; |
116 const char *lsb_release_; | 126 const char *lsb_release_; |
117 }; | 127 }; |
118 | 128 |
119 #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ | 129 #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ |
OLD | NEW |