cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / common / extensions / api / file_system_provider.idl
blob96ef449a7160a2f4136c20dd77ba3ccc13fd3cd8
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.fileSystemProvider</code> API to create file systems,
6 // that can be accessible from the file manager on Chrome OS.
7 [implemented_in="chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h"]
8 namespace fileSystemProvider {
9 // Error codes used by providing extensions in response to requests as well
10 // as in case of errors when calling methods of the API. For success,
11 // <code>"OK"</code> must be used.
12 enum ProviderError {
13 OK,
14 FAILED,
15 IN_USE,
16 EXISTS,
17 NOT_FOUND,
18 ACCESS_DENIED,
19 TOO_MANY_OPENED,
20 NO_MEMORY,
21 NO_SPACE,
22 NOT_A_DIRECTORY,
23 INVALID_OPERATION,
24 SECURITY,
25 ABORT,
26 NOT_A_FILE,
27 NOT_EMPTY,
28 INVALID_URL,
32 // Mode of opening a file. Used by $(ref:onOpenFileRequested).
33 enum OpenFileMode {
34 READ,
35 WRITE
38 // Type of a change detected on the observed directory.
39 enum ChangeType {
40 CHANGED,
41 DELETED
44 // List of common actions. <code>"SHARE"</code> is for sharing files with
45 // others. <code>"SAVE_FOR_OFFLINE"</code> for pinning (saving for offline
46 // access). <code>"OFFLINE_NOT_NECESSARY"</code> for notifying that the file
47 // doesn't need to be stored for offline access anymore.
48 // Used by $(ref:onGetActionsRequested) and $(ref:onExecuteActionRequested).
49 enum CommonActionId {
50 SAVE_FOR_OFFLINE,
51 OFFLINE_NOT_NECESSARY,
52 SHARE
55 // Represents metadata of a file or a directory.
56 dictionary EntryMetadata {
57 // True if it is a directory.
58 boolean isDirectory;
60 // Name of this entry (not full path name). Must not contain '/'. For root
61 // it must be empty.
62 DOMString name;
64 // File size in bytes.
65 double size;
67 // The last modified time of this entry.
68 [instanceOf=Date] object modificationTime;
70 // Mime type for the entry.
71 DOMString? mimeType;
73 // Thumbnail image as a data URI in either PNG, JPEG or WEBP format, at most
74 // 32 KB in size. Optional, but can be provided only when explicitly
75 // requested by the $(ref:onGetMetadataRequested) event.
76 DOMString? thumbnail;
79 // Represents a watcher.
80 dictionary Watcher {
81 // The path of the entry being observed.
82 DOMString entryPath;
84 // Whether watching should include all child entries recursively. It can be
85 // true for directories only.
86 boolean recursive;
88 // Tag used by the last notification for the watcher.
89 DOMString? lastTag;
92 // Represents an opened file.
93 dictionary OpenedFile {
94 // A request ID to be be used by consecutive read/write and close requests.
95 long openRequestId;
97 // The path of the opened file.
98 DOMString filePath;
100 // Whether the file was opened for reading or writing.
101 OpenFileMode mode;
104 // Represents a mounted file system.
105 dictionary FileSystemInfo {
106 // The identifier of the file system.
107 DOMString fileSystemId;
109 // A human-readable name for the file system.
110 DOMString displayName;
112 // Whether the file system supports operations which may change contents
113 // of the file system (such as creating, deleting or writing to files).
114 boolean writable;
116 // The maximum number of files that can be opened at once. If 0, then not
117 // limited.
118 long openedFilesLimit;
120 // List of currently opened files.
121 OpenedFile[] openedFiles;
123 // Whether the file system supports the <code>tag</code> field for observing
124 // directories.
125 boolean? supportsNotifyTag;
127 // List of watchers.
128 Watcher[] watchers;
131 // Options for the $(ref:mount) method.
132 dictionary MountOptions {
133 // The string indentifier of the file system. Must be unique per each
134 // extension.
135 DOMString fileSystemId;
137 // A human-readable name for the file system.
138 DOMString displayName;
140 // Whether the file system supports operations which may change contents
141 // of the file system (such as creating, deleting or writing to files).
142 boolean? writable;
144 // The maximum number of files that can be opened at once. If not specified,
145 // or 0, then not limited.
146 long? openedFilesLimit;
148 // Whether the file system supports the <code>tag</code> field for observed
149 // directories.
150 boolean? supportsNotifyTag;
153 // Options for the $(ref:unmount) method.
154 dictionary UnmountOptions {
155 // The identifier of the file system to be unmounted.
156 DOMString fileSystemId;
159 // Options for the $(ref:onUnmountRequested) event.
160 dictionary UnmountRequestedOptions {
161 // The identifier of the file system to be unmounted.
162 DOMString fileSystemId;
164 // The unique identifier of this request.
165 long requestId;
168 // Options for the $(ref:onGetMetadataRequested) event.
169 dictionary GetMetadataRequestedOptions {
170 // The identifier of the file system related to this operation.
171 DOMString fileSystemId;
173 // The unique identifier of this request.
174 long requestId;
176 // The path of the entry to fetch metadata about.
177 DOMString entryPath;
179 // Set to <code>true</code> if the thumbnail is requested.
180 boolean thumbnail;
183 // Options for the $(ref:onGetActionsRequested) event.
184 dictionary GetActionsRequestedOptions {
185 // The identifier of the file system related to this operation.
186 DOMString fileSystemId;
188 // The unique identifier of this request.
189 long requestId;
191 // The path of the entry to return the list of actions for.
192 DOMString entryPath;
195 // Options for the $(ref:onReadDirectoryRequested) event.
196 dictionary ReadDirectoryRequestedOptions {
197 // The identifier of the file system related to this operation.
198 DOMString fileSystemId;
200 // The unique identifier of this request.
201 long requestId;
203 // The path of the directory which contents are requested.
204 DOMString directoryPath;
207 // Options for the $(ref:onOpenFileRequested) event.
208 dictionary OpenFileRequestedOptions {
209 // The identifier of the file system related to this operation.
210 DOMString fileSystemId;
212 // A request ID which will be used by consecutive read/write and close
213 // requests.
214 long requestId;
216 // The path of the file to be opened.
217 DOMString filePath;
219 // Whether the file will be used for reading or writing.
220 OpenFileMode mode;
223 // Options for the $(ref:onCloseFileRequested) event.
224 dictionary CloseFileRequestedOptions {
225 // The identifier of the file system related to this operation.
226 DOMString fileSystemId;
228 // The unique identifier of this request.
229 long requestId;
231 // A request ID used to open the file.
232 long openRequestId;
235 // Options for the $(ref:onReadFileRequested) event.
236 dictionary ReadFileRequestedOptions {
237 // The identifier of the file system related to this operation.
238 DOMString fileSystemId;
240 // The unique identifier of this request.
241 long requestId;
243 // A request ID used to open the file.
244 long openRequestId;
246 // Position in the file (in bytes) to start reading from.
247 double offset;
249 // Number of bytes to be returned.
250 double length;
253 // Options for the $(ref:onCreateDirectoryRequested) event.
254 dictionary CreateDirectoryRequestedOptions {
255 // The identifier of the file system related to this operation.
256 DOMString fileSystemId;
258 // The unique identifier of this request.
259 long requestId;
261 // The path of the directory to be created.
262 DOMString directoryPath;
264 // Whether the operation is recursive (for directories only).
265 boolean recursive;
268 // Options for the $(ref:onDeleteEntryRequested) event.
269 dictionary DeleteEntryRequestedOptions {
270 // The identifier of the file system related to this operation.
271 DOMString fileSystemId;
273 // The unique identifier of this request.
274 long requestId;
276 // The path of the entry to be deleted.
277 DOMString entryPath;
279 // Whether the operation is recursive (for directories only).
280 boolean recursive;
283 // Options for the $(ref:onCreateFileRequested) event.
284 dictionary CreateFileRequestedOptions {
285 // The identifier of the file system related to this operation.
286 DOMString fileSystemId;
288 // The unique identifier of this request.
289 long requestId;
291 // The path of the file to be created.
292 DOMString filePath;
295 // Options for the $(ref:onCopyEntryRequested) event.
296 dictionary CopyEntryRequestedOptions {
297 // The identifier of the file system related to this operation.
298 DOMString fileSystemId;
300 // The unique identifier of this request.
301 long requestId;
303 // The source path of the entry to be copied.
304 DOMString sourcePath;
306 // The destination path for the copy operation.
307 DOMString targetPath;
310 // Options for the $(ref:onMoveEntryRequested) event.
311 dictionary MoveEntryRequestedOptions {
312 // The identifier of the file system related to this operation.
313 DOMString fileSystemId;
315 // The unique identifier of this request.
316 long requestId;
318 // The source path of the entry to be moved into a new place.
319 DOMString sourcePath;
321 // The destination path for the copy operation.
322 DOMString targetPath;
325 // Options for the $(ref:onTruncateRequested) event.
326 dictionary TruncateRequestedOptions {
327 // The identifier of the file system related to this operation.
328 DOMString fileSystemId;
330 // The unique identifier of this request.
331 long requestId;
333 // The path of the file to be truncated.
334 DOMString filePath;
336 // Number of bytes to be retained after the operation completes.
337 double length;
340 // Options for the $(ref:onWriteFileRequested) event.
341 dictionary WriteFileRequestedOptions {
342 // The identifier of the file system related to this operation.
343 DOMString fileSystemId;
345 // The unique identifier of this request.
346 long requestId;
348 // A request ID used to open the file.
349 long openRequestId;
351 // Position in the file (in bytes) to start writing the bytes from.
352 double offset;
354 // Buffer of bytes to be written to the file.
355 ArrayBuffer data;
358 // Options for the $(ref:onAbortRequested) event.
359 dictionary AbortRequestedOptions {
360 // The identifier of the file system related to this operation.
361 DOMString fileSystemId;
363 // The unique identifier of this request.
364 long requestId;
366 // An ID of the request to be aborted.
367 long operationRequestId;
370 // Options for the $(ref:onAddWatcherRequested) event.
371 dictionary AddWatcherRequestedOptions {
372 // The identifier of the file system related to this operation.
373 DOMString fileSystemId;
375 // The unique identifier of this request.
376 long requestId;
378 // The path of the entry to be observed.
379 DOMString entryPath;
381 // Whether observing should include all child entries recursively. It can be
382 // true for directories only.
383 boolean recursive;
386 // Options for the $(ref:onRemoveWatcherRequested) event.
387 dictionary RemoveWatcherRequestedOptions {
388 // The identifier of the file system related to this operation.
389 DOMString fileSystemId;
391 // The unique identifier of this request.
392 long requestId;
394 // The path of the watched entry.
395 DOMString entryPath;
397 // Mode of the watcher.
398 boolean recursive;
401 // Information about an action for an entry.
402 dictionary Action {
403 // The identifier of the action. Any string or $(ref:CommonActionId) for
404 // common actions.
405 DOMString id;
407 // The title of the action. It may be ignored for common actions.
408 DOMString? title;
411 // Options for the $(ref:onExecuteActionRequested) event.
412 dictionary ExecuteActionRequestedOptions {
413 // The identifier of the file system related to this operation.
414 DOMString fileSystemId;
416 // The unique identifier of this request.
417 long requestId;
419 // The path of the entry to be used for the action.
420 DOMString entryPath;
422 // The identifier of the action to be executed.
423 DOMString actionId;
426 // Information about a change happened to an entry within the observed
427 // directory (including the entry itself).
428 dictionary Change {
429 // The path of the changed entry.
430 DOMString entryPath;
432 // The type of the change which happened to the entry.
433 ChangeType changeType;
436 // Options for the $(ref:notify) method.
437 dictionary NotifyOptions {
438 // The identifier of the file system related to this change.
439 DOMString fileSystemId;
441 // The path of the observed entry.
442 DOMString observedPath;
444 // Mode of the observed entry.
445 boolean recursive;
447 // The type of the change which happened to the observed entry. If it is
448 // DELETED, then the observed entry will be automatically removed from the
449 // list of observed entries.
450 ChangeType changeType;
452 // List of changes to entries within the observed directory (including the
453 // entry itself)
454 Change[]? changes;
456 // Tag for the notification. Required if the file system was mounted with
457 // the <code>supportsNotifyTag</code> option. Note, that this flag is
458 // necessary to provide notifications about changes which changed even
459 // when the system was shutdown.
460 DOMString? tag;
463 // Options for the $(ref:onConfigureRequested) event.
464 dictionary ConfigureRequestedOptions {
465 // The identifier of the file system to be configured.
466 DOMString fileSystemId;
468 // The unique identifier of this request.
469 long requestId;
472 // Callback to receive the result of $(ref:getAll) function.
473 callback GetAllCallback = void(FileSystemInfo[] fileSystems);
475 // Callback to receive the result of $(ref:get) function.
476 callback GetCallback = void(FileSystemInfo fileSystem);
478 // Callback to be called by the providing extension in case of a success.
479 [nocompile] callback ProviderSuccessCallback = void();
481 // Callback to be called by the providing extension in case of an error.
482 [nocompile] callback ProviderErrorCallback = void(ProviderError error);
484 // Success callback for the $(ref:onGetMetadataRequested) event.
485 [nocompile] callback MetadataCallback = void(EntryMetadata metadata);
487 // Success callback for the $(ref:onGetActionsRequested) event.
488 [nocompile, nodoc] callback ActionsCallback = void(Action[] actions);
490 // Success callback for the $(ref:onReadDirectoryRequested) event. If more
491 // entries will be returned, then <code>hasMore</code> must be true, and it
492 // has to be called again with additional entries. If no more entries are
493 // available, then <code>hasMore</code> must be set to false.
494 [nocompile] callback EntriesCallback = void(
495 EntryMetadata[] entries, boolean hasMore);
497 // Success callback for the $(ref:onReadFileRequested) event. If more
498 // data will be returned, then <code>hasMore</code> must be true, and it
499 // has to be called again with additional entries. If no more data is
500 // available, then <code>hasMore</code> must be set to false.
501 [nocompile] callback FileDataCallback = void(
502 ArrayBuffer data, boolean hasMore);
504 // A generic result callback to indicate success or failure.
505 callback ResultCallback = void();
507 interface Functions {
508 // Mounts a file system with the given <code>fileSystemId</code> and
509 // <code>displayName</code>. <code>displayName</code> will be shown in the
510 // left panel of Files.app. <code>displayName</code> can contain any
511 // characters including '/', but cannot be an empty string.
512 // <code>displayName</code> must be descriptive but doesn't have to be
513 // unique. The <code>fileSystemId</code> must not be an empty string.
515 // Depending on the type of the file system being mounted, the
516 // <code>source</code> option must be set appropriately.
518 // In case of an error, $(ref:runtime.lastError) will be set with a
519 // corresponding error code.
520 static void mount(MountOptions options,
521 optional ResultCallback callback);
523 // Unmounts a file system with the given <code>fileSystemId</code>. It
524 // must be called after $(ref:onUnmountRequested) is invoked. Also,
525 // the providing extension can decide to perform unmounting if not requested
526 // (eg. in case of lost connection, or a file error).
528 // In case of an error, $(ref:runtime.lastError) will be set with a
529 // corresponding error code.
530 static void unmount(UnmountOptions options,
531 optional ResultCallback callback);
533 // Returns all file systems mounted by the extension.
534 static void getAll(GetAllCallback callback);
536 // Returns information about a file system with the passed
537 // <code>fileSystemId</code>.
538 static void get(DOMString fileSystemId, GetCallback callback);
540 // Notifies about changes in the watched directory at
541 // <code>observedPath</code> in <code>recursive</code> mode. If the file
542 // system is mounted with <code>supportsNofityTag</code>, then
543 // <code>tag</code> must be provided, and all changes since the last
544 // notification always reported, even if the system was shutdown. The last
545 // tag can be obtained with $(ref:getAll).
547 // To use, the <code>file_system_provider.notify</code> manifest option
548 // must be set to true.
550 // Value of <code>tag</code> can be any string which is unique per call,
551 // so it's possible to identify the last registered notification. Eg. if
552 // the providing extension starts after a reboot, and the last registered
553 // notification's tag is equal to "123", then it should call $(ref:notify)
554 // for all changes which happened since the change tagged as "123". It
555 // cannot be an empty string.
557 // Not all providers are able to provide a tag, but if the file system has
558 // a changelog, then the tag can be eg. a change number, or a revision
559 // number.
561 // Note that if a parent directory is removed, then all descendant entries
562 // are also removed, and if they are watched, then the API must be notified
563 // about the fact. Also, if a directory is renamed, then all descendant
564 // entries are in fact removed, as there is no entry under their original
565 // paths anymore.
567 // In case of an error, $(ref:runtime.lastError) will be set
568 // will a corresponding error code.
569 static void notify(NotifyOptions options,
570 optional ResultCallback callback);
573 interface Events {
574 // Raised when unmounting for the file system with the
575 // <code>fileSystemId</code> identifier is requested. In the response, the
576 // $(ref:unmount) API method must be called together with
577 // <code>successCallback</code>. If unmounting is not possible (eg. due to
578 // a pending operation), then <code>errorCallback</code> must be called.
579 [maxListeners=1] static void onUnmountRequested(
580 UnmountRequestedOptions options,
581 ProviderSuccessCallback successCallback,
582 ProviderErrorCallback errorCallback);
584 // Raised when metadata of a file or a directory at <code>entryPath</code>
585 // is requested. The metadata must be returned with the
586 // <code>successCallback</code> call. In case of an error,
587 // <code>errorCallback</code> must be called.
588 [maxListeners=1] static void onGetMetadataRequested(
589 GetMetadataRequestedOptions options,
590 MetadataCallback successCallback,
591 ProviderErrorCallback errorCallback);
593 // Raised when list of actions for of a file or a directory at
594 // <code>entryPath</code>s requested. The actions must be returned with the
595 // <code>successCallback</code> call. In case of an error,
596 // <code>errorCallback</code> must be called.
597 [maxListeners=1, nodoc] static void onGetActionsRequested(
598 GetActionsRequestedOptions options,
599 ActionsCallback successCallback,
600 ProviderErrorCallback errorCallback);
602 // Raised when contents of a directory at <code>directoryPath</code> are
603 // requested. The results must be returned in chunks by calling the
604 // <code>successCallback</code> several times. In case of an error,
605 // <code>errorCallback</code> must be called.
606 [maxListeners=1] static void onReadDirectoryRequested(
607 ReadDirectoryRequestedOptions options,
608 EntriesCallback successCallback,
609 ProviderErrorCallback errorCallback);
611 // Raised when opening a file at <code>filePath</code> is requested. If the
612 // file does not exist, then the operation must fail. Maximum number of
613 // files opened at once can be specified with <code>MountOptions</code>.
614 [maxListeners=1] static void onOpenFileRequested(
615 OpenFileRequestedOptions options,
616 ProviderSuccessCallback successCallback,
617 ProviderErrorCallback errorCallback);
619 // Raised when opening a file previously opened with
620 // <code>openRequestId</code> is requested to be closed.
621 [maxListeners=1] static void onCloseFileRequested(
622 CloseFileRequestedOptions options,
623 ProviderSuccessCallback successCallback,
624 ProviderErrorCallback errorCallback);
626 // Raised when reading contents of a file opened previously with
627 // <code>openRequestId</code> is requested. The results must be returned in
628 // chunks by calling <code>successCallback</code> several times. In case of
629 // an error, <code>errorCallback</code> must be called.
630 [maxListeners=1] static void onReadFileRequested(
631 ReadFileRequestedOptions options,
632 FileDataCallback successCallback,
633 ProviderErrorCallback errorCallback);
635 // Raised when creating a directory is requested. The operation must fail
636 // with the EXISTS error if the target directory already exists.
637 // If <code>recursive</code> is true, then all of the missing directories
638 // on the directory path must be created.
639 [maxListeners=1] static void onCreateDirectoryRequested(
640 CreateDirectoryRequestedOptions options,
641 ProviderSuccessCallback successCallback,
642 ProviderErrorCallback errorCallback);
644 // Raised when deleting an entry is requested. If <code>recursive</code> is
645 // true, and the entry is a directory, then all of the entries inside
646 // must be recursively deleted as well.
647 [maxListeners=1] static void onDeleteEntryRequested(
648 DeleteEntryRequestedOptions options,
649 ProviderSuccessCallback successCallback,
650 ProviderErrorCallback errorCallback);
652 // Raised when creating a file is requested. If the file already exists,
653 // then <code>errorCallback</code> must be called with the
654 // <code>"EXISTS"</code> error code.
655 [maxListeners=1] static void onCreateFileRequested(
656 CreateFileRequestedOptions options,
657 ProviderSuccessCallback successCallback,
658 ProviderErrorCallback errorCallback);
660 // Raised when copying an entry (recursively if a directory) is requested.
661 // If an error occurs, then <code>errorCallback</code> must be called.
662 [maxListeners=1] static void onCopyEntryRequested(
663 CopyEntryRequestedOptions options,
664 ProviderSuccessCallback successCallback,
665 ProviderErrorCallback errorCallback);
667 // Raised when moving an entry (recursively if a directory) is requested.
668 // If an error occurs, then <code>errorCallback</code> must be called.
669 [maxListeners=1] static void onMoveEntryRequested(
670 MoveEntryRequestedOptions options,
671 ProviderSuccessCallback successCallback,
672 ProviderErrorCallback errorCallback);
674 // Raised when truncating a file to a desired length is requested.
675 // If an error occurs, then <code>errorCallback</code> must be called.
676 [maxListeners=1] static void onTruncateRequested(
677 TruncateRequestedOptions options,
678 ProviderSuccessCallback successCallback,
679 ProviderErrorCallback errorCallback);
681 // Raised when writing contents to a file opened previously with
682 // <code>openRequestId</code> is requested.
683 [maxListeners=1] static void onWriteFileRequested(
684 WriteFileRequestedOptions options,
685 ProviderSuccessCallback successCallback,
686 ProviderErrorCallback errorCallback);
688 // Raised when aborting an operation with <code>operationRequestId</code>
689 // is requested. The operation executed with <code>operationRequestId</code>
690 // must be immediately stopped and <code>successCallback</code> of this
691 // abort request executed. If aborting fails, then
692 // <code>errorCallback</code> must be called. Note, that callbacks of the
693 // aborted operation must not be called, as they will be ignored. Despite
694 // calling <code>errorCallback</code>, the request may be forcibly aborted.
695 [maxListeners=1] static void onAbortRequested(
696 AbortRequestedOptions options,
697 ProviderSuccessCallback successCallback,
698 ProviderErrorCallback errorCallback);
700 // Raised when showing a configuration dialog for <code>fileSystemId</code>
701 // is requested. If it's handled, the
702 // <code>file_system_provider.configurable</code> manfiest option must be
703 // set to true.
704 [maxListeners=1] static void onConfigureRequested(
705 ConfigureRequestedOptions options,
706 ProviderSuccessCallback successCallback,
707 ProviderErrorCallback errorCallback);
709 // Raised when showing a dialog for mounting a new file system is requested.
710 // If the extension/app is a file handler, then this event shouldn't be
711 // handled. Instead <code>app.runtime.onLaunched</code> should be handled in
712 // order to mount new file systems when a file is opened. For multiple
713 // mounts, the <code>file_system_provider.multiple_mounts</code> manifest
714 // option must be set to true.
715 [maxListeners=1] static void onMountRequested(
716 ProviderSuccessCallback successCallback,
717 ProviderErrorCallback errorCallback);
719 // Raised when setting a new directory watcher is requested. If an error
720 // occurs, then <code>errorCallback</code> must be called.
721 [maxListeners=1] static void onAddWatcherRequested(
722 AddWatcherRequestedOptions options,
723 ProviderSuccessCallback successCallback,
724 ProviderErrorCallback errorCallback);
726 // Raised when the watcher should be removed. If an error occurs, then
727 // <code>errorCallback</code> must be called.
728 [maxListeners=1] static void onRemoveWatcherRequested(
729 RemoveWatcherRequestedOptions options,
730 ProviderSuccessCallback successCallback,
731 ProviderErrorCallback errorCallback);
733 // Raised when executing an action for a file or a directory is requested.
734 // After the action is completed, <code>successCallback</code> must be
735 // called. On error, <code>errorCallback</code> must be called.
736 [maxListeners=1, nodoc] static void onExecuteActionRequested(
737 ExecuteActionRequestedOptions options,
738 ProviderSuccessCallback successCallback,
739 ProviderErrorCallback errorCallback);