Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=40: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | /** |
michael@0 | 10 | * The result of a successful asynchronous operation. |
michael@0 | 11 | */ |
michael@0 | 12 | [scriptable, builtinclass, uuid(08B4CF29-3D65-4E79-B522-A694C322ED07)] |
michael@0 | 13 | interface nsINativeOSFileResult: nsISupports |
michael@0 | 14 | { |
michael@0 | 15 | /** |
michael@0 | 16 | * The actual value produced by the operation. |
michael@0 | 17 | * |
michael@0 | 18 | * Actual type of this value depends on the options passed to the |
michael@0 | 19 | * operation. |
michael@0 | 20 | */ |
michael@0 | 21 | [implicit_jscontext] |
michael@0 | 22 | readonly attribute jsval result; |
michael@0 | 23 | |
michael@0 | 24 | /** |
michael@0 | 25 | * Delay between when the operation was requested on the main thread and |
michael@0 | 26 | * when the operation was started off main thread. |
michael@0 | 27 | */ |
michael@0 | 28 | readonly attribute double dispatchDurationMS; |
michael@0 | 29 | |
michael@0 | 30 | /** |
michael@0 | 31 | * Duration of the off main thread execution. |
michael@0 | 32 | */ |
michael@0 | 33 | readonly attribute double executionDurationMS; |
michael@0 | 34 | }; |
michael@0 | 35 | |
michael@0 | 36 | /** |
michael@0 | 37 | * A callback invoked in case of success. |
michael@0 | 38 | */ |
michael@0 | 39 | [scriptable, function, uuid(2C1922CA-CA1B-4099-8B61-EC23CFF49412)] |
michael@0 | 40 | interface nsINativeOSFileSuccessCallback: nsISupports |
michael@0 | 41 | { |
michael@0 | 42 | void complete(in nsINativeOSFileResult result); |
michael@0 | 43 | }; |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * A callback invoked in case of error. |
michael@0 | 47 | */ |
michael@0 | 48 | [scriptable, function, uuid(F612E0FC-6736-4D24-AA50-FD661B3B40B6)] |
michael@0 | 49 | interface nsINativeOSFileErrorCallback: nsISupports |
michael@0 | 50 | { |
michael@0 | 51 | /** |
michael@0 | 52 | * @param operation The name of the failed operation. Provided to aid |
michael@0 | 53 | * debugging only, may change without notice. |
michael@0 | 54 | * @param OSstatus The OS status of the operation (errno under Unix, |
michael@0 | 55 | * GetLastError under Windows). |
michael@0 | 56 | */ |
michael@0 | 57 | void complete(in ACString operation, in long OSstatus); |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * A service providing native implementations of some of the features |
michael@0 | 62 | * of OS.File. |
michael@0 | 63 | */ |
michael@0 | 64 | [scriptable, builtinclass, uuid(913362AD-1526-4623-9E6B-A2EB08AFBBB9)] |
michael@0 | 65 | interface nsINativeOSFileInternalsService: nsISupports |
michael@0 | 66 | { |
michael@0 | 67 | /** |
michael@0 | 68 | * Implementation of OS.File.read |
michael@0 | 69 | * |
michael@0 | 70 | * @param path The absolute path to the file to read. |
michael@0 | 71 | * @param options An object that may contain some of the following fields |
michael@0 | 72 | * - {number} bytes The maximal number of bytes to read. |
michael@0 | 73 | * - {string} encoding If provided, return the result as a string, decoded |
michael@0 | 74 | * using this encoding. Otherwise, pass the result as an ArrayBuffer. |
michael@0 | 75 | * Invalid encodings cause onError to be called with the platform-specific |
michael@0 | 76 | * "invalid argument" constant. |
michael@0 | 77 | * - {string} compression Unimplemented at the moment. |
michael@0 | 78 | * @param onSuccess The success callback. |
michael@0 | 79 | * @param onError The error callback. |
michael@0 | 80 | */ |
michael@0 | 81 | [implicit_jscontext] |
michael@0 | 82 | void read(in AString path, in jsval options, |
michael@0 | 83 | in nsINativeOSFileSuccessCallback onSuccess, |
michael@0 | 84 | in nsINativeOSFileErrorCallback onError); |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | |
michael@0 | 88 | %{ C++ |
michael@0 | 89 | |
michael@0 | 90 | #define NATIVE_OSFILE_INTERNALS_SERVICE_CID {0x63A69303,0x8A64,0x45A9,{0x84, 0x8C, 0xD4, 0xE2, 0x79, 0x27, 0x94, 0xE6}} |
michael@0 | 91 | #define NATIVE_OSFILE_INTERNALS_SERVICE_CONTRACTID "@mozilla.org/toolkit/osfile/native-internals;1" |
michael@0 | 92 | |
michael@0 | 93 | %} |