2013-07-04 07:54:34 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2013-11-14 05:33:09 +00:00
|
|
|
#include "common/crash_reporter/crash_reporter_mac.h"
|
2013-07-04 07:54:34 +00:00
|
|
|
|
2013-11-14 05:33:09 +00:00
|
|
|
#include "base/memory/singleton.h"
|
2013-07-04 07:54:34 +00:00
|
|
|
#include "base/strings/sys_string_conversions.h"
|
2013-11-13 08:48:30 +00:00
|
|
|
#import "vendor/breakpad/src/client/apple/Framework/BreakpadDefines.h"
|
2013-07-04 07:54:34 +00:00
|
|
|
|
|
|
|
namespace crash_reporter {
|
|
|
|
|
2013-11-14 05:33:09 +00:00
|
|
|
CrashReporterMac::CrashReporterMac()
|
|
|
|
: breakpad_(NULL) {
|
|
|
|
}
|
2013-11-13 08:48:30 +00:00
|
|
|
|
2013-11-14 05:33:09 +00:00
|
|
|
CrashReporterMac::~CrashReporterMac() {
|
|
|
|
if (breakpad_ != NULL)
|
|
|
|
BreakpadRelease(breakpad_);
|
2013-11-13 11:12:13 +00:00
|
|
|
}
|
|
|
|
|
2013-11-14 05:33:09 +00:00
|
|
|
void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
|
|
|
const std::string& version,
|
|
|
|
const std::string& company_name,
|
|
|
|
const std::string& submit_url,
|
|
|
|
bool auto_submit,
|
|
|
|
bool skip_system_crash_handler) {
|
|
|
|
if (breakpad_ != NULL)
|
|
|
|
BreakpadRelease(breakpad_);
|
|
|
|
|
|
|
|
NSMutableDictionary* parameters =
|
|
|
|
[NSMutableDictionary dictionaryWithCapacity:4];
|
|
|
|
|
2013-11-19 04:29:34 +00:00
|
|
|
[parameters setValue:@"atom-shell"
|
2013-11-14 05:33:09 +00:00
|
|
|
forKey:@BREAKPAD_PRODUCT];
|
2013-11-19 04:19:23 +00:00
|
|
|
[parameters setValue:base::SysUTF8ToNSString(product_name)
|
|
|
|
forKey:@BREAKPAD_PRODUCT_DISPLAY];
|
2013-11-14 05:33:09 +00:00
|
|
|
[parameters setValue:base::SysUTF8ToNSString(version)
|
|
|
|
forKey:@BREAKPAD_VERSION];
|
|
|
|
[parameters setValue:base::SysUTF8ToNSString(company_name)
|
|
|
|
forKey:@BREAKPAD_VENDOR];
|
|
|
|
[parameters setValue:base::SysUTF8ToNSString(submit_url)
|
|
|
|
forKey:@BREAKPAD_URL];
|
|
|
|
[parameters setValue:(auto_submit ? @"YES" : @"NO")
|
|
|
|
forKey:@BREAKPAD_SKIP_CONFIRM];
|
|
|
|
[parameters setValue:(skip_system_crash_handler ? @"YES" : @"NO")
|
|
|
|
forKey:@BREAKPAD_SEND_AND_EXIT];
|
|
|
|
|
|
|
|
// Report all crashes (important for testing the crash reporter).
|
|
|
|
[parameters setValue:@"0" forKey:@BREAKPAD_REPORT_INTERVAL];
|
|
|
|
|
|
|
|
breakpad_ = BreakpadCreate(parameters);
|
2013-11-14 10:02:15 +00:00
|
|
|
|
|
|
|
for (StringMap::const_iterator iter = upload_parameters_.begin();
|
|
|
|
iter != upload_parameters_.end(); ++iter) {
|
|
|
|
BreakpadAddUploadParameter(breakpad_,
|
|
|
|
base::SysUTF8ToNSString(iter->first),
|
|
|
|
base::SysUTF8ToNSString(iter->second));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CrashReporterMac::SetUploadParameters() {
|
|
|
|
upload_parameters_["platform"] = "darwin";
|
2013-07-04 07:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-11-14 05:33:09 +00:00
|
|
|
CrashReporterMac* CrashReporterMac::GetInstance() {
|
|
|
|
return Singleton<CrashReporterMac>::get();
|
2013-07-04 07:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-11-14 05:33:09 +00:00
|
|
|
CrashReporter* CrashReporter::GetInstance() {
|
|
|
|
return CrashReporterMac::GetInstance();
|
2013-07-04 07:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace crash_reporter
|