- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / glue / chrome_report_unrecoverable_error.cc
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
6
7 #include "base/rand_util.h"
8 #include "build/build_config.h"
9
10 #if defined(OS_WIN)
11 #include <windows.h>
12 #endif
13
14 #include "chrome/common/chrome_constants.h"
15
16 namespace browser_sync {
17
18 void ChromeReportUnrecoverableError() {
19   // TODO(lipalani): Add this for other platforms as well.
20 #if defined(OS_WIN)
21   const double kErrorUploadRatio = 0.0;
22
23   // We only want to upload |kErrorUploadRatio| ratio of errors.
24   if (kErrorUploadRatio <= 0.0)
25     return; // We are not allowed to upload errors.
26   double random_number = base::RandDouble();
27   if (random_number > kErrorUploadRatio)
28     return;
29
30   // Get the breakpad pointer from chrome.exe
31   typedef void (__cdecl *DumpProcessFunction)();
32   DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
33       ::GetProcAddress(::GetModuleHandle(
34                        chrome::kBrowserProcessExecutableName),
35                        "DumpProcessWithoutCrash"));
36   if (DumpProcess)
37     DumpProcess();
38 #endif  // OS_WIN
39
40 }
41
42 }  // namespace browser_sync