1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Use the <code>chrome.system.storage</code> API to query storage device
6 // information and be notified when a removable storage device is attached and
8 namespace system.storage
{
10 enum StorageUnitType
{
11 // The storage has fixed media, e.g. hard disk or SSD.
13 // The storage is removable, e.g. USB flash drive.
15 // The storage type is unknown.
19 dictionary StorageUnitInfo
{
20 // The transient ID that uniquely identifies the storage device.
21 // This ID will be persistent within the same run of a single application.
22 // It will not be a persistent identifier between different runs of an
23 // application, or between different applications.
25 // The name of the storage unit.
27 // The media type of the storage unit.
29 // The total amount of the storage space, in bytes.
33 dictionary StorageAvailableCapacityInfo
{
34 // A copied |id| of getAvailableCapacity function parameter |id|.
36 // The available capacity of the storage device, in bytes.
37 double availableCapacity
;
40 [inline_doc
] enum EjectDeviceResultCode
{
41 // The ejection command is successful -- the application can prompt the user
42 // to remove the device.
44 // The device is in use by another application. The ejection did not
45 // succeed; the user should not remove the device until the other
46 // application is done with the device.
48 // There is no such device known.
50 // The ejection command failed.
54 callback EjectDeviceCallback
= void (EjectDeviceResultCode result
);
56 callback StorageInfoCallback
= void (StorageUnitInfo
[] info
);
58 callback GetAvailableCapacityCallback
= void (
59 StorageAvailableCapacityInfo info
);
62 // Get the storage information from the system. The argument passed to the
63 // callback is an array of StorageUnitInfo objects.
64 static
void getInfo
(StorageInfoCallback
callback);
66 // Ejects a removable storage device.
67 static
void ejectDevice
(DOMString
id, EjectDeviceCallback
callback);
69 // Get the available capacity of a specified |id| storage device.
70 // The |id| is the transient device ID from StorageUnitInfo.
71 static
void getAvailableCapacity
(DOMString
id,
72 GetAvailableCapacityCallback
callback);
76 // Fired when a new removable storage is attached to the system.
77 static
void onAttached
(StorageUnitInfo info
);
79 // Fired when a removable storage is detached from the system.
80 static
void onDetached
(DOMString
id);