1 // Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 //
5 // ---------------------------------------------------------------------------
6 //
7 // This file was generated by the CEF translator tool. If making changes by
8 // hand only do so within the body of existing method and function
9 // implementations. See the translator.README.txt file in the tools directory
10 // for more information.
11 //
12 // $hash=72d9dc0e438de96161f262353c153c11b76f8ad0$
13 //
14
15 #include "libcef_dll/cpptoc/resource_handler_cpptoc.h"
16 #include "libcef_dll/ctocpp/callback_ctocpp.h"
17 #include "libcef_dll/ctocpp/request_ctocpp.h"
18 #include "libcef_dll/ctocpp/resource_read_callback_ctocpp.h"
19 #include "libcef_dll/ctocpp/resource_skip_callback_ctocpp.h"
20 #include "libcef_dll/ctocpp/response_ctocpp.h"
21 #include "libcef_dll/shutdown_checker.h"
22
23 namespace {
24
25 // MEMBER FUNCTIONS - Body may be edited by hand.
26
resource_handler_open(struct _cef_resource_handler_t * self,cef_request_t * request,int * handle_request,cef_callback_t * callback)27 int CEF_CALLBACK resource_handler_open(struct _cef_resource_handler_t* self,
28 cef_request_t* request,
29 int* handle_request,
30 cef_callback_t* callback) {
31 shutdown_checker::AssertNotShutdown();
32
33 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
34
35 DCHECK(self);
36 if (!self)
37 return 0;
38 // Verify param: request; type: refptr_diff
39 DCHECK(request);
40 if (!request)
41 return 0;
42 // Verify param: handle_request; type: bool_byref
43 DCHECK(handle_request);
44 if (!handle_request)
45 return 0;
46 // Verify param: callback; type: refptr_diff
47 DCHECK(callback);
48 if (!callback)
49 return 0;
50
51 // Translate param: handle_request; type: bool_byref
52 bool handle_requestBool = (handle_request && *handle_request) ? true : false;
53
54 // Execute
55 bool _retval = CefResourceHandlerCppToC::Get(self)->Open(
56 CefRequestCToCpp::Wrap(request), handle_requestBool,
57 CefCallbackCToCpp::Wrap(callback));
58
59 // Restore param: handle_request; type: bool_byref
60 if (handle_request)
61 *handle_request = handle_requestBool ? true : false;
62
63 // Return type: bool
64 return _retval;
65 }
66
67 int CEF_CALLBACK
resource_handler_process_request(struct _cef_resource_handler_t * self,cef_request_t * request,cef_callback_t * callback)68 resource_handler_process_request(struct _cef_resource_handler_t* self,
69 cef_request_t* request,
70 cef_callback_t* callback) {
71 shutdown_checker::AssertNotShutdown();
72
73 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
74
75 DCHECK(self);
76 if (!self)
77 return 0;
78 // Verify param: request; type: refptr_diff
79 DCHECK(request);
80 if (!request)
81 return 0;
82 // Verify param: callback; type: refptr_diff
83 DCHECK(callback);
84 if (!callback)
85 return 0;
86
87 // Execute
88 bool _retval = CefResourceHandlerCppToC::Get(self)->ProcessRequest(
89 CefRequestCToCpp::Wrap(request), CefCallbackCToCpp::Wrap(callback));
90
91 // Return type: bool
92 return _retval;
93 }
94
95 void CEF_CALLBACK
resource_handler_get_response_headers(struct _cef_resource_handler_t * self,struct _cef_response_t * response,int64 * response_length,cef_string_t * redirectUrl)96 resource_handler_get_response_headers(struct _cef_resource_handler_t* self,
97 struct _cef_response_t* response,
98 int64* response_length,
99 cef_string_t* redirectUrl) {
100 shutdown_checker::AssertNotShutdown();
101
102 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
103
104 DCHECK(self);
105 if (!self)
106 return;
107 // Verify param: response; type: refptr_diff
108 DCHECK(response);
109 if (!response)
110 return;
111 // Verify param: response_length; type: simple_byref
112 DCHECK(response_length);
113 if (!response_length)
114 return;
115 // Verify param: redirectUrl; type: string_byref
116 DCHECK(redirectUrl);
117 if (!redirectUrl)
118 return;
119
120 // Translate param: response_length; type: simple_byref
121 int64 response_lengthVal = response_length ? *response_length : 0;
122 // Translate param: redirectUrl; type: string_byref
123 CefString redirectUrlStr(redirectUrl);
124
125 // Execute
126 CefResourceHandlerCppToC::Get(self)->GetResponseHeaders(
127 CefResponseCToCpp::Wrap(response), response_lengthVal, redirectUrlStr);
128
129 // Restore param: response_length; type: simple_byref
130 if (response_length)
131 *response_length = response_lengthVal;
132 }
133
resource_handler_skip(struct _cef_resource_handler_t * self,int64 bytes_to_skip,int64 * bytes_skipped,cef_resource_skip_callback_t * callback)134 int CEF_CALLBACK resource_handler_skip(struct _cef_resource_handler_t* self,
135 int64 bytes_to_skip,
136 int64* bytes_skipped,
137 cef_resource_skip_callback_t* callback) {
138 shutdown_checker::AssertNotShutdown();
139
140 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
141
142 DCHECK(self);
143 if (!self)
144 return 0;
145 // Verify param: bytes_skipped; type: simple_byref
146 DCHECK(bytes_skipped);
147 if (!bytes_skipped)
148 return 0;
149 // Verify param: callback; type: refptr_diff
150 DCHECK(callback);
151 if (!callback)
152 return 0;
153
154 // Translate param: bytes_skipped; type: simple_byref
155 int64 bytes_skippedVal = bytes_skipped ? *bytes_skipped : 0;
156
157 // Execute
158 bool _retval = CefResourceHandlerCppToC::Get(self)->Skip(
159 bytes_to_skip, bytes_skippedVal,
160 CefResourceSkipCallbackCToCpp::Wrap(callback));
161
162 // Restore param: bytes_skipped; type: simple_byref
163 if (bytes_skipped)
164 *bytes_skipped = bytes_skippedVal;
165
166 // Return type: bool
167 return _retval;
168 }
169
resource_handler_read(struct _cef_resource_handler_t * self,void * data_out,int bytes_to_read,int * bytes_read,cef_resource_read_callback_t * callback)170 int CEF_CALLBACK resource_handler_read(struct _cef_resource_handler_t* self,
171 void* data_out,
172 int bytes_to_read,
173 int* bytes_read,
174 cef_resource_read_callback_t* callback) {
175 shutdown_checker::AssertNotShutdown();
176
177 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
178
179 DCHECK(self);
180 if (!self)
181 return 0;
182 // Verify param: data_out; type: simple_byaddr
183 DCHECK(data_out);
184 if (!data_out)
185 return 0;
186 // Verify param: bytes_read; type: simple_byref
187 DCHECK(bytes_read);
188 if (!bytes_read)
189 return 0;
190 // Verify param: callback; type: refptr_diff
191 DCHECK(callback);
192 if (!callback)
193 return 0;
194
195 // Translate param: bytes_read; type: simple_byref
196 int bytes_readVal = bytes_read ? *bytes_read : 0;
197
198 // Execute
199 bool _retval = CefResourceHandlerCppToC::Get(self)->Read(
200 data_out, bytes_to_read, bytes_readVal,
201 CefResourceReadCallbackCToCpp::Wrap(callback));
202
203 // Restore param: bytes_read; type: simple_byref
204 if (bytes_read)
205 *bytes_read = bytes_readVal;
206
207 // Return type: bool
208 return _retval;
209 }
210
211 int CEF_CALLBACK
resource_handler_read_response(struct _cef_resource_handler_t * self,void * data_out,int bytes_to_read,int * bytes_read,cef_callback_t * callback)212 resource_handler_read_response(struct _cef_resource_handler_t* self,
213 void* data_out,
214 int bytes_to_read,
215 int* bytes_read,
216 cef_callback_t* callback) {
217 shutdown_checker::AssertNotShutdown();
218
219 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
220
221 DCHECK(self);
222 if (!self)
223 return 0;
224 // Verify param: data_out; type: simple_byaddr
225 DCHECK(data_out);
226 if (!data_out)
227 return 0;
228 // Verify param: bytes_read; type: simple_byref
229 DCHECK(bytes_read);
230 if (!bytes_read)
231 return 0;
232 // Verify param: callback; type: refptr_diff
233 DCHECK(callback);
234 if (!callback)
235 return 0;
236
237 // Translate param: bytes_read; type: simple_byref
238 int bytes_readVal = bytes_read ? *bytes_read : 0;
239
240 // Execute
241 bool _retval = CefResourceHandlerCppToC::Get(self)->ReadResponse(
242 data_out, bytes_to_read, bytes_readVal,
243 CefCallbackCToCpp::Wrap(callback));
244
245 // Restore param: bytes_read; type: simple_byref
246 if (bytes_read)
247 *bytes_read = bytes_readVal;
248
249 // Return type: bool
250 return _retval;
251 }
252
253 void CEF_CALLBACK
resource_handler_cancel(struct _cef_resource_handler_t * self)254 resource_handler_cancel(struct _cef_resource_handler_t* self) {
255 shutdown_checker::AssertNotShutdown();
256
257 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
258
259 DCHECK(self);
260 if (!self)
261 return;
262
263 // Execute
264 CefResourceHandlerCppToC::Get(self)->Cancel();
265 }
266
267 } // namespace
268
269 // CONSTRUCTOR - Do not edit by hand.
270
CefResourceHandlerCppToC()271 CefResourceHandlerCppToC::CefResourceHandlerCppToC() {
272 GetStruct()->open = resource_handler_open;
273 GetStruct()->process_request = resource_handler_process_request;
274 GetStruct()->get_response_headers = resource_handler_get_response_headers;
275 GetStruct()->skip = resource_handler_skip;
276 GetStruct()->read = resource_handler_read;
277 GetStruct()->read_response = resource_handler_read_response;
278 GetStruct()->cancel = resource_handler_cancel;
279 }
280
281 // DESTRUCTOR - Do not edit by hand.
282
~CefResourceHandlerCppToC()283 CefResourceHandlerCppToC::~CefResourceHandlerCppToC() {
284 shutdown_checker::AssertNotShutdown();
285 }
286
287 template <>
288 CefRefPtr<CefResourceHandler> CefCppToCRefCounted<
289 CefResourceHandlerCppToC,
290 CefResourceHandler,
UnwrapDerived(CefWrapperType type,cef_resource_handler_t * s)291 cef_resource_handler_t>::UnwrapDerived(CefWrapperType type,
292 cef_resource_handler_t* s) {
293 NOTREACHED() << "Unexpected class type: " << type;
294 return nullptr;
295 }
296
297 template <>
298 CefWrapperType CefCppToCRefCounted<CefResourceHandlerCppToC,
299 CefResourceHandler,
300 cef_resource_handler_t>::kWrapperType =
301 WT_RESOURCE_HANDLER;
302