Seperate implementation of crash reporter to standalone class.

This commit is contained in:
Cheng Zhao 2013-07-04 15:54:34 +08:00
parent 5f3b71e589
commit f146c1fe3b
5 changed files with 90 additions and 22 deletions

View file

@ -42,7 +42,7 @@
'browser/api/atom_api_browser_ipc.cc',
'browser/api/atom_api_browser_ipc.h',
'browser/api/atom_api_crash_reporter.h',
'browser/api/atom_api_crash_reporter_mac.mm',
'browser/api/atom_api_crash_reporter.cc',
'browser/api/atom_api_dialog.cc',
'browser/api/atom_api_dialog.h',
'browser/api/atom_api_event.cc',
@ -82,6 +82,9 @@
'browser/browser.h',
'browser/browser_mac.mm',
'browser/browser_observer.h',
'browser/crash_reporter.h',
'browser/crash_reporter_mac.mm',
'browser/crash_reporter_win.cc',
'browser/file_dialog.h',
'browser/file_dialog_mac.mm',
'browser/media/media_capture_devices_dispatcher.cc',

View file

@ -4,9 +4,7 @@
#include "browser/api/atom_api_crash_reporter.h"
#import <Quincy/BWQuincyManager.h>
#include "base/strings/sys_string_conversions.h"
#include "browser/crash_reporter.h"
#include "vendor/node/src/node.h"
#include "vendor/node/src/node_internals.h"
@ -14,37 +12,24 @@ namespace atom {
namespace api {
namespace {
// Converts a V8 value to a string16.
string16 V8ValueToUTF16(v8::Handle<v8::Value> value) {
v8::String::Value s(value);
return string16(reinterpret_cast<const char16*>(*s), s.length());
}
} // namespace
// static
v8::Handle<v8::Value> CrashReporter::SetCompanyName(const v8::Arguments &args) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
string16 str(V8ValueToUTF16(args[0]));
[manager setCompanyName:base::SysUTF16ToNSString(str)];
std::string name(*v8::String::Utf8Value(args[0]));
crash_reporter::CrashReporter::SetCompanyName(name);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> CrashReporter::SetSubmissionURL(
const v8::Arguments &args) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
string16 str(V8ValueToUTF16(args[0]));
[manager setSubmissionURL:base::SysUTF16ToNSString(str)];
std::string url(*v8::String::Utf8Value(args[0]));
crash_reporter::CrashReporter::SetSubmissionURL(url);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> CrashReporter::SetAutoSubmit(const v8::Arguments &args) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
[manager setAutoSubmitCrashReport:args[0]->BooleanValue()];
crash_reporter::CrashReporter::SetAutoSubmit(args[0]->BooleanValue());
return v8::Undefined();
}

26
browser/crash_reporter.h Normal file
View file

@ -0,0 +1,26 @@
// 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_

View file

@ -0,0 +1,32 @@
// 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"
#import <Quincy/BWQuincyManager.h>
#include "base/strings/sys_string_conversions.h"
namespace crash_reporter {
// static
void CrashReporter::SetCompanyName(const std::string& name) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
[manager setCompanyName:base::SysUTF8ToNSString(name)];
}
// static
void CrashReporter::SetSubmissionURL(const std::string& url) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
[manager setSubmissionURL:base::SysUTF8ToNSString(name)];
return v8::Undefined();
}
// static
void CrashReporter::SetAutoSubmit(bool yes) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
[manager setAutoSubmitCrashReport:yes];
}
} // namespace crash_reporter

View file

@ -0,0 +1,22 @@
// 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