Make the crash reporter available for both browser and renderer.
This commit is contained in:
parent
8f558fb252
commit
374cf948e4
8 changed files with 18 additions and 18 deletions
|
@ -1,46 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#include "browser/api/atom_api_crash_reporter.h"
|
||||
|
||||
#include "browser/crash_reporter.h"
|
||||
#include "common/v8_conversions.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> CrashReporter::SetCompanyName(const v8::Arguments &args) {
|
||||
crash_reporter::CrashReporter::SetCompanyName(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> CrashReporter::SetSubmissionURL(
|
||||
const v8::Arguments &args) {
|
||||
crash_reporter::CrashReporter::SetSubmissionURL(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> CrashReporter::SetAutoSubmit(const v8::Arguments &args) {
|
||||
crash_reporter::CrashReporter::SetAutoSubmit(FromV8Value(args[0]));
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::Initialize(v8::Handle<v8::Object> target) {
|
||||
node::SetMethod(target, "setCompanyName", SetCompanyName);
|
||||
node::SetMethod(target, "setSubmissionUrl", SetSubmissionURL);
|
||||
node::SetMethod(target, "setAutoSubmit", SetAutoSubmit);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
NODE_MODULE(atom_browser_crash_reporter, atom::api::CrashReporter::Initialize)
|
|
@ -1,31 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class CrashReporter {
|
||||
public:
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> SetCompanyName(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetSubmissionURL(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetAutoSubmit(const v8::Arguments &args);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(CrashReporter);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_
|
|
@ -1 +0,0 @@
|
|||
module.exports = process.atomBinding 'crash_reporter'
|
|
@ -1,26 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#ifndef ATOM_BROWSER_CRASH_REPORTER_H_
|
||||
#define ATOM_BROWSER_CRASH_REPORTER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
namespace crash_reporter {
|
||||
|
||||
class CrashReporter {
|
||||
public:
|
||||
static void SetCompanyName(const std::string& name);
|
||||
static void SetSubmissionURL(const std::string& url);
|
||||
static void SetAutoSubmit(bool yes);
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(CrashReporter);
|
||||
};
|
||||
|
||||
} // namespace crash_reporter
|
||||
|
||||
#endif // ATOM_BROWSER_CRASH_REPORTER_H_
|
|
@ -1,92 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#include "browser/crash_reporter.h"
|
||||
|
||||
#include "browser/browser.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "common/atom_version.h"
|
||||
#import "vendor/breakpad/src/client/apple/Framework/BreakpadDefines.h"
|
||||
#import "vendor/breakpad/src/client/mac/Framework/Breakpad.h"
|
||||
|
||||
namespace crash_reporter {
|
||||
|
||||
namespace {
|
||||
|
||||
class ScopedCrashReporter {
|
||||
public:
|
||||
ScopedCrashReporter() : is_browser_(!base::mac::IsBackgroundOnlyProcess()) {
|
||||
NSMutableDictionary* parameters =
|
||||
[NSMutableDictionary dictionaryWithCapacity:4];
|
||||
[parameters setValue:@"Atom-Shell" forKey:@BREAKPAD_PRODUCT];
|
||||
[parameters setValue:@"GitHub, Inc" forKey:@BREAKPAD_VENDOR];
|
||||
|
||||
// Use application's version for crashes in browser.
|
||||
if (is_browser_) {
|
||||
std::string version = atom::Browser::Get()->GetVersion();
|
||||
[parameters setValue:base::SysUTF8ToNSString(version)
|
||||
forKey:@BREAKPAD_VERSION];
|
||||
} else {
|
||||
[parameters setValue:@ATOM_VERSION_STRING forKey:@BREAKPAD_VERSION];
|
||||
}
|
||||
|
||||
// Report all crashes (important for testing the crash reporter).
|
||||
[parameters setValue:@"0" forKey:@BREAKPAD_REPORT_INTERVAL];
|
||||
|
||||
// Let the crash reporter log everything in Console.app.
|
||||
[parameters setValue:@"NO" forKey:@BREAKPAD_SEND_AND_EXIT];
|
||||
|
||||
// Send the report by default.
|
||||
[parameters setValue:@"YES" forKey:@BREAKPAD_SKIP_CONFIRM];
|
||||
|
||||
// Use my server as /dev/null if not specified.
|
||||
[parameters setValue:@"http://54.249.141.255" forKey:@BREAKPAD_URL];
|
||||
|
||||
breakpad_ = BreakpadCreate(parameters);
|
||||
}
|
||||
|
||||
~ScopedCrashReporter() { if (breakpad_) BreakpadRelease(breakpad_); }
|
||||
|
||||
void SetKey(const std::string& key, const std::string& value) {
|
||||
BreakpadSetKeyValue(breakpad_,
|
||||
base::SysUTF8ToNSString(key),
|
||||
base::SysUTF8ToNSString(value));
|
||||
}
|
||||
|
||||
static ScopedCrashReporter* Get() {
|
||||
if (g_scoped_crash_reporter_ == NULL)
|
||||
g_scoped_crash_reporter_ = new ScopedCrashReporter();
|
||||
return g_scoped_crash_reporter_;
|
||||
}
|
||||
|
||||
private:
|
||||
BreakpadRef breakpad_;
|
||||
bool is_browser_;
|
||||
|
||||
static ScopedCrashReporter* g_scoped_crash_reporter_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedCrashReporter);
|
||||
};
|
||||
|
||||
ScopedCrashReporter* ScopedCrashReporter::g_scoped_crash_reporter_ = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
void CrashReporter::SetCompanyName(const std::string& name) {
|
||||
ScopedCrashReporter::Get()->SetKey(BREAKPAD_VENDOR, name);
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::SetSubmissionURL(const std::string& url) {
|
||||
ScopedCrashReporter::Get()->SetKey(BREAKPAD_URL, url);
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::SetAutoSubmit(bool yes) {
|
||||
ScopedCrashReporter::Get()->SetKey(BREAKPAD_SKIP_CONFIRM, yes ? "YES" : "NO");
|
||||
}
|
||||
|
||||
} // namespace crash_reporter
|
|
@ -1,22 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#include "browser/crash_reporter.h"
|
||||
|
||||
namespace crash_reporter {
|
||||
|
||||
// static
|
||||
void CrashReporter::SetCompanyName(const std::string& name) {
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::SetSubmissionURL(const std::string& url) {
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashReporter::SetAutoSubmit(bool yes) {
|
||||
}
|
||||
|
||||
} // namespace crash_reporter
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue