OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
Greg Billock
2013/07/16 17:54:40
Can you rework this according to bug 252994 now? I
| |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.experimental.systemInfo.storage</code> API to query | 5 // Use the <code>chrome.systemInfo.storage</code> API to query |
6 // storage device information and be notified when it changes. | 6 // storage device information and be notified when a removable storage device is |
7 namespace experimental.systemInfo.storage { | 7 // attached and detached. |
8 namespace systemInfo.storage { | |
8 | 9 |
9 enum StorageUnitType { | 10 enum StorageUnitType { |
10 // The storage has fixed media, e.g. hard disk or SSD. | 11 // The storage has fixed media, e.g. hard disk or SSD. |
11 fixed, | 12 fixed, |
12 // The storage is removable, e.g. USB flash drive. | 13 // The storage is removable, e.g. USB flash drive. |
13 removable, | 14 removable, |
14 // The storage type is unknown. | 15 // The storage type is unknown. |
15 unknown | 16 unknown |
16 }; | 17 }; |
17 | 18 |
18 dictionary StorageUnitInfo { | 19 dictionary StorageUnitInfo { |
19 // The unique storage id. It will use the transient ID. | 20 // The unique storage id. It will use the transient ID. |
20 DOMString id; | 21 DOMString id; |
21 // The name of the storage unit. | 22 // The name of the storage unit. |
22 DOMString name; | 23 DOMString name; |
23 // The media type of the storage unit. | 24 // The media type of the storage unit. |
24 StorageUnitType type; | 25 StorageUnitType type; |
25 // The total amount of the storage space, in bytes. | 26 // The total amount of the storage space, in bytes. |
26 // Default value is 0 if query operation fails. | |
27 double capacity; | 27 double capacity; |
28 // The available amount of the storage space, in bytes. | |
29 // Default value is 0 if query operation fails. | |
30 double availableCapacity; | |
31 }; | 28 }; |
32 | 29 |
33 [inline_doc] enum EjectDeviceResultCode { | 30 [inline_doc] enum EjectDeviceResultCode { |
34 // The ejection command is successful -- the application can prompt the user | 31 // The ejection command is successful -- the application can prompt the user |
35 // to remove the device. | 32 // to remove the device. |
36 success, | 33 success, |
37 // The device is in use by another application. The ejection did not | 34 // The device is in use by another application. The ejection did not |
38 // succeed; the user should not remove the device until the other | 35 // succeed; the user should not remove the device until the other |
39 // application is done with the device. | 36 // application is done with the device. |
40 in_use, | 37 in_use, |
41 // There is no such device known. | 38 // There is no such device known. |
42 no_such_device, | 39 no_such_device, |
43 // The ejection command failed. | 40 // The ejection command failed. |
44 failure | 41 failure |
45 }; | 42 }; |
46 | 43 |
47 dictionary StorageFreeSpaceChangeInfo { | 44 callback EjectDeviceCallback = void (EjectDeviceResultCode result); |
48 // The transient id of the storage unit already changed. | |
49 DOMString id; | |
50 // The new value of the available capacity. | |
51 double availableCapacity; | |
52 }; | |
53 | |
54 // A dictionary that describes the add particular storage device watch | |
55 // request results. | |
56 dictionary AddWatchResult { | |
57 DOMString id; | |
58 boolean success; | |
59 }; | |
60 | 45 |
61 callback StorageInfoCallback = void (StorageUnitInfo[] info); | 46 callback StorageInfoCallback = void (StorageUnitInfo[] info); |
62 | 47 |
63 callback EjectDeviceCallback = void (EjectDeviceResultCode result); | |
64 | |
65 callback AddWatchCallback = void (AddWatchResult info); | |
66 | |
67 callback GetAllWatchCallback = void (DOMString[] storageIds); | |
68 | |
69 interface Functions { | 48 interface Functions { |
70 // Get the storage information from the system. The argument passed to the | 49 // Get the storage information from the system. The argument passed to the |
71 // callback is an array of StorageUnitInfo objects. | 50 // callback is an array of StorageUnitInfo objects. |
72 static void get(StorageInfoCallback callback); | 51 static void get(StorageInfoCallback callback); |
73 | 52 |
74 // Ejects a removable storage device. | 53 // Ejects a removable storage device. |
75 // Note: We plan to move this function into a namespace that indicates it | 54 // Note: We plan to move this function into a namespace that indicates it |
76 // that modifies the state of the system rather than just gathering | 55 // that modifies the state of the system rather than just gathering |
77 // information. | 56 // information. |
78 static void ejectDevice(DOMString id, EjectDeviceCallback callback); | 57 static void ejectDevice(DOMString id, EjectDeviceCallback callback); |
79 | |
80 // Monitor a particular storage device available change capacity. | |
81 static void addWatch(DOMString id, AddWatchCallback callback); | |
82 | |
83 // Remove the monitor of a particular device. | |
84 static void removeWatch(DOMString id); | |
85 | |
86 // Get all the watched storage devices. | |
87 static void getAllWatch(GetAllWatchCallback callback); | |
88 | |
89 // Remove all the storage devices monitors. | |
90 static void removeAllWatch(); | |
91 }; | 58 }; |
92 | 59 |
93 interface Events { | 60 interface Events { |
94 // Fired when the storage device available capacity is changed. | |
95 // |info|: The changed information for the specified storage unit. | |
96 static void onAvailableCapacityChanged(StorageFreeSpaceChangeInfo info); | |
97 | |
98 // Fired when a new removable storage is attached to the system. | 61 // Fired when a new removable storage is attached to the system. |
99 static void onAttached(StorageUnitInfo info); | 62 static void onAttached(StorageUnitInfo info); |
100 | 63 |
101 // Fired when a removable storage is detached from the system. | 64 // Fired when a removable storage is detached from the system. |
102 static void onDetached(DOMString id); | 65 static void onDetached(DOMString id); |
103 }; | 66 }; |
104 | 67 |
105 }; | 68 }; |
106 | 69 |
OLD | NEW |