Dart Documentationchrome.processesChromeProcesses

ChromeProcesses class

class ChromeProcesses extends ChromeApi {
 static final JsObject _processes = chrome['processes'];

 ChromeProcesses._();

 bool get available => _processes != null;

 /**
  * Terminates the specified renderer process. Equivalent to visiting
  * about:crash, but without changing the tab's URL.
  * 
  * [processId] The ID of the process to be terminated.
  * 
  * Returns:
  * True if terminating the process was successful, otherwise false.
  */
 Future<bool> terminate(int processId) {
   if (_processes == null) _throwNotAvailable();

   var completer = new ChromeCompleter<bool>.oneArg();
   _processes.callMethod('terminate', [processId, completer.callback]);
   return completer.future;
 }

 /**
  * Returns the ID of the renderer process for the specified tab.
  * 
  * [tabId] The ID of the tab for which the renderer process ID is to be
  * returned.
  * 
  * Returns:
  * Process ID of the tab's renderer process.
  */
 Future<int> getProcessIdForTab(int tabId) {
   if (_processes == null) _throwNotAvailable();

   var completer = new ChromeCompleter<int>.oneArg();
   _processes.callMethod('getProcessIdForTab', [tabId, completer.callback]);
   return completer.future;
 }

 /**
  * Retrieves the process information for each process ID specified.
  * 
  * [processIds] The list of process IDs or single process ID for which to
  * return the process information. An empty list indicates all processes are
  * requested.
  * 
  * [includeMemory] True if detailed memory usage is required. Note, collecting
  * memory usage information incurs extra CPU usage and should only be queried
  * for when needed.
  * 
  * Returns:
  * A dictionary of Process objects for each requested process that is a live
  * child process of the current browser process, indexed by process ID.
  * Metrics requiring aggregation over time will not be populated in each
  * Process object.
  */
 Future<Map> getProcessInfo(dynamic processIds, bool includeMemory) {
   if (_processes == null) _throwNotAvailable();

   var completer = new ChromeCompleter<Map>.oneArg(mapify);
   _processes.callMethod('getProcessInfo', [jsify(processIds), includeMemory, completer.callback]);
   return completer.future;
 }

 /**
  * Fired each time the Task Manager updates its process statistics, providing
  * the dictionary of updated Process objects, indexed by process ID.
  */
 Stream<Map> get onUpdated => _onUpdated.stream;

 final ChromeStreamController<Map> _onUpdated =
     new ChromeStreamController<Map>.oneArg(_processes, 'onUpdated', mapify);

 /**
  * Fired each time the Task Manager updates its process statistics, providing
  * the dictionary of updated Process objects, indexed by process ID. Identical
  * to onUpdate, with the addition of memory usage details included in each
  * Process object. Note, collecting memory usage information incurs extra CPU
  * usage and should only be listened for when needed.
  */
 Stream<Map> get onUpdatedWithMemory => _onUpdatedWithMemory.stream;

 final ChromeStreamController<Map> _onUpdatedWithMemory =
     new ChromeStreamController<Map>.oneArg(_processes, 'onUpdatedWithMemory', mapify);

 /**
  * Fired each time a process is created, providing the corrseponding Process
  * object.
  */
 Stream<Process> get onCreated => _onCreated.stream;

 final ChromeStreamController<Process> _onCreated =
     new ChromeStreamController<Process>.oneArg(_processes, 'onCreated', _createProcess);

 /**
  * Fired each time a process becomes unresponsive, providing the corrseponding
  * Process object.
  */
 Stream<Process> get onUnresponsive => _onUnresponsive.stream;

 final ChromeStreamController<Process> _onUnresponsive =
     new ChromeStreamController<Process>.oneArg(_processes, 'onUnresponsive', _createProcess);

 /**
  * Fired each time a process is terminated, providing the type of exit.
  */
 Stream<OnExitedEvent> get onExited => _onExited.stream;

 final ChromeStreamController<OnExitedEvent> _onExited =
     new ChromeStreamController<OnExitedEvent>.threeArgs(_processes, 'onExited', _createOnExitedEvent);

 void _throwNotAvailable() {
   throw new UnsupportedError("'chrome.processes' is not available");
 }
}

Extends

ChromeApi > ChromeProcesses

Properties

final bool available #

Returns true if the API is available. The common causes of an API not being avilable are:

  • a permission is missing in the application's manifest.json file
  • the API is defined on a newer version of Chrome then the current runtime
docs inherited from ChromeApi
bool get available => _processes != null;

final Stream<Process> onCreated #

Fired each time a process is created, providing the corrseponding Process object.

Stream<Process> get onCreated => _onCreated.stream;

final Stream<OnExitedEvent> onExited #

Fired each time a process is terminated, providing the type of exit.

Stream<OnExitedEvent> get onExited => _onExited.stream;

final Stream<Process> onUnresponsive #

Fired each time a process becomes unresponsive, providing the corrseponding Process object.

Stream<Process> get onUnresponsive => _onUnresponsive.stream;

final Stream<Map> onUpdated #

Fired each time the Task Manager updates its process statistics, providing the dictionary of updated Process objects, indexed by process ID.

Stream<Map> get onUpdated => _onUpdated.stream;

final Stream<Map> onUpdatedWithMemory #

Fired each time the Task Manager updates its process statistics, providing the dictionary of updated Process objects, indexed by process ID. Identical to onUpdate, with the addition of memory usage details included in each Process object. Note, collecting memory usage information incurs extra CPU usage and should only be listened for when needed.

Stream<Map> get onUpdatedWithMemory => _onUpdatedWithMemory.stream;

Methods

Future<int> getProcessIdForTab(int tabId) #

Returns the ID of the renderer process for the specified tab.

tabId The ID of the tab for which the renderer process ID is to be returned.

Returns: Process ID of the tab's renderer process.

Future<int> getProcessIdForTab(int tabId) {
 if (_processes == null) _throwNotAvailable();

 var completer = new ChromeCompleter<int>.oneArg();
 _processes.callMethod('getProcessIdForTab', [tabId, completer.callback]);
 return completer.future;
}

Future<Map> getProcessInfo(processIds, bool includeMemory) #

Retrieves the process information for each process ID specified.

processIds The list of process IDs or single process ID for which to return the process information. An empty list indicates all processes are requested.

includeMemory True if detailed memory usage is required. Note, collecting memory usage information incurs extra CPU usage and should only be queried for when needed.

Returns: A dictionary of Process objects for each requested process that is a live child process of the current browser process, indexed by process ID. Metrics requiring aggregation over time will not be populated in each Process object.

Future<Map> getProcessInfo(dynamic processIds, bool includeMemory) {
 if (_processes == null) _throwNotAvailable();

 var completer = new ChromeCompleter<Map>.oneArg(mapify);
 _processes.callMethod('getProcessInfo', [jsify(processIds), includeMemory, completer.callback]);
 return completer.future;
}

Future<bool> terminate(int processId) #

Terminates the specified renderer process. Equivalent to visiting about:crash, but without changing the tab's URL.

processId The ID of the process to be terminated.

Returns: True if terminating the process was successful, otherwise false.

Future<bool> terminate(int processId) {
 if (_processes == null) _throwNotAvailable();

 var completer = new ChromeCompleter<bool>.oneArg();
 _processes.callMethod('terminate', [processId, completer.callback]);
 return completer.future;
}