| OLD | NEW |
| 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 Loading... |
| 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 chunk_max_length, the value can be chunked into |
| 60 // values 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 |
| 65 // Before the crash key logging mechanism can be used, all crash keys must be |
| 66 // registered with this function. The function returns the amount of space |
| 67 // the crash reporting implementation should allocate space for the registered |
| 68 // crash keys. |chunk_max_length| is the maximum size that a value in a single |
| 69 // chunk can be. |
| 70 BASE_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count, |
| 71 size_t chunk_max_length); |
| 72 |
| 73 // Returns the correspnding crash key object or NULL for a given key. |
| 74 BASE_EXPORT const CrashKey* LookupCrashKey(const base::StringPiece& key); |
| 75 |
| 54 typedef void (*SetCrashKeyValueFuncT)(const base::StringPiece&, | 76 typedef void (*SetCrashKeyValueFuncT)(const base::StringPiece&, |
| 55 const base::StringPiece&); | 77 const base::StringPiece&); |
| 56 typedef void (*ClearCrashKeyValueFuncT)(const base::StringPiece&); | 78 typedef void (*ClearCrashKeyValueFuncT)(const base::StringPiece&); |
| 57 | 79 |
| 58 // Sets the function pointers that are used to integrate with the platform- | 80 // Sets the function pointers that are used to integrate with the platform- |
| 59 // specific crash reporting libraries. | 81 // specific crash reporting libraries. |
| 60 BASE_EXPORT void SetCrashKeyReportingFunctions( | 82 BASE_EXPORT void SetCrashKeyReportingFunctions( |
| 61 SetCrashKeyValueFuncT set_key_func, | 83 SetCrashKeyValueFuncT set_key_func, |
| 62 ClearCrashKeyValueFuncT clear_key_func); | 84 ClearCrashKeyValueFuncT clear_key_func); |
| 63 | 85 |
| 86 // Helper function that breaks up a value according to the parameters |
| 87 // specified by the crash key object. |
| 88 BASE_EXPORT std::vector<std::string> ChunkCrashKeyValue( |
| 89 const CrashKey& crash_key, |
| 90 const base::StringPiece& value, |
| 91 size_t chunk_max_length); |
| 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_ |
| OLD | NEW |