toolkit/components/osfile/nsINativeOSFileInternals.idl

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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

mercurial