1 // Copyright (c) 2022 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 // This file was generated by the CEF translator tool and should not edited 33 // by hand. See the translator.README.txt file in the tools directory for 34 // more information. 35 // 36 // $hash=67df3d56f0cc0f58d2b0a2fe884bbb2c1c39813f$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_base_capi.h" 44 #include "include/capi/cef_browser_capi.h" 45 #include "include/capi/cef_callback_capi.h" 46 #include "include/capi/cef_cookie_capi.h" 47 #include "include/capi/cef_request_capi.h" 48 #include "include/capi/cef_response_capi.h" 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 /// 55 // Callback for asynchronous continuation of cef_resource_handler_t::skip(). 56 /// 57 typedef struct _cef_resource_skip_callback_t { 58 /// 59 // Base structure. 60 /// 61 cef_base_ref_counted_t base; 62 63 /// 64 // Callback for asynchronous continuation of skip(). If |bytes_skipped| > 0 65 // then either skip() will be called again until the requested number of bytes 66 // have been skipped or the request will proceed. If |bytes_skipped| <= 0 the 67 // request will fail with ERR_REQUEST_RANGE_NOT_SATISFIABLE. 68 /// 69 void(CEF_CALLBACK* cont)(struct _cef_resource_skip_callback_t* self, 70 int64 bytes_skipped); 71 } cef_resource_skip_callback_t; 72 73 /// 74 // Callback for asynchronous continuation of cef_resource_handler_t::read(). 75 /// 76 typedef struct _cef_resource_read_callback_t { 77 /// 78 // Base structure. 79 /// 80 cef_base_ref_counted_t base; 81 82 /// 83 // Callback for asynchronous continuation of read(). If |bytes_read| == 0 the 84 // response will be considered complete. If |bytes_read| > 0 then read() will 85 // be called again until the request is complete (based on either the result 86 // or the expected content length). If |bytes_read| < 0 then the request will 87 // fail and the |bytes_read| value will be treated as the error code. 88 /// 89 void(CEF_CALLBACK* cont)(struct _cef_resource_read_callback_t* self, 90 int bytes_read); 91 } cef_resource_read_callback_t; 92 93 /// 94 // Structure used to implement a custom request handler structure. The functions 95 // of this structure will be called on the IO thread unless otherwise indicated. 96 /// 97 typedef struct _cef_resource_handler_t { 98 /// 99 // Base structure. 100 /// 101 cef_base_ref_counted_t base; 102 103 /// 104 // Open the response stream. To handle the request immediately set 105 // |handle_request| to true (1) and return true (1). To decide at a later time 106 // set |handle_request| to false (0), return true (1), and execute |callback| 107 // to continue or cancel the request. To cancel the request immediately set 108 // |handle_request| to true (1) and return false (0). This function will be 109 // called in sequence but not from a dedicated thread. For backwards 110 // compatibility set |handle_request| to false (0) and return false (0) and 111 // the ProcessRequest function will be called. 112 /// 113 int(CEF_CALLBACK* open)(struct _cef_resource_handler_t* self, 114 struct _cef_request_t* request, 115 int* handle_request, 116 struct _cef_callback_t* callback); 117 118 /// 119 // Begin processing the request. To handle the request return true (1) and 120 // call cef_callback_t::cont() once the response header information is 121 // available (cef_callback_t::cont() can also be called from inside this 122 // function if header information is available immediately). To cancel the 123 // request return false (0). 124 // 125 // WARNING: This function is deprecated. Use Open instead. 126 /// 127 int(CEF_CALLBACK* process_request)(struct _cef_resource_handler_t* self, 128 struct _cef_request_t* request, 129 struct _cef_callback_t* callback); 130 131 /// 132 // Retrieve response header information. If the response length is not known 133 // set |response_length| to -1 and read_response() will be called until it 134 // returns false (0). If the response length is known set |response_length| to 135 // a positive value and read_response() will be called until it returns false 136 // (0) or the specified number of bytes have been read. Use the |response| 137 // object to set the mime type, http status code and other optional header 138 // values. To redirect the request to a new URL set |redirectUrl| to the new 139 // URL. |redirectUrl| can be either a relative or fully qualified URL. It is 140 // also possible to set |response| to a redirect http status code and pass the 141 // new URL via a Location header. Likewise with |redirectUrl| it is valid to 142 // set a relative or fully qualified URL as the Location header value. If an 143 // error occured while setting up the request you can call set_error() on 144 // |response| to indicate the error condition. 145 /// 146 void(CEF_CALLBACK* get_response_headers)(struct _cef_resource_handler_t* self, 147 struct _cef_response_t* response, 148 int64* response_length, 149 cef_string_t* redirectUrl); 150 151 /// 152 // Skip response data when requested by a Range header. Skip over and discard 153 // |bytes_to_skip| bytes of response data. If data is available immediately 154 // set |bytes_skipped| to the number of bytes skipped and return true (1). To 155 // read the data at a later time set |bytes_skipped| to 0, return true (1) and 156 // execute |callback| when the data is available. To indicate failure set 157 // |bytes_skipped| to < 0 (e.g. -2 for ERR_FAILED) and return false (0). This 158 // function will be called in sequence but not from a dedicated thread. 159 /// 160 int(CEF_CALLBACK* skip)(struct _cef_resource_handler_t* self, 161 int64 bytes_to_skip, 162 int64* bytes_skipped, 163 struct _cef_resource_skip_callback_t* callback); 164 165 /// 166 // Read response data. If data is available immediately copy up to 167 // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of 168 // bytes copied, and return true (1). To read the data at a later time keep a 169 // pointer to |data_out|, set |bytes_read| to 0, return true (1) and execute 170 // |callback| when the data is available (|data_out| will remain valid until 171 // the callback is executed). To indicate response completion set |bytes_read| 172 // to 0 and return false (0). To indicate failure set |bytes_read| to < 0 173 // (e.g. -2 for ERR_FAILED) and return false (0). This function will be called 174 // in sequence but not from a dedicated thread. For backwards compatibility 175 // set |bytes_read| to -1 and return false (0) and the ReadResponse function 176 // will be called. 177 /// 178 int(CEF_CALLBACK* read)(struct _cef_resource_handler_t* self, 179 void* data_out, 180 int bytes_to_read, 181 int* bytes_read, 182 struct _cef_resource_read_callback_t* callback); 183 184 /// 185 // Read response data. If data is available immediately copy up to 186 // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of 187 // bytes copied, and return true (1). To read the data at a later time set 188 // |bytes_read| to 0, return true (1) and call cef_callback_t::cont() when the 189 // data is available. To indicate response completion return false (0). 190 // 191 // WARNING: This function is deprecated. Use Skip and Read instead. 192 /// 193 int(CEF_CALLBACK* read_response)(struct _cef_resource_handler_t* self, 194 void* data_out, 195 int bytes_to_read, 196 int* bytes_read, 197 struct _cef_callback_t* callback); 198 199 /// 200 // Request processing has been canceled. 201 /// 202 void(CEF_CALLBACK* cancel)(struct _cef_resource_handler_t* self); 203 } cef_resource_handler_t; 204 205 #ifdef __cplusplus 206 } 207 #endif 208 209 #endif // CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_ 210