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

Side by Side Diff: crash_collector.h

Issue 3209003: Limit the number of crash reports to enqueue at once (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git
Patch Set: Respond to reviews Created 10 years, 3 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 | « no previous file | 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 <string> 8 #include <string>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 // Initialize the crash collector for detection of crashes, given a 26 // Initialize the crash collector for detection of crashes, given a
27 // crash counting function, metrics collection enabled oracle, and 27 // crash counting function, metrics collection enabled oracle, and
28 // system logger facility. 28 // system logger facility.
29 void Initialize(CountCrashFunction count_crash, 29 void Initialize(CountCrashFunction count_crash,
30 IsFeedbackAllowedFunction is_metrics_allowed, 30 IsFeedbackAllowedFunction is_metrics_allowed,
31 SystemLogging *logger); 31 SystemLogging *logger);
32 32
33 protected: 33 protected:
34 friend class CrashCollectorTest; 34 friend class CrashCollectorTest;
35 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityOverCore);
36 FRIEND_TEST(CrashCollectorTest, CheckHasCapacityOverNonCore);
35 FRIEND_TEST(CrashCollectorTest, GetCrashDirectoryInfo); 37 FRIEND_TEST(CrashCollectorTest, GetCrashDirectoryInfo);
36 FRIEND_TEST(CrashCollectorTest, FormatDumpBasename); 38 FRIEND_TEST(CrashCollectorTest, FormatDumpBasename);
37 FRIEND_TEST(CrashCollectorTest, Initialize); 39 FRIEND_TEST(CrashCollectorTest, Initialize);
38 40
41 // Set maximum enqueued crashes in a crash directory.
42 static const int kMaxCrashDirectorySize;
43
39 // For testing, set the directory always returned by 44 // For testing, set the directory always returned by
40 // GetCreatedCrashDirectoryByEuid. 45 // GetCreatedCrashDirectoryByEuid.
41 void ForceCrashDirectory(const char *forced_directory) { 46 void ForceCrashDirectory(const char *forced_directory) {
42 forced_crash_directory_ = forced_directory; 47 forced_crash_directory_ = forced_directory;
43 } 48 }
44 49
45 FilePath GetCrashDirectoryInfo(uid_t process_euid, 50 FilePath GetCrashDirectoryInfo(uid_t process_euid,
46 uid_t default_user_id, 51 uid_t default_user_id,
47 gid_t default_user_group, 52 gid_t default_user_group,
48 mode_t *mode, 53 mode_t *mode,
49 uid_t *directory_owner, 54 uid_t *directory_owner,
50 gid_t *directory_group); 55 gid_t *directory_group);
51 bool GetUserInfoFromName(const std::string &name, 56 bool GetUserInfoFromName(const std::string &name,
52 uid_t *uid, 57 uid_t *uid,
53 gid_t *gid); 58 gid_t *gid);
54 // Determines the crash directory for given eud, and creates the 59 // Determines the crash directory for given eud, and creates the
55 // directory if necessary with appropriate permissions. Returns 60 // directory if necessary with appropriate permissions. Returns
56 // true whether or not directory needed to be created, false on any 61 // true whether or not directory needed to be created, false on any
57 // failure. 62 // failure. If the crash directory is already full, returns false.
58 bool GetCreatedCrashDirectoryByEuid(uid_t euid, 63 bool GetCreatedCrashDirectoryByEuid(uid_t euid,
59 FilePath *crash_file_path); 64 FilePath *crash_file_path);
65
66 // Format crash name based on components.
60 std::string FormatDumpBasename(const std::string &exec_name, 67 std::string FormatDumpBasename(const std::string &exec_name,
61 time_t timestamp, 68 time_t timestamp,
62 pid_t pid); 69 pid_t pid);
63 70
71 // Check given crash directory still has remaining capacity for another
72 // crash.
73 bool CheckHasCapacity(const FilePath &crash_directory);
74
64 CountCrashFunction count_crash_function_; 75 CountCrashFunction count_crash_function_;
65 IsFeedbackAllowedFunction is_feedback_allowed_function_; 76 IsFeedbackAllowedFunction is_feedback_allowed_function_;
66 SystemLogging *logger_; 77 SystemLogging *logger_;
67 const char *forced_crash_directory_; 78 const char *forced_crash_directory_;
68 }; 79 };
69 80
70 #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ 81 #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_
OLDNEW
« no previous file with comments | « no previous file | crash_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698