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
3 // found in the LICENSE file.
9 #include "base/at_exit.h"
10 #include "base/command_line.h"
11 #include "base/files/file_util.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/crash/tools/crash_service.h"
20 const wchar_t kStandardLogFile
[] = L
"operation_log.txt";
22 bool GetCrashServiceDirectory(base::FilePath
* dir
) {
23 base::FilePath temp_dir
;
24 if (!base::GetTempDir(&temp_dir
))
26 temp_dir
= temp_dir
.Append(L
"chrome_crashes");
27 if (!base::PathExists(temp_dir
)) {
28 if (!base::CreateDirectory(temp_dir
))
37 int __stdcall
wWinMain(HINSTANCE instance
, HINSTANCE
, wchar_t* cmd_line
,
39 // Manages the destruction of singletons.
40 base::AtExitManager exit_manager
;
42 base::CommandLine::Init(0, NULL
);
44 chrome::RegisterPathProvider();
46 // We use/create a directory under the user's temp folder, for logging.
47 base::FilePath operating_dir
;
48 GetCrashServiceDirectory(&operating_dir
);
49 base::FilePath log_file
= operating_dir
.Append(kStandardLogFile
);
51 // Logging to stderr (to help with debugging failures on the
52 // buildbots) and to a file.
53 logging::LoggingSettings settings
;
54 settings
.logging_dest
= logging::LOG_TO_ALL
;
55 settings
.log_file
= log_file
.value().c_str();
56 logging::InitLogging(settings
);
57 // Logging with pid, tid and timestamp.
58 logging::SetLogItems(true, true, true, false);
60 VLOG(1) << "session start. cmdline is [" << cmd_line
<< "]";
62 base::FilePath dumps_path
;
63 if (!PathService::Get(chrome::DIR_CRASH_DUMPS
, &dumps_path
)) {
64 LOG(ERROR
) << "could not get DIR_CRASH_DUMPS";
68 breakpad::CrashService crash_service
;
69 if (!crash_service
.Initialize(operating_dir
, dumps_path
))
72 VLOG(1) << "ready to process crash requests";
74 // Enter the message loop.
75 int retv
= crash_service
.ProcessingLoop();
77 VLOG(1) << "session end. return code is " << retv
;