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

Side by Side Diff: base/debug/crash_logging.h

Issue 11761030: Create the crash key registration system and register some Mac-specific keys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_DEBUG_CRASH_LOGGING_H_ 5 #ifndef BASE_DEBUG_CRASH_LOGGING_H_
6 #define BASE_DEBUG_CRASH_LOGGING_H_ 6 #define BASE_DEBUG_CRASH_LOGGING_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 public: 44 public:
45 ScopedCrashKey(const base::StringPiece& key, const base::StringPiece& value); 45 ScopedCrashKey(const base::StringPiece& key, const base::StringPiece& value);
46 ~ScopedCrashKey(); 46 ~ScopedCrashKey();
47 47
48 private: 48 private:
49 std::string key_; 49 std::string key_;
50 50
51 DISALLOW_COPY_AND_ASSIGN(ScopedCrashKey); 51 DISALLOW_COPY_AND_ASSIGN(ScopedCrashKey);
52 }; 52 };
53 53
54 // Before setting values for a key, all the keys must be registered.
55 struct BASE_EXPORT CrashKey {
56 // The name of the crash key, used in the above functions.
57 const char* const key_name;
58
59 // For values longer than max_length, the value can be chunked into values
60 // named "key_name-1", "key_name-2", etc. This is the maximum number of
61 // numbered chunks to use before the value is truncated.
62 size_t num_chunks;
63
64 // The maximum length of a single chunk. Truncation happens if the value is
65 // greater than |num_chunks * max_length|.
66 size_t max_length;
67 };
68
69 // Before the crash key logging mechanism can be used, all crash keys must be
70 // registered with this function. The crash reporting implementation should
71 // allocate space for exactly |out_key_storage_size| crash keys.
72 BASE_EXPORT void InitCrashKeys(const CrashKey* const keys, size_t count,
73 size_t* out_key_storage_size);
Scott Hess - ex-Googler 2013/01/09 22:34:20 I'm still -1 on having a size_t* out parameter whe
Robert Sesek 2013/01/09 23:06:30 OK, I don't feel strongly enough to argue ;). Done
74
75 // Returns the correspnding crash key object or NULL for a given key.
76 BASE_EXPORT const CrashKey* LookupCrashKey(const base::StringPiece& key);
77
54 typedef void (*SetCrashKeyValueFuncT)(const base::StringPiece&, 78 typedef void (*SetCrashKeyValueFuncT)(const base::StringPiece&,
55 const base::StringPiece&); 79 const base::StringPiece&);
56 typedef void (*ClearCrashKeyValueFuncT)(const base::StringPiece&); 80 typedef void (*ClearCrashKeyValueFuncT)(const base::StringPiece&);
57 81
58 // Sets the function pointers that are used to integrate with the platform- 82 // Sets the function pointers that are used to integrate with the platform-
59 // specific crash reporting libraries. 83 // specific crash reporting libraries.
60 BASE_EXPORT void SetCrashKeyReportingFunctions( 84 BASE_EXPORT void SetCrashKeyReportingFunctions(
61 SetCrashKeyValueFuncT set_key_func, 85 SetCrashKeyValueFuncT set_key_func,
62 ClearCrashKeyValueFuncT clear_key_func); 86 ClearCrashKeyValueFuncT clear_key_func);
63 87
88 // Helper function that breaks up a value according to the parameters
89 // specified by the crash key object.
90 BASE_EXPORT std::vector<std::string> ChunkCrashKeyValue(
91 const CrashKey& crash_key, const base::StringPiece& value);
92
93 // Resets the crash key system so it can be reinitialized. For testing only.
94 BASE_EXPORT void ResetCrashLoggingForTesting();
95
64 } // namespace debug 96 } // namespace debug
65 } // namespace base 97 } // namespace base
66 98
67 #endif // BASE_DEBUG_CRASH_LOGGING_H_ 99 #endif // BASE_DEBUG_CRASH_LOGGING_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/debug/crash_logging.cc » ('j') | base/debug/crash_logging.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698