| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/common/dump_without_crashing.h" | 7 #include "chrome/common/dump_without_crashing.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
| 11 | 11 |
| 12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 13 #include <windows.h> | 13 #include <windows.h> |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 #if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) | 18 #if defined(OS_POSIX) |
| 19 // Pointer to the function that's called by DumpWithoutCrashing() to dump the | 19 // Pointer to the function that's called by DumpWithoutCrashing() to dump the |
| 20 // process's memory. | 20 // process's memory. |
| 21 void (*dump_without_crashing_function_)() = NULL; | 21 void (*dump_without_crashing_function_)() = NULL; |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 namespace logging { | 26 namespace logging { |
| 27 | 27 |
| 28 void DumpWithoutCrashing() { | 28 void DumpWithoutCrashing() { |
| 29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 30 // Get the breakpad pointer from chrome.exe | 30 // Get the breakpad pointer from chrome.exe |
| 31 typedef void (__cdecl *DumpProcessFunction)(); | 31 typedef void (__cdecl *DumpProcessFunction)(); |
| 32 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( | 32 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( |
| 33 ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName), | 33 ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName), |
| 34 "DumpProcess")); | 34 "DumpProcess")); |
| 35 if (DumpProcess) | 35 if (DumpProcess) |
| 36 DumpProcess(); | 36 DumpProcess(); |
| 37 #elif defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) | 37 #elif defined(OS_POSIX) |
| 38 if (dump_without_crashing_function_) | 38 if (dump_without_crashing_function_) |
| 39 (*dump_without_crashing_function_)(); | 39 (*dump_without_crashing_function_)(); |
| 40 #else | 40 #else |
| 41 NOTIMPLEMENTED(); | 41 NOTIMPLEMENTED(); |
| 42 #endif | 42 #endif |
| 43 } | 43 } |
| 44 | 44 |
| 45 #if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) | 45 #if defined(OS_POSIX) |
| 46 void SetDumpWithoutCrashingFunction(void (*function)()) { | 46 void SetDumpWithoutCrashingFunction(void (*function)()) { |
| 47 dump_without_crashing_function_ = function; | 47 dump_without_crashing_function_ = function; |
| 48 } | 48 } |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 } // namespace logging | 51 } // namespace logging |
| OLD | NEW |