Browse Source

chore: remove deprecated crashReporter APIs (#26695)

Milan Burda 4 years ago
parent
commit
022bafc485

+ 5 - 11
docs/api/crash-reporter.md

@@ -128,7 +128,7 @@ must be at most 39 bytes long, and values must be no longer than 127 bytes.
 Keys with names longer than the maximum will be silently ignored. Key values
 longer than the maximum length will be truncated.
 
-**Note:** Calling this method from the renderer process is deprecated.
+**Note:** This method is only available in the main process.
 
 ### `crashReporter.getLastCrashReport()`
 
@@ -137,7 +137,7 @@ last crash report. Only crash reports that have been uploaded will be returned;
 even if a crash report is present on disk it will not be returned until it is
 uploaded. In the case that there are no uploaded reports, `null` is returned.
 
-**Note:** Calling this method from the renderer process is deprecated.
+**Note:** This method is only available in the main process.
 
 ### `crashReporter.getUploadedReports()`
 
@@ -146,14 +146,14 @@ Returns [`CrashReport[]`](structures/crash-report.md):
 Returns all uploaded crash reports. Each report contains the date and uploaded
 ID.
 
-**Note:** Calling this method from the renderer process is deprecated.
+**Note:** This method is only available in the main process.
 
 ### `crashReporter.getUploadToServer()`
 
 Returns `Boolean` - Whether reports should be submitted to the server. Set through
 the `start` method or `setUploadToServer`.
 
-**Note:** Calling this method from the renderer process is deprecated.
+**Note:** This method is only available in the main process.
 
 ### `crashReporter.setUploadToServer(uploadToServer)`
 
@@ -162,13 +162,7 @@ the `start` method or `setUploadToServer`.
 This would normally be controlled by user preferences. This has no effect if
 called before `start` is called.
 
-**Note:** Calling this method from the renderer process is deprecated.
-
-### `crashReporter.getCrashesDirectory()` _Deprecated_
-
-Returns `String` - The directory where crashes are temporarily stored before being uploaded.
-
-**Note:** This method is deprecated, use `app.getPath('crashDumps')` instead.
+**Note:** This method is only available in the main process.
 
 ### `crashReporter.addExtraParameter(key, value)`
 

+ 12 - 0
docs/breaking-changes.md

@@ -43,6 +43,18 @@ We [recommend having contextIsolation enabled](https://github.com/electron/elect
 
 For more details see: https://github.com/electron/electron/issues/23506
 
+### Removed: `crashReporter.getCrashesDirectory()`
+
+The `crashReporter.getCrashesDirectory` method has been removed. Usage
+should be replaced by `app.getPath('crashDumps')`.
+
+```js
+// Removed in Electron 12
+crashReporter.getCrashesDirectory()
+// Replace with
+app.getPath('crashDumps')
+```
+
 ### Removed: `crashReporter` methods in the renderer process
 
 The following `crashReporter` methods are no longer available in the renderer

+ 0 - 4
lib/browser/api/crash-reporter.ts

@@ -51,10 +51,6 @@ class CrashReporter {
     return binding.getUploadedReports();
   }
 
-  getCrashesDirectory () {
-    return app.getPath('crashDumps');
-  }
-
   getUploadToServer () {
     if (process.type === 'browser') {
       return binding.getUploadToServer();

+ 1 - 21
lib/browser/rpc-server.ts

@@ -1,6 +1,6 @@
 import { app } from 'electron/main';
 import type { WebContents } from 'electron/main';
-import { clipboard, crashReporter, nativeImage } from 'electron/common';
+import { clipboard, nativeImage } from 'electron/common';
 import * as fs from 'fs';
 import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
 import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
@@ -104,26 +104,6 @@ ipcMainInternal.on(IPC_MESSAGES.BROWSER_PRELOAD_ERROR, function (event, preloadP
   event.sender.emit('preload-error', event, preloadPath, error);
 });
 
-ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_LAST_CRASH_REPORT, () => {
-  return crashReporter.getLastCrashReport();
-});
-
-ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOADED_REPORTS, () => {
-  return crashReporter.getUploadedReports();
-});
-
-ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOAD_TO_SERVER, () => {
-  return crashReporter.getUploadToServer();
-});
-
-ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_SET_UPLOAD_TO_SERVER, (event, uploadToServer: boolean) => {
-  return crashReporter.setUploadToServer(uploadToServer);
-});
-
-ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_CRASHES_DIRECTORY, () => {
-  return crashReporter.getCrashesDirectory();
-});
-
 ipcMainInternal.handle(IPC_MESSAGES.NATIVE_IMAGE_CREATE_THUMBNAIL_FROM_PATH, async (_, path: string, size: Electron.Size) => {
   return typeUtils.serialize(await nativeImage.createThumbnailFromPath(path, size));
 });

+ 0 - 6
lib/common/ipc-messages.ts

