Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: third_party/apple_cf/CFStreamAbstract.h

Issue 993413003: Remove NSInputStream used in HTTPTransportMac and use a CFReadStream instead. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/apple_cf/APPLE_LICENSE ('k') | third_party/apple_cf/README.crashpad » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* CFStreamAbstract.h
25 Copyright (c) 2000-2009, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFSTREAMABSTRACT__)
29 #define __COREFOUNDATION_CFSTREAMABSTRACT__ 1
30
31 #include <CoreFoundation/CFStream.h>
32
33 CF_EXTERN_C_BEGIN
34
35 /* During a stream's lifetime, the open callback will be called once, followed by any number of openCompleted calls (until openCompleted returns TRUE). Then a ny number of read/canRead or write/canWrite calls, then a single close call. co pyProperty can be called at any time. prepareAsynch will be called exactly once when the stream's client is first configured.
36
37 Expected semantics:
38 - open reserves any system resources that are needed. The stream may start the process of opening, returning TRUE immediately and setting openComplete to F ALSE. When the open completes, _CFStreamSignalEvent should be called passing kC FStreamOpenCompletedEvent. openComplete should be set to TRUE only if the open operation completed in its entirety.
39 - openCompleted will only be called after open has been called, but before a ny kCFStreamOpenCompletedEvent has been received. Return TRUE, setting error.co de to 0, if the open operation has completed. Return TRUE, setting error to the correct error code and domain if the open operation completed, but failed. Ret urn FALSE if the open operation is still in-progress. If your open ever fails t o complete (i.e. sets openComplete to FALSE), you must be implement the openComp leted callback.
40 - read should read into the given buffer, returning the number of bytes succ essfully read. read must block until at least one byte is available, but should not block until the entire buffer is filled; zero should only be returned if en d-of-stream is encountered. atEOF should be set to true if the EOF is encountere d, false otherwise. error.code should be set to zero if no error occurs; otherw ise, error should be set to the appropriate values.
41 - getBuffer is an optimization to return an internal buffer of bytes read fr om the stream, and may return NULL. getBuffer itself may be NULL if the concret e implementation does not wish to provide an internal buffer. If implemented, i t should set numBytesRead to the number of bytes available in the internal buffe r (but should not exceed maxBytesToRead) and return a pointer to the base of the bytes.
42 - canRead will only be called once openCompleted reports that the stream has been successfully opened (or the initial open call succeeded). It should retur n whether there are bytes that can be read without blocking.
43 - write should write the bytes in the given buffer to the device, returning the number of bytes successfully written. write must block until at least one b yte is written. error.code should be set to zero if no error occurs; otherwise, error should be set to the appropriate values.
44 - close should close the device, releasing any reserved system resources. c lose cannot fail (it may be called to abort the stream), and may be called at an y time after open has been called. It will only be called once.
45 - copyProperty should return the value for the given property, or NULL if no ne exists. Composite streams (streams built on top of other streams) should tak e care to call CFStreamCopyProperty on the base stream if they do not recognize the property given, to give the underlying stream a chance to respond.
46
47 In all cases, errors returned by reference will be initialized to NULL by th e caller, and if they are set to non-NULL, will
48 be released by the caller
49 */
50
51 typedef struct {
52 CFIndex version; /* == 2 */
53
54 void *(*create)(CFReadStreamRef stream, void *info);
55 void (*finalize)(CFReadStreamRef stream, void *info);
56 CFStringRef (*copyDescription)(CFReadStreamRef stream, void *info);
57
58 Boolean (*open)(CFReadStreamRef stream, CFErrorRef *error, Boolean *openComp lete, void *info);
59 Boolean (*openCompleted)(CFReadStreamRef stream, CFErrorRef *error, void *in fo);
60 CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, Boolean *atEOF, void *info);
61 const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CF Index *numBytesRead, CFErrorRef *error, Boolean *atEOF, void *info);
62 Boolean (*canRead)(CFReadStreamRef stream, CFErrorRef *error, void *info);
63 void (*close)(CFReadStreamRef stream, void *info);
64
65 CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info);
66 Boolean (*setProperty)(CFReadStreamRef stream, CFStringRef propertyName, CFT ypeRef propertyValue, void *info);
67
68 void (*requestEvents)(CFReadStreamRef stream, CFOptionFlags streamEvents, vo id *info);
69 void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef r unLoopMode, void *info);
70 void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
71 } CFReadStreamCallBacks;
72
73 typedef struct {
74 CFIndex version; /* == 2 */
75
76 void *(*create)(CFWriteStreamRef stream, void *info);
77 void (*finalize)(CFWriteStreamRef stream, void *info);
78 CFStringRef (*copyDescription)(CFWriteStreamRef stream, void *info);
79
80 Boolean (*open)(CFWriteStreamRef stream, CFErrorRef *error, Boolean *openCom plete, void *info);
81 Boolean (*openCompleted)(CFWriteStreamRef stream, CFErrorRef *error, void *i nfo);
82 CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex buffe rLength, CFErrorRef *error, void *info);
83 Boolean (*canWrite)(CFWriteStreamRef stream, CFErrorRef *error, void *info);
84 void (*close)(CFWriteStreamRef stream, void *info);
85
86 CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info);
87 Boolean (*setProperty)(CFWriteStreamRef stream, CFStringRef propertyName, CF TypeRef propertyValue, void *info);
88
89 void (*requestEvents)(CFWriteStreamRef stream, CFOptionFlags streamEvents, v oid *info);
90 void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
91 void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRe f runLoopMode, void *info);
92 } CFWriteStreamCallBacks;
93
94 // Primitive creation mechanisms.
95 CF_EXPORT
96 CFReadStreamRef CFReadStreamCreate(CFAllocatorRef alloc, const CFReadStreamCallB acks *callbacks, void *info);
97 CF_EXPORT
98 CFWriteStreamRef CFWriteStreamCreate(CFAllocatorRef alloc, const CFWriteStreamCa llBacks *callbacks, void *info);
99
100 /* All the functions below can only be called when you are sure the stream in qu estion was created via
101 CFReadStreamCreate() or CFWriteStreamCreate(), above. They are NOT safe for toll-free bridged objects,
102 so the caller must be sure the argument passed is not such an object. */
103
104 // To be called by the concrete stream implementation (the callbacks) when an ev ent occurs. error may be NULL if event != kCFStreamEventErrorOccurred
105 // error should be a CFErrorRef if the callbacks are version 2 or later; otherwi se it should be a (CFStreamError *).
106 CF_EXPORT
107 void CFReadStreamSignalEvent(CFReadStreamRef stream, CFStreamEventType event, co nst void *error);
108 CF_EXPORT
109 void CFWriteStreamSignalEvent(CFWriteStreamRef stream, CFStreamEventType event, const void *error);
110
111 // These require that the stream allow the run loop to run once before deliverin g the event to its client.
112 // See the comment above CFRead/WriteStreamSignalEvent for interpretation of the error argument.
113 CF_EXPORT
114 void _CFReadStreamSignalEventDelayed(CFReadStreamRef stream, CFStreamEventType e vent, const void *error);
115 CF_EXPORT
116 void _CFWriteStreamSignalEventDelayed(CFWriteStreamRef stream, CFStreamEventType event, const void *error);
117
118 CF_EXPORT
119 void _CFReadStreamClearEvent(CFReadStreamRef stream, CFStreamEventType event);
120 // Write variant not currently needed
121 //CF_EXPORT
122 //void _CFWriteStreamClearEvent(CFWriteStreamRef stream, CFStreamEventType event );
123
124 // Convenience for concrete implementations to extract the info pointer given th e stream.
125 CF_EXPORT
126 void *CFReadStreamGetInfoPointer(CFReadStreamRef stream);
127 CF_EXPORT
128 void *CFWriteStreamGetInfoPointer(CFWriteStreamRef stream);
129
130 // Returns the client info pointer currently set on the stream. These should pr obably be made public one day.
131 CF_EXPORT
132 void *_CFReadStreamGetClient(CFReadStreamRef readStream);
133 CF_EXPORT
134 void *_CFWriteStreamGetClient(CFWriteStreamRef writeStream);
135
136 // Returns an array of the runloops and modes on which the stream is currently s cheduled
137 CF_EXPORT
138 CFArrayRef _CFReadStreamGetRunLoopsAndModes(CFReadStreamRef readStream);
139 CF_EXPORT
140 CFArrayRef _CFWriteStreamGetRunLoopsAndModes(CFWriteStreamRef writeStream);
141
142 /* Deprecated versions; here for backwards compatibility. */
143 typedef struct {
144 CFIndex version; /* == 1 */
145 void *(*create)(CFReadStreamRef stream, void *info);
146 void (*finalize)(CFReadStreamRef stream, void *info);
147 CFStringRef (*copyDescription)(CFReadStreamRef stream, void *info);
148 Boolean (*open)(CFReadStreamRef stream, CFStreamError *error, Boolean *openC omplete, void *info);
149 Boolean (*openCompleted)(CFReadStreamRef stream, CFStreamError *error, void *info);
150 CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info);
151 const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CF Index *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info);
152 Boolean (*canRead)(CFReadStreamRef stream, void *info);
153 void (*close)(CFReadStreamRef stream, void *info);
154 CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info);
155 Boolean (*setProperty)(CFReadStreamRef stream, CFStringRef propertyName, CFT ypeRef propertyValue, void *info);
156 void (*requestEvents)(CFReadStreamRef stream, CFOptionFlags streamEvents, vo id *info);
157 void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef r unLoopMode, void *info);
158 void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
159 } CFReadStreamCallBacksV1;
160
161 typedef struct {
162 CFIndex version; /* == 1 */
163 void *(*create)(CFWriteStreamRef stream, void *info);
164 void (*finalize)(CFWriteStreamRef stream, void *info);
165 CFStringRef (*copyDescription)(CFWriteStreamRef stream, void *info);
166 Boolean (*open)(CFWriteStreamRef stream, CFStreamError *error, Boolean *open Complete, void *info);
167 Boolean (*openCompleted)(CFWriteStreamRef stream, CFStreamError *error, void *info);
168 CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex buffe rLength, CFStreamError *error, void *info);
169 Boolean (*canWrite)(CFWriteStreamRef stream, void *info);
170 void (*close)(CFWriteStreamRef stream, void *info);
171 CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info);
172 Boolean (*setProperty)(CFWriteStreamRef stream, CFStringRef propertyName, CF TypeRef propertyValue, void *info);
173 void (*requestEvents)(CFWriteStreamRef stream, CFOptionFlags streamEvents, v oid *info);
174 void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
175 void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRe f runLoopMode, void *info);
176 } CFWriteStreamCallBacksV1;
177
178 typedef struct {
179 CFIndex version; /* == 0 */
180 Boolean (*open)(CFReadStreamRef stream, CFStreamError *error, Boolean *openC omplete, void *info);
181 Boolean (*openCompleted)(CFReadStreamRef stream, CFStreamError *error, void *info);
182 CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info);
183 const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CF Index *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info);
184 Boolean (*canRead)(CFReadStreamRef stream, void *info);
185 void (*close)(CFReadStreamRef stream, void *info);
186 CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info);
187 void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef r unLoopMode, void *info);
188 void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
189 } CFReadStreamCallBacksV0;
190
191 typedef struct {
192 CFIndex version; /* == 0 */
193 Boolean (*open)(CFWriteStreamRef stream, CFStreamError *error, Boolean *open Complete, void *info);
194 Boolean (*openCompleted)(CFWriteStreamRef stream, CFStreamError *error, void *info);
195 CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex buffe rLength, CFStreamError *error, void *info);
196 Boolean (*canWrite)(CFWriteStreamRef stream, void *info);
197 void (*close)(CFWriteStreamRef stream, void *info);
198 CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info);
199 void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
200 void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRe f runLoopMode, void *info);
201 } CFWriteStreamCallBacksV0;
202
203 CF_EXTERN_C_END
204
205 #endif /* ! __COREFOUNDATION_CFSTREAMABSTRACT__ */
OLDNEW
« no previous file with comments | « third_party/apple_cf/APPLE_LICENSE ('k') | third_party/apple_cf/README.crashpad » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698