Index: chrome/common/dump_without_crashing.cc |
diff --git a/chrome/common/dump_without_crashing.cc b/chrome/common/dump_without_crashing.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8c692e49c7b21f15da3b9393e50a583131ff09c5 |
--- /dev/null |
+++ b/chrome/common/dump_without_crashing.cc |
@@ -0,0 +1,50 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "build/build_config.h" |
+ |
+#include "chrome/common/dump_without_crashing.h" |
+ |
+#include "chrome/common/chrome_constants.h" |
+ |
+#if defined(OS_WIN) |
+#include <windows.h> |
+#endif |
+ |
+namespace { |
+ |
+#if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) |
+// Pointer to the function that's called by DumpWithoutCrashing() to dump the |
+// process's memory. |
+void (*dump_without_crashing_function_)() = NULL; |
+#endif |
+ |
+} // namespace |
+ |
+namespace logging { |
+ |
+void DumpWithoutCrashing() { |
+#if defined(OS_WIN) |
+ // Get the breakpad pointer from chrome.exe |
+ typedef void (__cdecl *DumpProcessFunction)(); |
+ DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( |
+ ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName), |
+ "DumpProcess")); |
+ if (DumpProcess) |
+ DumpProcess(); |
+#elif defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) |
+ if (dump_without_crashing_function_) |
+ (*dump_without_crashing_function_)(); |
+#else |
+ NOTIMPLEMENTED(); |
+#endif |
+} |
+ |
+#if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) |
+void SetDumpWithoutCrashingFunction(void (*function)()) { |
+ dump_without_crashing_function_ = function; |
+} |
+#endif |
+ |
+} // namespace logging |