@@ -5,12 +5,6 @@ export const enum IPC_MESSAGES {
   BROWSER_SANDBOX_LOAD = 'BROWSER_SANDBOX_LOAD',
   BROWSER_WINDOW_CLOSE = 'BROWSER_WINDOW_CLOSE',
 
-  CRASH_REPORTER_GET_LAST_CRASH_REPORT = 'CRASH_REPORTER_GET_LAST_CRASH_REPORT',
-  CRASH_REPORTER_GET_UPLOADED_REPORTS = 'CRASH_REPORTER_GET_UPLOADED_REPORTS',
-  CRASH_REPORTER_GET_UPLOAD_TO_SERVER = 'CRASH_REPORTER_GET_UPLOAD_TO_SERVER',
-  CRASH_REPORTER_SET_UPLOAD_TO_SERVER = 'CRASH_REPORTER_SET_UPLOAD_TO_SERVER',
-  CRASH_REPORTER_GET_CRASHES_DIRECTORY = 'CRASH_REPORTER_GET_CRASHES_DIRECTORY',
-
   GUEST_INSTANCE_VISIBILITY_CHANGE = 'GUEST_INSTANCE_VISIBILITY_CHANGE',
 
   GUEST_VIEW_INTERNAL_DESTROY_GUEST = 'GUEST_VIEW_INTERNAL_DESTROY_GUEST',

+ 0 - 36
lib/renderer/api/crash-reporter.ts

@@ -1,42 +1,6 @@
-import { invokeSync } from '../ipc-renderer-internal-utils';
-import { deprecate } from 'electron';
-import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
-
 const binding = process._linkedBinding('electron_renderer_crash_reporter');
 
 export default {
-  start (options: Electron.CrashReporterStartOptions) {
-    deprecate.log('crashReporter.start is deprecated in the renderer process. Call it from the main process instead.');
-    for (const [k, v] of Object.entries(options.extra || {})) {
-      binding.addExtraParameter(k, String(v));
-    }
-  },
-
-  getLastCrashReport (): Electron.CrashReport | null {
-    deprecate.log('crashReporter.getLastCrashReport is deprecated in the renderer process. Call it from the main process instead.');
-    return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_LAST_CRASH_REPORT);
-  },
-
-  getUploadedReports () {
-    deprecate.log('crashReporter.getUploadedReports is deprecated in the renderer process. Call it from the main process instead.');
-    return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOADED_REPORTS);
-  },
-
-  getUploadToServer () {
-    deprecate.log('crashReporter.getUploadToServer is deprecated in the renderer process. Call it from the main process instead.');
-    return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOAD_TO_SERVER);
-  },
-
-  setUploadToServer (uploadToServer: boolean) {
-    deprecate.log('crashReporter.setUploadToServer is deprecated in the renderer process. Call it from the main process instead.');
-    return invokeSync(IPC_MESSAGES.CRASH_REPORTER_SET_UPLOAD_TO_SERVER, uploadToServer);
-  },
-
-  getCrashesDirectory () {
-    deprecate.log('crashReporter.getCrashesDirectory is deprecated in the renderer process. Call it from the main process instead.');
-    return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_CRASHES_DIRECTORY);
-  },
-
   addExtraParameter (key: string, value: string) {
     binding.addExtraParameter(key, value);
   },

+ 3 - 7
spec-main/api-crash-reporter-spec.ts

@@ -523,10 +523,6 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
       expect(app.getPath('crashDumps')).to.include(app.getPath('userData'));
     });
 
-    it('matches getCrashesDirectory', async () => {
-      expect(app.getPath('crashDumps')).to.equal(require('electron').crashReporter.getCrashesDirectory());
-    });
-
     function crash (processType: string, remotely: Function) {
       if (processType === 'main') {
         return remotely(() => {
@@ -565,9 +561,9 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
         it('stores crashes in the crash dump directory when uploadToServer: false', async () => {
           const { remotely } = await startRemoteControlApp();
           const crashesDir = await remotely(() => {
-            const { crashReporter } = require('electron');
+            const { crashReporter, app } = require('electron');
             crashReporter.start({ submitURL: 'http://127.0.0.1', uploadToServer: false, ignoreSystemCrashHandler: true });
-            return crashReporter.getCrashesDirectory();
+            return app.getPath('crashDumps');
           });
           let reportsDir = crashesDir;
           if (process.platform === 'darwin') {
@@ -599,7 +595,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
             const { crashReporter, app } = require('electron');
             app.setPath('crashDumps', crashesDir);
             crashReporter.start({ submitURL: 'http://127.0.0.1', uploadToServer: false, ignoreSystemCrashHandler: true });
-            return crashReporter.getCrashesDirectory();
+            return app.getPath('crashDumps');
           }, crashesDir);
           expect(remoteCrashesDir).to.equal(crashesDir);