Commit 5799f48f authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Add base::debug::ScopedCrashKeyString.

This is the new version of base::debug::ScopedCrashKey.

Bug: 598854
Change-Id: Idfea07f414c4c68fb51909de467c8e666acd841d
Reviewed-on: https://chromium-review.googlesource.com/811287
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522145}
parent 0935af53
...@@ -73,6 +73,16 @@ void ClearCrashKeyString(CrashKeyString* crash_key) { ...@@ -73,6 +73,16 @@ void ClearCrashKeyString(CrashKeyString* crash_key) {
g_crash_key_impl->Clear(crash_key); g_crash_key_impl->Clear(crash_key);
} }
ScopedCrashKeyString::ScopedCrashKeyString(CrashKeyString* crash_key,
base::StringPiece value)
: crash_key_(crash_key) {
SetCrashKeyString(crash_key_, value);
}
ScopedCrashKeyString::~ScopedCrashKeyString() {
ClearCrashKeyString(crash_key_);
}
void SetCrashKeyImplementation(std::unique_ptr<CrashKeyImplementation> impl) { void SetCrashKeyImplementation(std::unique_ptr<CrashKeyImplementation> impl) {
delete g_crash_key_impl; delete g_crash_key_impl;
g_crash_key_impl = impl.release(); g_crash_key_impl = impl.release();
......
...@@ -59,6 +59,19 @@ BASE_EXPORT void SetCrashKeyString(CrashKeyString* crash_key, ...@@ -59,6 +59,19 @@ BASE_EXPORT void SetCrashKeyString(CrashKeyString* crash_key,
// null. // null.
BASE_EXPORT void ClearCrashKeyString(CrashKeyString* crash_key); BASE_EXPORT void ClearCrashKeyString(CrashKeyString* crash_key);
// A scoper that sets the specified key to value for the lifetime of the
// object, and clears it on destruction.
class BASE_EXPORT ScopedCrashKeyString {
public:
ScopedCrashKeyString(CrashKeyString* crash_key, base::StringPiece value);
~ScopedCrashKeyString();
private:
CrashKeyString* const crash_key_;
DISALLOW_COPY_AND_ASSIGN(ScopedCrashKeyString);
};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// The following declarations are used to initialize the crash key system // The following declarations are used to initialize the crash key system
// in //base by providing implementations for the above functions. // in //base by providing implementations for the above functions.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment