michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=40: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: /** michael@0: * The result of a successful asynchronous operation. michael@0: */ michael@0: [scriptable, builtinclass, uuid(08B4CF29-3D65-4E79-B522-A694C322ED07)] michael@0: interface nsINativeOSFileResult: nsISupports michael@0: { michael@0: /** michael@0: * The actual value produced by the operation. michael@0: * michael@0: * Actual type of this value depends on the options passed to the michael@0: * operation. michael@0: */ michael@0: [implicit_jscontext] michael@0: readonly attribute jsval result; michael@0: michael@0: /** michael@0: * Delay between when the operation was requested on the main thread and michael@0: * when the operation was started off main thread. michael@0: */ michael@0: readonly attribute double dispatchDurationMS; michael@0: michael@0: /** michael@0: * Duration of the off main thread execution. michael@0: */ michael@0: readonly attribute double executionDurationMS; michael@0: }; michael@0: michael@0: /** michael@0: * A callback invoked in case of success. michael@0: */ michael@0: [scriptable, function, uuid(2C1922CA-CA1B-4099-8B61-EC23CFF49412)] michael@0: interface nsINativeOSFileSuccessCallback: nsISupports michael@0: { michael@0: void complete(in nsINativeOSFileResult result); michael@0: }; michael@0: michael@0: /** michael@0: * A callback invoked in case of error. michael@0: */ michael@0: [scriptable, function, uuid(F612E0FC-6736-4D24-AA50-FD661B3B40B6)] michael@0: interface nsINativeOSFileErrorCallback: nsISupports michael@0: { michael@0: /** michael@0: * @param operation The name of the failed operation. Provided to aid michael@0: * debugging only, may change without notice. michael@0: * @param OSstatus The OS status of the operation (errno under Unix, michael@0: * GetLastError under Windows). michael@0: */ michael@0: void complete(in ACString operation, in long OSstatus); michael@0: }; michael@0: michael@0: /** michael@0: * A service providing native implementations of some of the features michael@0: * of OS.File. michael@0: */ michael@0: [scriptable, builtinclass, uuid(913362AD-1526-4623-9E6B-A2EB08AFBBB9)] michael@0: interface nsINativeOSFileInternalsService: nsISupports michael@0: { michael@0: /** michael@0: * Implementation of OS.File.read michael@0: * michael@0: * @param path The absolute path to the file to read. michael@0: * @param options An object that may contain some of the following fields michael@0: * - {number} bytes The maximal number of bytes to read. michael@0: * - {string} encoding If provided, return the result as a string, decoded michael@0: * using this encoding. Otherwise, pass the result as an ArrayBuffer. michael@0: * Invalid encodings cause onError to be called with the platform-specific michael@0: * "invalid argument" constant. michael@0: * - {string} compression Unimplemented at the moment. michael@0: * @param onSuccess The success callback. michael@0: * @param onError The error callback. michael@0: */ michael@0: [implicit_jscontext] michael@0: void read(in AString path, in jsval options, michael@0: in nsINativeOSFileSuccessCallback onSuccess, michael@0: in nsINativeOSFileErrorCallback onError); michael@0: }; michael@0: michael@0: michael@0: %{ C++ michael@0: michael@0: #define NATIVE_OSFILE_INTERNALS_SERVICE_CID {0x63A69303,0x8A64,0x45A9,{0x84, 0x8C, 0xD4, 0xE2, 0x79, 0x27, 0x94, 0xE6}} michael@0: #define NATIVE_OSFILE_INTERNALS_SERVICE_CONTRACTID "@mozilla.org/toolkit/osfile/native-internals;1" michael@0: michael@0: %}