Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: crash_collector.h

Issue 6517001: crash-reporter: Use standard logging and new libchromeos Process code (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crash-reporter.git@master
Patch Set: More comments Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Makefile ('k') | crash_collector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "gtest/gtest_prod.h" // for FRIEND_TEST 14 #include "gtest/gtest_prod.h" // for FRIEND_TEST
15 15
16 class SystemLogging;
17
18 // User crash collector. 16 // User crash collector.
19 class CrashCollector { 17 class CrashCollector {
20 public: 18 public:
21 typedef void (*CountCrashFunction)(); 19 typedef void (*CountCrashFunction)();
22 typedef bool (*IsFeedbackAllowedFunction)(); 20 typedef bool (*IsFeedbackAllowedFunction)();
23 21
24 CrashCollector(); 22 CrashCollector();
25 23
26 virtual ~CrashCollector(); 24 virtual ~CrashCollector();
27 25
28 // Initialize the crash collector for detection of crashes, given a 26 // Initialize the crash collector for detection of crashes, given a
29 // crash counting function, metrics collection enabled oracle, and 27 // crash counting function, and metrics collection enabled oracle.
30 // system logger facility.
31 void Initialize(CountCrashFunction count_crash, 28 void Initialize(CountCrashFunction count_crash,
32 IsFeedbackAllowedFunction is_metrics_allowed, 29 IsFeedbackAllowedFunction is_metrics_allowed);
33 SystemLogging *logger);
34 30
35 protected: 31 protected:
36 friend class CrashCollectorTest; 32 friend class CrashCollectorTest;
37 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityCorrectBasename); 33 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityCorrectBasename);
38 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityStrangeNames); 34 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityStrangeNames);
39 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityUsual); 35 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityUsual);
40 FRIEND_TEST(CrashCollectorTest, GetCrashDirectoryInfo); 36 FRIEND_TEST(CrashCollectorTest, GetCrashDirectoryInfo);
41 FRIEND_TEST(CrashCollectorTest, GetCrashPath); 37 FRIEND_TEST(CrashCollectorTest, GetCrashPath);
42 FRIEND_TEST(CrashCollectorTest, GetLogContents); 38 FRIEND_TEST(CrashCollectorTest, GetLogContents);
43 FRIEND_TEST(CrashCollectorTest, ForkExecAndPipe); 39 FRIEND_TEST(CrashCollectorTest, ForkExecAndPipe);
(...skipping 15 matching lines...) Expand all
59 FRIEND_TEST(ForkExecAndPipeTest, SegFaultHandling); 55 FRIEND_TEST(ForkExecAndPipeTest, SegFaultHandling);
60 56
61 // Set maximum enqueued crashes in a crash directory. 57 // Set maximum enqueued crashes in a crash directory.
62 static const int kMaxCrashDirectorySize; 58 static const int kMaxCrashDirectorySize;
63 59
64 // Writes |data| of |size| to |filename|, which must be a new file. 60 // Writes |data| of |size| to |filename|, which must be a new file.
65 // If the file already exists or writing fails, return a negative value. 61 // If the file already exists or writing fails, return a negative value.
66 // Otherwise returns the number of bytes written. 62 // Otherwise returns the number of bytes written.
67 int WriteNewFile(const FilePath &filename, const char *data, int size); 63 int WriteNewFile(const FilePath &filename, const char *data, int size);
68 64
69 int ForkExecAndPipe(std::vector<const char *> &arguments,
70 const char *output_file);
71
72 // Return a filename that has only [a-z0-1_] characters by mapping 65 // Return a filename that has only [a-z0-1_] characters by mapping
73 // all others into '_'. 66 // all others into '_'.
74 std::string Sanitize(const std::string &name); 67 std::string Sanitize(const std::string &name);
75 68
76 // For testing, set the directory always returned by 69 // For testing, set the directory always returned by
77 // GetCreatedCrashDirectoryByEuid. 70 // GetCreatedCrashDirectoryByEuid.
78 void ForceCrashDirectory(const char *forced_directory) { 71 void ForceCrashDirectory(const char *forced_directory) {
79 forced_crash_directory_ = forced_directory; 72 forced_crash_directory_ = forced_directory;
80 } 73 }
81 74
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // "\n" characters. Value must not contain "\n" characters. 126 // "\n" characters. Value must not contain "\n" characters.
134 void AddCrashMetaData(const std::string &key, const std::string &value); 127 void AddCrashMetaData(const std::string &key, const std::string &value);
135 128
136 // Write a file of metadata about crash. 129 // Write a file of metadata about crash.
137 void WriteCrashMetaData(const FilePath &meta_path, 130 void WriteCrashMetaData(const FilePath &meta_path,
138 const std::string &exec_name, 131 const std::string &exec_name,
139 const std::string &payload_path); 132 const std::string &payload_path);
140 133
141 CountCrashFunction count_crash_function_; 134 CountCrashFunction count_crash_function_;
142 IsFeedbackAllowedFunction is_feedback_allowed_function_; 135 IsFeedbackAllowedFunction is_feedback_allowed_function_;
143 SystemLogging *logger_;
144 std::string extra_metadata_; 136 std::string extra_metadata_;
145 const char *forced_crash_directory_; 137 const char *forced_crash_directory_;
146 const char *lsb_release_; 138 const char *lsb_release_;
147 }; 139 };
148 140
149 #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ 141 #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_
OLDNEW
« no previous file with comments | « Makefile ('k') | crash_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698