summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/chrome.gyp10
-rw-r--r--chrome/tools/DEPS2
-rw-r--r--chrome/tools/crash_service/main.cc18
-rw-r--r--components/breakpad.gypi35
-rw-r--r--components/breakpad/tools/crash_service.cc (renamed from chrome/tools/crash_service/crash_service.cc)49
-rw-r--r--components/breakpad/tools/crash_service.h (renamed from chrome/tools/crash_service/crash_service.h)26
6 files changed, 83 insertions, 57 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index daf3582..3ecffc1 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -958,16 +958,13 @@
'dependencies': [
'installer_util',
'../base/base.gyp:base',
- '../breakpad/breakpad.gyp:breakpad_handler',
- '../breakpad/breakpad.gyp:breakpad_sender',
'../chrome/common_constants.gyp:common_constants',
+ '../components/components.gyp:breakpad_crash_service',
],
'include_dirs': [
'..',
],
'sources': [
- 'tools/crash_service/crash_service.cc',
- 'tools/crash_service/crash_service.h',
'tools/crash_service/main.cc',
],
'msvs_settings': {
@@ -1025,16 +1022,13 @@
'dependencies': [
'installer_util_nacl_win64',
'../base/base.gyp:base_static_win64',
- '../breakpad/breakpad.gyp:breakpad_handler_win64',
- '../breakpad/breakpad.gyp:breakpad_sender_win64',
'../chrome/common_constants.gyp:common_constants_win64',
+ '../components/components.gyp:breakpad_crash_service_win64',
],
'include_dirs': [
'..',
],
'sources': [
- 'tools/crash_service/crash_service.cc',
- 'tools/crash_service/crash_service.h',
'tools/crash_service/main.cc',
'../content/public/common/content_switches.cc',
],
diff --git a/chrome/tools/DEPS b/chrome/tools/DEPS
index 2a98e95..adf68b9 100644
--- a/chrome/tools/DEPS
+++ b/chrome/tools/DEPS
@@ -1,9 +1,9 @@
include_rules = [
- "+breakpad",
"+chrome/browser",
"+chrome/third_party/hunspell/google",
"+chrome/utility/local_discovery",
"+content/browser",
"+content/public/browser",
+ "+components/breakpad",
"+third_party/re2",
]
diff --git a/chrome/tools/crash_service/main.cc b/chrome/tools/crash_service/main.cc
index c4889c7..9fd9e87 100644
--- a/chrome/tools/crash_service/main.cc
+++ b/chrome/tools/crash_service/main.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/tools/crash_service/crash_service.h"
-
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
@@ -12,6 +10,10 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/path_service.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_paths.h"
+#include "components/breakpad/tools/crash_service.h"
namespace {
@@ -39,6 +41,8 @@ int __stdcall wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd_line,
CommandLine::Init(0, NULL);
+ chrome::RegisterPathProvider();
+
// We use/create a directory under the user's temp folder, for logging.
base::FilePath operating_dir;
GetCrashServiceDirectory(&operating_dir);
@@ -55,8 +59,14 @@ int __stdcall wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd_line,
VLOG(1) << "session start. cmdline is [" << cmd_line << "]";
- CrashService crash_service(operating_dir.value());
- if (!crash_service.Initialize(::GetCommandLineW()))
+ base::FilePath dumps_path;
+ if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) {
+ LOG(ERROR) << "could not get DIR_CRASH_DUMPS";
+ return 1;
+ }
+
+ breakpad::CrashService crash_service;
+ if (!crash_service.Initialize(operating_dir, dumps_path))
return 1;
VLOG(1) << "ready to process crash requests";
diff --git a/components/breakpad.gypi b/components/breakpad.gypi
index bd45b0a..f7bdd98 100644
--- a/components/breakpad.gypi
+++ b/components/breakpad.gypi
@@ -50,6 +50,23 @@
},
],
'conditions': [
+ ['OS=="win"', {
+ 'targets': [
+ {
+ 'target_name': 'breakpad_crash_service',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../base/base.gyp:base',
+ '../breakpad/breakpad.gyp:breakpad_handler',
+ '../breakpad/breakpad.gyp:breakpad_sender',
+ ],
+ 'sources': [
+ 'breakpad/tools/crash_service.cc',
+ 'breakpad/tools/crash_service.h',
+ ],
+ },
+ ],
+ }],
['OS=="win" and target_arch=="ia32"', {
'targets': [
{
@@ -70,6 +87,24 @@
},
},
},
+ {
+ 'target_name': 'breakpad_crash_service_win64',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../base/base.gyp:base_nacl_win64',
+ '../breakpad/breakpad.gyp:breakpad_handler_win64',
+ '../breakpad/breakpad.gyp:breakpad_sender_win64',
+ ],
+ 'sources': [
+ 'breakpad/tools/crash_service.cc',
+ 'breakpad/tools/crash_service.h',
+ ],
+ 'configurations': {
+ 'Common_Base': {
+ 'msvs_target_platform': 'x64',
+ },
+ },
+ },
],
}],
['OS=="mac"', {
diff --git a/chrome/tools/crash_service/crash_service.cc b/components/breakpad/tools/crash_service.cc
index 8face40..c7ceb58 100644
--- a/chrome/tools/crash_service/crash_service.cc
+++ b/components/breakpad/tools/crash_service.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/tools/crash_service/crash_service.h"
+#include "components/breakpad/tools/crash_service.h"
#include <windows.h>
@@ -13,13 +13,12 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
-#include "base/path_service.h"
#include "base/win/windows_version.h"
#include "breakpad/src/client/windows/crash_generation/client_info.h"
#include "breakpad/src/client/windows/crash_generation/crash_generation_server.h"
#include "breakpad/src/client/windows/sender/crash_report_sender.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths.h"
+
+namespace breakpad {
namespace {
@@ -152,15 +151,13 @@ const char CrashService::kReporterTag[] = "reporter";
const char CrashService::kDumpsDir[] = "dumps-dir";
const char CrashService::kPipeName[] = "pipe-name";
-CrashService::CrashService(const std::wstring& report_dir)
- : report_path_(report_dir),
- sender_(NULL),
+CrashService::CrashService()
+ : sender_(NULL),
dumper_(NULL),
requests_handled_(0),
requests_sent_(0),
clients_connected_(0),
clients_terminated_(0) {
- chrome::RegisterPathProvider();
}
CrashService::~CrashService() {
@@ -169,8 +166,8 @@ CrashService::~CrashService() {
delete sender_;
}
-
-bool CrashService::Initialize(const std::wstring& command_line) {
+bool CrashService::Initialize(const base::FilePath& operating_dir,
+ const base::FilePath& dumps_path) {
using google_breakpad::CrashReportSender;
using google_breakpad::CrashGenerationServer;
@@ -179,28 +176,15 @@ bool CrashService::Initialize(const std::wstring& command_line) {
// The checkpoint file allows CrashReportSender to enforce the the maximum
// reports per day quota. Does not seem to serve any other purpose.
- base::FilePath checkpoint_path = report_path_.Append(kCheckPointFile);
-
- // The dumps path is typically : '<user profile>\Local settings\
- // Application data\Goggle\Chrome\Crash Reports' and the report path is
- // Application data\Google\Chrome\Reported Crashes.txt
- base::FilePath user_data_dir;
- if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
- LOG(ERROR) << "could not get DIR_USER_DATA";
- return false;
- }
- report_path_ = user_data_dir.Append(chrome::kCrashReportLog);
+ base::FilePath checkpoint_path = operating_dir.Append(kCheckPointFile);
- CommandLine cmd_line = CommandLine::FromString(command_line);
+ CommandLine& cmd_line = *CommandLine::ForCurrentProcess();
+
+ base::FilePath dumps_path_to_use = dumps_path;
- base::FilePath dumps_path;
if (cmd_line.HasSwitch(kDumpsDir)) {
- dumps_path = base::FilePath(cmd_line.GetSwitchValueNative(kDumpsDir));
- } else {
- if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) {
- LOG(ERROR) << "could not get DIR_CRASH_DUMPS";
- return false;
- }
+ dumps_path_to_use =
+ base::FilePath(cmd_line.GetSwitchValueNative(kDumpsDir));
}
// We can override the send reports quota with a command line switch.
@@ -243,7 +227,7 @@ bool CrashService::Initialize(const std::wstring& command_line) {
&CrashService::OnClientDumpRequest, this,
&CrashService::OnClientExited, this,
NULL, NULL,
- true, &dumps_path.value());
+ true, &dumps_path_to_use.value());
if (!dumper_) {
LOG(ERROR) << "could not create dumper";
@@ -266,8 +250,7 @@ bool CrashService::Initialize(const std::wstring& command_line) {
// Log basic information.
VLOG(1) << "pipe name is " << pipe_name
- << "\ndumps at " << dumps_path.value()
- << "\nreports at " << report_path_.value();
+ << "\ndumps at " << dumps_path_to_use.value();
if (sender_) {
VLOG(1) << "checkpoint is " << checkpoint_path.value()
@@ -501,3 +484,5 @@ PSECURITY_DESCRIPTOR CrashService::GetSecurityDescriptorForLowIntegrity() {
return NULL;
}
+
+} // namespace breakpad
diff --git a/chrome/tools/crash_service/crash_service.h b/components/breakpad/tools/crash_service.h
index 9ea56c5..4f54b5e 100644
--- a/chrome/tools/crash_service/crash_service.h
+++ b/components/breakpad/tools/crash_service.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TOOLS_CRASH_SERVICE_CRASH_SERVICE_H_
-#define CHROME_TOOLS_CRASH_SERVICE_CRASH_SERVICE_H_
+#ifndef COMPONENTS_BREAKPAD_TOOLS_CRASH_SERVICE_H_
+#define COMPONENTS_BREAKPAD_TOOLS_CRASH_SERVICE_H_
#include <string>
@@ -19,6 +19,8 @@ class ClientInfo;
}
+namespace breakpad {
+
// This class implements an out-of-process crash server. It uses breakpad's
// CrashGenerationServer and CrashReportSender to generate and then send the
// crash dumps. Internally, it uses OS specific pipe to allow applications to
@@ -28,15 +30,15 @@ class ClientInfo;
// possibly sent to the crash2 servers.
class CrashService {
public:
- // The ctor takes a directory that needs to be writable and will create
- // a subdirectory inside to keep logs, crashes and checkpoint files.
- explicit CrashService(const std::wstring& report_dir);
+ CrashService();
~CrashService();
- // Starts servicing crash dumps. The command_line specifies various behaviors,
- // see below for more information. Returns false if it failed. Do not use
- // other members in that case.
- bool Initialize(const std::wstring& command_line);
+ // Starts servicing crash dumps. Returns false if it failed. Do not use
+ // other members in that case. |operating_dir| is where the CrashService
+ // should store breakpad's checkpoint file. |dumps_path| is the directory
+ // where the crash dumps should be stored.
+ bool Initialize(const base::FilePath& operating_dir,
+ const base::FilePath& dumps_path);
// Command line switches:
//
@@ -105,8 +107,6 @@ class CrashService {
google_breakpad::CrashGenerationServer* dumper_;
google_breakpad::CrashReportSender* sender_;
- // the path to dumps and logs directory.
- base::FilePath report_path_;
// the extra tag sent to the server with each dump.
std::wstring reporter_tag_;
@@ -120,4 +120,6 @@ class CrashService {
DISALLOW_COPY_AND_ASSIGN(CrashService);
};
-#endif // CHROME_TOOLS_CRASH_SERVICE_CRASH_SERVICE_H_
+} // namespace breakpad
+
+#endif // COMPONENTS_BREAKPAD_TOOLS_CRASH_SERVICE_H_