Dart Documentationchrome.systemChromeSystemStorage

ChromeSystemStorage class

Use the chrome.system.storage API to query storage device information and be notified when a removable storage device is attached and detached.

class ChromeSystemStorage extends ChromeApi {
 static final JsObject _system_storage = chrome['system']['storage'];

 ChromeSystemStorage._();

 bool get available => _system_storage != null;

 /**
  * Get the storage information from the system. The argument passed to the
  * callback is an array of StorageUnitInfo objects.
  */
 Future<List<StorageUnitInfo>> getInfo() {
   if (_system_storage == null) _throwNotAvailable();

   var completer = new ChromeCompleter<List<StorageUnitInfo>>.oneArg((e) => listify(e, _createStorageUnitInfo));
   _system_storage.callMethod('getInfo', [completer.callback]);
   return completer.future;
 }

 /**
  * Ejects a removable storage device.
  */
 Future<EjectDeviceResultCode> ejectDevice(String id) {
   if (_system_storage == null) _throwNotAvailable();

   var completer = new ChromeCompleter<EjectDeviceResultCode>.oneArg(_createEjectDeviceResultCode);
   _system_storage.callMethod('ejectDevice', [id, completer.callback]);
   return completer.future;
 }

 /**
  * Get the available capacity of a specified [id] storage device. The [id] is
  * the transient device ID from StorageUnitInfo.
  */
 Future<StorageAvailableCapacityInfo> getAvailableCapacity(String id) {
   if (_system_storage == null) _throwNotAvailable();

   var completer = new ChromeCompleter<StorageAvailableCapacityInfo>.oneArg(_createStorageAvailableCapacityInfo);
   _system_storage.callMethod('getAvailableCapacity', [id, completer.callback]);
   return completer.future;
 }

 Stream<StorageUnitInfo> get onAttached => _onAttached.stream;

 final ChromeStreamController<StorageUnitInfo> _onAttached =
     new ChromeStreamController<StorageUnitInfo>.oneArg(_system_storage, 'onAttached', _createStorageUnitInfo);

 Stream<String> get onDetached => _onDetached.stream;

 final ChromeStreamController<String> _onDetached =
     new ChromeStreamController<String>.oneArg(_system_storage, 'onDetached', selfConverter);

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

Extends

ChromeApi > ChromeSystemStorage

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 => _system_storage != null;

final Stream<StorageUnitInfo> onAttached #

Stream<StorageUnitInfo> get onAttached => _onAttached.stream;

final Stream<String> onDetached #

Stream<String> get onDetached => _onDetached.stream;

Methods

Future<EjectDeviceResultCode> ejectDevice(String id) #

Ejects a removable storage device.

Future<EjectDeviceResultCode> ejectDevice(String id) {
 if (_system_storage == null) _throwNotAvailable();

 var completer = new ChromeCompleter<EjectDeviceResultCode>.oneArg(_createEjectDeviceResultCode);
 _system_storage.callMethod('ejectDevice', [id, completer.callback]);
 return completer.future;
}

Future<StorageAvailableCapacityInfo> getAvailableCapacity(String id) #

Get the available capacity of a specified id storage device. The id is the transient device ID from StorageUnitInfo.

Future<StorageAvailableCapacityInfo> getAvailableCapacity(String id) {
 if (_system_storage == null) _throwNotAvailable();

 var completer = new ChromeCompleter<StorageAvailableCapacityInfo>.oneArg(_createStorageAvailableCapacityInfo);
 _system_storage.callMethod('getAvailableCapacity', [id, completer.callback]);
 return completer.future;
}

Future<List<StorageUnitInfo>> getInfo() #

Get the storage information from the system. The argument passed to the callback is an array of StorageUnitInfo objects.

Future<List<StorageUnitInfo>> getInfo() {
 if (_system_storage == null) _throwNotAvailable();

 var completer = new ChromeCompleter<List<StorageUnitInfo>>.oneArg((e) => listify(e, _createStorageUnitInfo));
 _system_storage.callMethod('getInfo', [completer.callback]);
 return completer.future;
}