1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/osfile/nsINativeOSFileInternals.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,93 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=40: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "nsISupports.idl" 1.11 + 1.12 +/** 1.13 + * The result of a successful asynchronous operation. 1.14 + */ 1.15 +[scriptable, builtinclass, uuid(08B4CF29-3D65-4E79-B522-A694C322ED07)] 1.16 +interface nsINativeOSFileResult: nsISupports 1.17 +{ 1.18 + /** 1.19 + * The actual value produced by the operation. 1.20 + * 1.21 + * Actual type of this value depends on the options passed to the 1.22 + * operation. 1.23 + */ 1.24 + [implicit_jscontext] 1.25 + readonly attribute jsval result; 1.26 + 1.27 + /** 1.28 + * Delay between when the operation was requested on the main thread and 1.29 + * when the operation was started off main thread. 1.30 + */ 1.31 + readonly attribute double dispatchDurationMS; 1.32 + 1.33 + /** 1.34 + * Duration of the off main thread execution. 1.35 + */ 1.36 + readonly attribute double executionDurationMS; 1.37 +}; 1.38 + 1.39 +/** 1.40 + * A callback invoked in case of success. 1.41 + */ 1.42 +[scriptable, function, uuid(2C1922CA-CA1B-4099-8B61-EC23CFF49412)] 1.43 +interface nsINativeOSFileSuccessCallback: nsISupports 1.44 +{ 1.45 + void complete(in nsINativeOSFileResult result); 1.46 +}; 1.47 + 1.48 +/** 1.49 + * A callback invoked in case of error. 1.50 + */ 1.51 +[scriptable, function, uuid(F612E0FC-6736-4D24-AA50-FD661B3B40B6)] 1.52 +interface nsINativeOSFileErrorCallback: nsISupports 1.53 +{ 1.54 + /** 1.55 + * @param operation The name of the failed operation. Provided to aid 1.56 + * debugging only, may change without notice. 1.57 + * @param OSstatus The OS status of the operation (errno under Unix, 1.58 + * GetLastError under Windows). 1.59 + */ 1.60 + void complete(in ACString operation, in long OSstatus); 1.61 +}; 1.62 + 1.63 +/** 1.64 + * A service providing native implementations of some of the features 1.65 + * of OS.File. 1.66 + */ 1.67 +[scriptable, builtinclass, uuid(913362AD-1526-4623-9E6B-A2EB08AFBBB9)] 1.68 +interface nsINativeOSFileInternalsService: nsISupports 1.69 +{ 1.70 + /** 1.71 + * Implementation of OS.File.read 1.72 + * 1.73 + * @param path The absolute path to the file to read. 1.74 + * @param options An object that may contain some of the following fields 1.75 + * - {number} bytes The maximal number of bytes to read. 1.76 + * - {string} encoding If provided, return the result as a string, decoded 1.77 + * using this encoding. Otherwise, pass the result as an ArrayBuffer. 1.78 + * Invalid encodings cause onError to be called with the platform-specific 1.79 + * "invalid argument" constant. 1.80 + * - {string} compression Unimplemented at the moment. 1.81 + * @param onSuccess The success callback. 1.82 + * @param onError The error callback. 1.83 + */ 1.84 + [implicit_jscontext] 1.85 + void read(in AString path, in jsval options, 1.86 + in nsINativeOSFileSuccessCallback onSuccess, 1.87 + in nsINativeOSFileErrorCallback onError); 1.88 +}; 1.89 + 1.90 + 1.91 +%{ C++ 1.92 + 1.93 +#define NATIVE_OSFILE_INTERNALS_SERVICE_CID {0x63A69303,0x8A64,0x45A9,{0x84, 0x8C, 0xD4, 0xE2, 0x79, 0x27, 0x94, 0xE6}} 1.94 +#define NATIVE_OSFILE_INTERNALS_SERVICE_CONTRACTID "@mozilla.org/toolkit/osfile/native-internals;1" 1.95 + 1.96 +%}