OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/tools/crash_service/crash_service.h" | |
6 | |
7 #include <windows.h> | 5 #include <windows.h> |
8 #include <stdlib.h> | 6 #include <stdlib.h> |
9 #include <tchar.h> | 7 #include <tchar.h> |
10 | 8 |
11 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
12 #include "base/command_line.h" | 10 #include "base/command_line.h" |
13 #include "base/file_util.h" | 11 #include "base/file_util.h" |
14 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/path_service.h" | |
14 #include "chrome/common/chrome_constants.h" | |
15 #include "chrome/common/chrome_paths.h" | |
16 #include "components/breakpad/tools/crash_service.h" | |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 const wchar_t kStandardLogFile[] = L"operation_log.txt"; | 20 const wchar_t kStandardLogFile[] = L"operation_log.txt"; |
19 | 21 |
20 bool GetCrashServiceDirectory(base::FilePath* dir) { | 22 bool GetCrashServiceDirectory(base::FilePath* dir) { |
21 base::FilePath temp_dir; | 23 base::FilePath temp_dir; |
22 if (!file_util::GetTempDir(&temp_dir)) | 24 if (!file_util::GetTempDir(&temp_dir)) |
23 return false; | 25 return false; |
24 temp_dir = temp_dir.Append(L"chrome_crashes"); | 26 temp_dir = temp_dir.Append(L"chrome_crashes"); |
25 if (!base::PathExists(temp_dir)) { | 27 if (!base::PathExists(temp_dir)) { |
26 if (!file_util::CreateDirectory(temp_dir)) | 28 if (!file_util::CreateDirectory(temp_dir)) |
27 return false; | 29 return false; |
28 } | 30 } |
29 *dir = temp_dir; | 31 *dir = temp_dir; |
30 return true; | 32 return true; |
31 } | 33 } |
32 | 34 |
33 } // namespace. | 35 } // namespace. |
34 | 36 |
35 int __stdcall wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd_line, | 37 int __stdcall wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd_line, |
36 int show_mode) { | 38 int show_mode) { |
37 // Manages the destruction of singletons. | 39 // Manages the destruction of singletons. |
38 base::AtExitManager exit_manager; | 40 base::AtExitManager exit_manager; |
39 | 41 |
40 CommandLine::Init(0, NULL); | 42 CommandLine::Init(0, NULL); |
41 | 43 |
44 chrome::RegisterPathProvider(); | |
45 | |
42 // We use/create a directory under the user's temp folder, for logging. | 46 // We use/create a directory under the user's temp folder, for logging. |
43 base::FilePath operating_dir; | 47 base::FilePath operating_dir; |
44 GetCrashServiceDirectory(&operating_dir); | 48 GetCrashServiceDirectory(&operating_dir); |
45 base::FilePath log_file = operating_dir.Append(kStandardLogFile); | 49 base::FilePath log_file = operating_dir.Append(kStandardLogFile); |
46 | 50 |
47 // Logging to stderr (to help with debugging failures on the | 51 // Logging to stderr (to help with debugging failures on the |
48 // buildbots) and to a file. | 52 // buildbots) and to a file. |
49 logging::LoggingSettings settings; | 53 logging::LoggingSettings settings; |
50 settings.logging_dest = logging::LOG_TO_ALL; | 54 settings.logging_dest = logging::LOG_TO_ALL; |
51 settings.log_file = log_file.value().c_str(); | 55 settings.log_file = log_file.value().c_str(); |
52 logging::InitLogging(settings); | 56 logging::InitLogging(settings); |
53 // Logging with pid, tid and timestamp. | 57 // Logging with pid, tid and timestamp. |
54 logging::SetLogItems(true, true, true, false); | 58 logging::SetLogItems(true, true, true, false); |
55 | 59 |
56 VLOG(1) << "session start. cmdline is [" << cmd_line << "]"; | 60 VLOG(1) << "session start. cmdline is [" << cmd_line << "]"; |
57 | 61 |
58 CrashService crash_service(operating_dir.value()); | 62 // The dumps path is typically : '<user profile>\Local settings\ |
Robert Sesek
2013/10/17 13:16:05
Does path case matter in windows? I think it's |Lo
jochen (gone - plz use gerrit)
2013/10/17 16:47:39
Done.
| |
59 if (!crash_service.Initialize(::GetCommandLineW())) | 63 // Application data\Goggle\Chrome\Crash Reports' and the report path is |
64 // Application data\Google\Chrome\Reported Crashes.txt | |
65 base::FilePath user_data_dir; | |
66 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | |
67 LOG(ERROR) << "could not get DIR_USER_DATA"; | |
68 return false; | |
69 } | |
70 base::FilePath report_path = user_data_dir.Append(chrome::kCrashReportLog); | |
71 | |
72 base::FilePath dumps_path; | |
73 if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) { | |
74 LOG(ERROR) << "could not get DIR_CRASH_DUMPS"; | |
75 return 1; | |
76 } | |
77 | |
78 breakpad::CrashService crash_service; | |
79 if (!crash_service.Initialize(operating_dir, report_path, dumps_path)) | |
60 return 1; | 80 return 1; |
61 | 81 |
62 VLOG(1) << "ready to process crash requests"; | 82 VLOG(1) << "ready to process crash requests"; |
63 | 83 |
64 // Enter the message loop. | 84 // Enter the message loop. |
65 int retv = crash_service.ProcessingLoop(); | 85 int retv = crash_service.ProcessingLoop(); |
66 // Time to exit. | 86 // Time to exit. |
67 VLOG(1) << "session end. return code is " << retv; | 87 VLOG(1) << "session end. return code is " << retv; |
68 return retv; | 88 return retv; |
69 } | 89 } |
OLD | NEW |