]> khamidou — GitHub mirrors - electron.git/commitdiff
Add crash reporter module (based on Quincy).
authorCheng Zhao <zcbenz@gmail.com>
Sat, 1 Jun 2013 07:57:37 +0000 (15:57 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 1 Jun 2013 07:57:37 +0000 (15:57 +0800)
atom.gyp
browser/api/atom_api_crash_reporter.h [new file with mode: 0644]
browser/api/atom_api_crash_reporter_mac.mm [new file with mode: 0644]
browser/api/lib/crash-reporter.coffee [new file with mode: 0644]
common/api/atom_extensions.h

index 2a7ae441759003f48a84a4883dbc44bf515158d0..fa0eafad0c9c47cc491587881e43465999762b5d 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
@@ -12,6 +12,7 @@
       'browser/api/lib/app.coffee',
       'browser/api/lib/atom-delegate.coffee',
       'browser/api/lib/browser-window.coffee',
+      'browser/api/lib/crash-reporter.coffee',
       'browser/api/lib/dialog.coffee',
       'browser/api/lib/ipc.coffee',
       'browser/api/lib/menu.coffee',
@@ -36,6 +37,8 @@
       'browser/api/atom_api_app.h',
       '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_dialog.cc',
       'browser/api/atom_api_dialog.h',
       'browser/api/atom_api_event.cc',
diff --git a/browser/api/atom_api_crash_reporter.h b/browser/api/atom_api_crash_reporter.h
new file mode 100644 (file)
index 0000000..7b42a0d
--- /dev/null
@@ -0,0 +1,31 @@
+// 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_
diff --git a/browser/api/atom_api_crash_reporter_mac.mm b/browser/api/atom_api_crash_reporter_mac.mm
new file mode 100644 (file)
index 0000000..f95fa8e
--- /dev/null
@@ -0,0 +1,62 @@
+// 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"
+
+#import <Quincy/BWQuincyManager.h>
+
+#include "base/strings/sys_string_conversions.h"
+#include "vendor/node/src/node.h"
+#include "vendor/node/src/node_internals.h"
+
+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)];
+  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)];
+  return v8::Undefined();
+}
+
+// static
+v8::Handle<v8::Value> CrashReporter::SetAutoSubmit(const v8::Arguments &args) {
+  BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
+  [manager setAutoSubmitCrashReport:args[0]->BooleanValue()];
+  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)
diff --git a/browser/api/lib/crash-reporter.coffee b/browser/api/lib/crash-reporter.coffee
new file mode 100644 (file)
index 0000000..90f5827
--- /dev/null
@@ -0,0 +1 @@
+module.exports = process.atomBinding 'crash_reporter'
index ac4059fb1d49a64e57990782a0daf5a6f285d3f7..2b986d3d80e868d779ddd031b7fffe85b4f0a79a 100644 (file)
@@ -10,6 +10,7 @@ NODE_EXT_LIST_START
 
 // Module names start with `atom_browser_` can only be used by browser process.
 NODE_EXT_LIST_ITEM(atom_browser_app)
+NODE_EXT_LIST_ITEM(atom_browser_crash_reporter)
 NODE_EXT_LIST_ITEM(atom_browser_dialog)
 NODE_EXT_LIST_ITEM(atom_browser_ipc)
 NODE_EXT_LIST_ITEM(atom_browser_menu)