OLD | NEW |
| (Empty) |
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. | |
4 | |
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 | |
7 // detached. | |
8 namespace system.storage { | |
9 | |
10 enum StorageUnitType { | |
11 // The storage has fixed media, e.g. hard disk or SSD. | |
12 fixed, | |
13 // The storage is removable, e.g. USB flash drive. | |
14 removable, | |
15 // The storage type is unknown. | |
16 unknown | |
17 }; | |
18 | |
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. | |
24 DOMString id; | |
25 // The name of the storage unit. | |
26 DOMString name; | |
27 // The media type of the storage unit. | |
28 StorageUnitType type; | |
29 // The total amount of the storage space, in bytes. | |
30 double capacity; | |
31 }; | |
32 | |
33 dictionary StorageAvailableCapacityInfo { | |
34 // A copied |id| of getAvailableCapacity function parameter |id|. | |
35 DOMString id; | |
36 // The available capacity of the storage device, in bytes. | |
37 double availableCapacity; | |
38 }; | |
39 | |
40 [inline_doc] enum EjectDeviceResultCode { | |
41 // The ejection command is successful -- the application can prompt the user | |
42 // to remove the device. | |
43 success, | |
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. | |
47 in_use, | |
48 // There is no such device known. | |
49 no_such_device, | |
50 // The ejection command failed. | |
51 failure | |
52 }; | |
53 | |
54 callback EjectDeviceCallback = void (EjectDeviceResultCode result); | |
55 | |
56 callback StorageInfoCallback = void (StorageUnitInfo[] info); | |
57 | |
58 callback GetAvailableCapacityCallback = void ( | |
59 StorageAvailableCapacityInfo info); | |
60 | |
61 interface Functions { | |
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); | |
65 | |
66 // Ejects a removable storage device. | |
67 static void ejectDevice(DOMString id, EjectDeviceCallback callback); | |
68 | |
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); | |
73 }; | |
74 | |
75 interface Events { | |
76 // Fired when a new removable storage is attached to the system. | |
77 static void onAttached(StorageUnitInfo info); | |
78 | |
79 // Fired when a removable storage is detached from the system. | |
80 static void onDetached(DOMString id); | |
81 }; | |
82 | |
83 }; | |
OLD | NEW |