| 6 |
| 7 | namespace base { |
| 8 | namespace debug { |
| 9 |
| 10 | namespace { |
| 11 |
| 12 | CrashKeyImplementation* g_crash_key_impl = nullptr; |
| 13 |
| 14 | } // namespace |
| 15 |
| 16 | CrashKeyString* AllocateCrashKeyString(const char name[], |
| 17 | CrashKeySize value_length) { |
| 18 | if (!g_crash_key_impl) |
| 19 | return nullptr; |
| 20 |
| 21 | return g_crash_key_impl->Allocate(name, value_length); |
| 22 | } |
| 23 |
| 24 | void SetCrashKeyString(CrashKeyString* crash_key, base::StringPiece value) { |
| 25 | if (!g_crash_key_impl || !crash_key) |
| 26 | return; |
| 27 |
| 28 | g_crash_key_impl->Set(crash_key, value); |
| 29 | } |
| 30 |
| 31 | void ClearCrashKeyString(CrashKeyString* crash_key) { |
| 32 | if (!g_crash_key_impl || !crash_key) |
| 33 | return; |
| 34 |
| 35 | g_crash_key_impl->Clear(crash_key); |
| 36 | } |
| 37 |
| 38 | ScopedCrashKeyString::ScopedCrashKeyString(CrashKeyString* crash_key, |
| 39 | base::StringPiece value) |
| 40 | : crash_key_(crash_key) { |
| 41 | SetCrashKeyString(crash_key_, value); |
| 42 | } |
| 43 |
| 44 | ScopedCrashKeyString::~ScopedCrashKeyString() { |
| 45 | ClearCrashKeyString(crash_key_); |
| 46 | } |
| 47 |
| 48 | void SetCrashKeyImplementation(std::unique_ptr<CrashKeyImplementation> impl) { |
| 49 | delete g_crash_key_impl; |
| 50 | g_crash_key_impl = impl.release(); |
| 51 | } |
| 52 |
| 53 | } // namespace debug |
| 54 | } // namespace base |
| 55 |