]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/cef_stream.h
* Merged html producer and updated to latest CEF version (does not have satisfactory...
[casparcg] / dependencies64 / cef / include / cef_stream.h
1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36
37 #ifndef CEF_INCLUDE_CEF_STREAM_H_
38 #define CEF_INCLUDE_CEF_STREAM_H_
39
40 #include "include/cef_base.h"
41
42 ///
43 // Interface the client can implement to provide a custom stream reader. The
44 // methods of this class may be called on any thread.
45 ///
46 /*--cef(source=client)--*/
47 class CefReadHandler : public virtual CefBase {
48  public:
49   ///
50   // Read raw binary data.
51   ///
52   /*--cef()--*/
53   virtual size_t Read(void* ptr, size_t size, size_t n) =0;
54
55   ///
56   // Seek to the specified offset position. |whence| may be any one of
57   // SEEK_CUR, SEEK_END or SEEK_SET. Return zero on success and non-zero on
58   // failure.
59   ///
60   /*--cef()--*/
61   virtual int Seek(int64 offset, int whence) =0;
62
63   ///
64   // Return the current offset position.
65   ///
66   /*--cef()--*/
67   virtual int64 Tell() =0;
68
69   ///
70   // Return non-zero if at end of file.
71   ///
72   /*--cef()--*/
73   virtual int Eof() =0;
74
75   ///
76   // Return true if this handler performs work like accessing the file system
77   // which may block. Used as a hint for determining the thread to access the
78   // handler from.
79   ///
80   /*--cef()--*/
81   virtual bool MayBlock() =0;
82 };
83
84
85 ///
86 // Class used to read data from a stream. The methods of this class may be
87 // called on any thread.
88 ///
89 /*--cef(source=library)--*/
90 class CefStreamReader : public virtual CefBase {
91  public:
92   ///
93   // Create a new CefStreamReader object from a file.
94   ///
95   /*--cef()--*/
96   static CefRefPtr<CefStreamReader> CreateForFile(const CefString& fileName);
97   ///
98   // Create a new CefStreamReader object from data.
99   ///
100   /*--cef()--*/
101   static CefRefPtr<CefStreamReader> CreateForData(void* data, size_t size);
102   ///
103   // Create a new CefStreamReader object from a custom handler.
104   ///
105   /*--cef()--*/
106   static CefRefPtr<CefStreamReader> CreateForHandler(
107       CefRefPtr<CefReadHandler> handler);
108
109   ///
110   // Read raw binary data.
111   ///
112   /*--cef()--*/
113   virtual size_t Read(void* ptr, size_t size, size_t n) =0;
114
115   ///
116   // Seek to the specified offset position. |whence| may be any one of
117   // SEEK_CUR, SEEK_END or SEEK_SET. Returns zero on success and non-zero on
118   // failure.
119   ///
120   /*--cef()--*/
121   virtual int Seek(int64 offset, int whence) =0;
122
123   ///
124   // Return the current offset position.
125   ///
126   /*--cef()--*/
127   virtual int64 Tell() =0;
128
129   ///
130   // Return non-zero if at end of file.
131   ///
132   /*--cef()--*/
133   virtual int Eof() =0;
134
135   ///
136   // Returns true if this reader performs work like accessing the file system
137   // which may block. Used as a hint for determining the thread to access the
138   // reader from.
139   ///
140   /*--cef()--*/
141   virtual bool MayBlock() =0;
142 };
143
144
145 ///
146 // Interface the client can implement to provide a custom stream writer. The
147 // methods of this class may be called on any thread.
148 ///
149 /*--cef(source=client)--*/
150 class CefWriteHandler : public virtual CefBase {
151  public:
152   ///
153   // Write raw binary data.
154   ///
155   /*--cef()--*/
156   virtual size_t Write(const void* ptr, size_t size, size_t n) =0;
157
158   ///
159   // Seek to the specified offset position. |whence| may be any one of
160   // SEEK_CUR, SEEK_END or SEEK_SET. Return zero on success and non-zero on
161   // failure.
162   ///
163   /*--cef()--*/
164   virtual int Seek(int64 offset, int whence) =0;
165
166   ///
167   // Return the current offset position.
168   ///
169   /*--cef()--*/
170   virtual int64 Tell() =0;
171
172   ///
173   // Flush the stream.
174   ///
175   /*--cef()--*/
176   virtual int Flush() =0;
177
178   ///
179   // Return true if this handler performs work like accessing the file system
180   // which may block. Used as a hint for determining the thread to access the
181   // handler from.
182   ///
183   /*--cef()--*/
184   virtual bool MayBlock() =0;
185 };
186
187
188 ///
189 // Class used to write data to a stream. The methods of this class may be called
190 // on any thread.
191 ///
192 /*--cef(source=library)--*/
193 class CefStreamWriter : public virtual CefBase {
194  public:
195   ///
196   // Create a new CefStreamWriter object for a file.
197   ///
198   /*--cef()--*/
199   static CefRefPtr<CefStreamWriter> CreateForFile(const CefString& fileName);
200   ///
201   // Create a new CefStreamWriter object for a custom handler.
202   ///
203   /*--cef()--*/
204   static CefRefPtr<CefStreamWriter> CreateForHandler(
205       CefRefPtr<CefWriteHandler> handler);
206
207   ///
208   // Write raw binary data.
209   ///
210   /*--cef()--*/
211   virtual size_t Write(const void* ptr, size_t size, size_t n) =0;
212
213   ///
214   // Seek to the specified offset position. |whence| may be any one of
215   // SEEK_CUR, SEEK_END or SEEK_SET. Returns zero on success and non-zero on
216   // failure.
217   ///
218   /*--cef()--*/
219   virtual int Seek(int64 offset, int whence) =0;
220
221   ///
222   // Return the current offset position.
223   ///
224   /*--cef()--*/
225   virtual int64 Tell() =0;
226
227   ///
228   // Flush the stream.
229   ///
230   /*--cef()--*/
231   virtual int Flush() =0;
232
233   ///
234   // Returns true if this writer performs work like accessing the file system
235   // which may block. Used as a hint for determining the thread to access the
236   // writer from.
237   ///
238   /*--cef()--*/
239   virtual bool MayBlock() =0;
240 };
241
242 #endif  // CEF_INCLUDE_CEF_STREAM_H_