Browse Source

Pass `uploadToServer` parameter to linux crash reporter

Thiago de Arruda 8 years ago
parent
commit
e03e37e984

+ 12 - 2
atom/common/crash_reporter/crash_reporter_linux.cc

@@ -38,7 +38,8 @@ static const off_t kMaxMinidumpFileSize = 1258291;
 
 CrashReporterLinux::CrashReporterLinux()
     : process_start_time_(0),
-      pid_(getpid()) {
+      pid_(getpid()),
+      upload_to_server_(true) {
   // Set the base process start time value.
   struct timeval tv;
   if (!gettimeofday(&tv, NULL)) {
@@ -69,6 +70,7 @@ void CrashReporterLinux::InitBreakpad(const std::string& product_name,
   crash_keys_->SetKeyValue("prod", ATOM_PRODUCT_NAME);
   crash_keys_->SetKeyValue("ver", version.c_str());
   upload_url_ = submit_url;
+  upload_to_server_ = upload_to_server;
 
   for (StringMap::const_iterator iter = upload_parameters_.begin();
        iter != upload_parameters_.end(); ++iter)
@@ -79,6 +81,14 @@ void CrashReporterLinux::SetUploadParameters() {
   upload_parameters_["platform"] = "linux";
 }
 
+void CrashReporterLinux::SetUploadToServer(const bool upload_to_server) {
+  upload_to_server_ = upload_to_server;
+}
+
+bool CrashReporterLinux::GetUploadToServer() {
+  return upload_to_server_;
+}
+
 void CrashReporterLinux::EnableCrashDumping(const base::FilePath& crashes_dir) {
   base::CreateDirectory(crashes_dir);
 
@@ -117,7 +127,7 @@ bool CrashReporterLinux::CrashDone(const MinidumpDescriptor& minidump,
   info.fd = minidump.fd();
   info.distro = base::g_linux_distro;
   info.distro_length = my_strlen(base::g_linux_distro);
-  info.upload = true;
+  info.upload = self->upload_to_server_;
   info.process_start_time = self->process_start_time_;
   info.oom_size = base::g_oom_size;
   info.pid = self->pid_;

+ 3 - 0
atom/common/crash_reporter/crash_reporter_linux.h

@@ -34,7 +34,9 @@ class CrashReporterLinux : public CrashReporter {
                     const base::FilePath& crashes_dir,
                     bool upload_to_server,
                     bool skip_system_crash_handler) override;
+  void SetUploadToServer(bool upload_to_server) override;
   void SetUploadParameters() override;
+  bool GetUploadToServer() override;
 
  private:
   friend struct base::DefaultSingletonTraits<CrashReporterLinux>;
@@ -54,6 +56,7 @@ class CrashReporterLinux : public CrashReporter {
   uint64_t process_start_time_;
   pid_t pid_;
   std::string upload_url_;
+  bool upload_to_server_;
 
   DISALLOW_COPY_AND_ASSIGN(CrashReporterLinux);
 };

+ 3 - 3
docs/api/crash-reporter.md

@@ -40,7 +40,7 @@ The `crashReporter` module has the following methods:
   * `companyName` String (optional)
   * `submitURL` String - URL that crash reports will be sent to as POST.
   * `productName` String (optional) - Defaults to `app.getName()`.
-  * `uploadToServer` Boolean (optional) _macOS_ - Whether crash reports should be sent to the server
+  * `uploadToServer` Boolean (optional) _Linux_ _macOS_ - Whether crash reports should be sent to the server
     Default is `true`.
   * `ignoreSystemCrashHandler` Boolean (optional) - Default is `false`.
   * `extra` Object (optional) - An object you can define that will be sent along with the
@@ -99,14 +99,14 @@ Returns [`CrashReport[]`](structures/crash-report.md):
 Returns all uploaded crash reports. Each report contains the date and uploaded
 ID.
 
-### `crashReporter.getUploadToServer()` _macOS_
+### `crashReporter.getUploadToServer()` _Linux_ _macOS_
 
 Returns `Boolean` - Whether reports should be submitted to the server.  Set through
 the `start` method or `setUploadToServer`.
 
 **Note:** This API can only be called from the main process.
 
-### `crashReporter.setUploadToServer(uploadToServer)` _macOS_
+### `crashReporter.setUploadToServer(uploadToServer)` _Linux_ _macOS_
 
 * `uploadToServer` Boolean _macOS_ - Whether reports should be submitted to the server