VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/io/nsStreamUtils.h@ 95259

Last change on this file since 95259 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is Mozilla.
15 *
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2002
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 * Darin Fisher <darin@netscape.com>
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef nsStreamUtils_h__
39#define nsStreamUtils_h__
40
41#include "nscore.h"
42
43class nsIInputStream;
44class nsIOutputStream;
45class nsIInputStreamCallback;
46class nsIOutputStreamCallback;
47class nsIEventTarget;
48
49/**
50 * A "one-shot" proxy of the OnInputStreamReady callback. The resulting
51 * proxy object's OnInputStreamReady function may only be called once! The
52 * proxy object ensures that the real notify object will be free'd on the
53 * thread corresponding to the given event target regardless of what thread
54 * the proxy object is destroyed on.
55 *
56 * This function is designed to be used to implement AsyncWait when the
57 * aEventTarget parameter is non-null.
58 */
59extern NS_COM nsresult
60NS_NewInputStreamReadyEvent(nsIInputStreamCallback **aEvent,
61 nsIInputStreamCallback *aNotify,
62 nsIEventTarget *aEventTarget);
63
64/**
65 * A "one-shot" proxy of the OnOutputStreamReady callback. The resulting
66 * proxy object's OnOutputStreamReady function may only be called once! The
67 * proxy object ensures that the real notify object will be free'd on the
68 * thread corresponding to the given event target regardless of what thread
69 * the proxy object is destroyed on.
70 *
71 * This function is designed to be used to implement AsyncWait when the
72 * aEventTarget parameter is non-null.
73 */
74extern NS_COM nsresult
75NS_NewOutputStreamReadyEvent(nsIOutputStreamCallback **aEvent,
76 nsIOutputStreamCallback *aNotify,
77 nsIEventTarget *aEventTarget);
78
79/* ------------------------------------------------------------------------- */
80
81enum nsAsyncCopyMode {
82 NS_ASYNCCOPY_VIA_READSEGMENTS,
83 NS_ASYNCCOPY_VIA_WRITESEGMENTS
84};
85
86/**
87 * This function is called when the async copy process completes. The reported
88 * status is NS_OK on success and some error code on failure.
89 */
90typedef void (* nsAsyncCopyCallbackFun)(void *closure, nsresult status);
91
92/**
93 * This function asynchronously copies data from the source to the sink. All
94 * data transfer occurs on the thread corresponding to the given event target.
95 * A null event target is not permitted.
96 *
97 * The copier handles blocking or non-blocking streams transparently. If a
98 * stream operation returns NS_BASE_STREAM_WOULD_BLOCK, then the stream will
99 * be QI'd to nsIAsync{In,Out}putStream and its AsyncWait method will be used
100 * to determine when to resume copying.
101 */
102extern NS_COM nsresult
103NS_AsyncCopy(nsIInputStream *aSource,
104 nsIOutputStream *aSink,
105 nsIEventTarget *aEventTarget,
106 nsAsyncCopyMode aMode = NS_ASYNCCOPY_VIA_READSEGMENTS,
107 PRUint32 aChunkSize = 4096,
108 nsAsyncCopyCallbackFun aCallbackFun = nsnull,
109 void *aCallbackClosure = nsnull);
110
111#endif // !nsStreamUtils_h__
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette