]> khamidou — GitHub mirrors - electron.git/commitdiff
Seperate implementation of crash reporter to standalone class.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 4 Jul 2013 07:54:34 +0000 (15:54 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 4 Jul 2013 08:30:49 +0000 (16:30 +0800)
atom.gyp
browser/api/atom_api_crash_reporter.cc [moved from browser/api/atom_api_crash_reporter_mac.mm with 58% similarity]
browser/crash_reporter.h [new file with mode: 0644]
browser/crash_reporter_mac.mm [new file with mode: 0644]
browser/crash_reporter_win.cc [new file with mode: 0644]

index 9109dc1473523d9f2f2d8aa00b6b835ca0ea15aa..533ffcb11dd7da24f558053e143b0bc75629a6dc 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
@@ -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',
similarity index 58%
rename from browser/api/atom_api_crash_reporter_mac.mm
rename to browser/api/atom_api_crash_reporter.cc
index ca86b2041d93cf46d7380197ab9e1cfee6067221..2b23db1d1a66a1627841b30f51a32cee36a2005f 100644 (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();
 }
 
diff --git a/browser/crash_reporter.h b/browser/crash_reporter.h
new file mode 100644 (file)
index 0000000..14b6c7a
--- /dev/null
@@ -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_
diff --git a/browser/crash_reporter_mac.mm b/browser/crash_reporter_mac.mm
new file mode 100644 (file)
index 0000000..90e709a
--- /dev/null
@@ -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
diff --git a/browser/crash_reporter_win.cc b/browser/crash_reporter_win.cc
new file mode 100644 (file)
index 0000000..ca3c7e6
--- /dev/null
@@ -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
+