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