2023-01-02 23:47:15 +01:00
|
|
|
// Copyright (c) 2023 The Chromium Embedded Framework Authors. All rights
|
2017-11-09 20:00:47 +01:00
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
//
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// This file was generated by the CEF translator tool. If making changes by
|
|
|
|
// hand only do so within the body of existing method and function
|
|
|
|
// implementations. See the translator.README.txt file in the tools directory
|
|
|
|
// for more information.
|
|
|
|
//
|
2023-06-01 16:07:20 +02:00
|
|
|
// $hash=c8c7a86f0fb91ad4ddca453253038e540b63f313$
|
2017-11-09 20:00:47 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "libcef_dll/ctocpp/server_ctocpp.h"
|
|
|
|
#include "libcef_dll/cpptoc/server_handler_cpptoc.h"
|
|
|
|
#include "libcef_dll/ctocpp/task_runner_ctocpp.h"
|
2019-01-23 16:42:12 +01:00
|
|
|
#include "libcef_dll/shutdown_checker.h"
|
2017-11-09 20:00:47 +01:00
|
|
|
#include "libcef_dll/transfer_util.h"
|
|
|
|
|
|
|
|
// STATIC METHODS - Body may be edited by hand.
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
void CefServer::CreateServer(const CefString& address,
|
2023-06-01 16:07:20 +02:00
|
|
|
uint16_t port,
|
2017-11-09 20:00:47 +01:00
|
|
|
int backlog,
|
|
|
|
CefRefPtr<CefServerHandler> handler) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Verify param: address; type: string_byref_const
|
|
|
|
DCHECK(!address.empty());
|
2023-01-02 23:47:15 +01:00
|
|
|
if (address.empty()) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
// Verify param: handler; type: refptr_diff
|
|
|
|
DCHECK(handler.get());
|
2023-01-02 23:47:15 +01:00
|
|
|
if (!handler.get()) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// Execute
|
|
|
|
cef_server_create(address.GetStruct(), port, backlog,
|
|
|
|
CefServerHandlerCppToC::Wrap(handler));
|
|
|
|
}
|
|
|
|
|
|
|
|
// VIRTUAL METHODS - Body may be edited by hand.
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
CefRefPtr<CefTaskRunner> CefServerCToCpp::GetTaskRunner() {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, get_task_runner)) {
|
2020-01-15 14:53:19 +01:00
|
|
|
return nullptr;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Execute
|
|
|
|
cef_task_runner_t* _retval = _struct->get_task_runner(_struct);
|
|
|
|
|
|
|
|
// Return type: refptr_same
|
|
|
|
return CefTaskRunnerCToCpp::Wrap(_retval);
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall") void CefServerCToCpp::Shutdown() {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, shutdown)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Execute
|
|
|
|
_struct->shutdown(_struct);
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall") bool CefServerCToCpp::IsRunning() {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, is_running)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return false;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Execute
|
|
|
|
int _retval = _struct->is_running(_struct);
|
|
|
|
|
|
|
|
// Return type: bool
|
|
|
|
return _retval ? true : false;
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall") CefString CefServerCToCpp::GetAddress() {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, get_address)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return CefString();
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Execute
|
|
|
|
cef_string_userfree_t _retval = _struct->get_address(_struct);
|
|
|
|
|
|
|
|
// Return type: string
|
|
|
|
CefString _retvalStr;
|
|
|
|
_retvalStr.AttachToUserFree(_retval);
|
|
|
|
return _retvalStr;
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall") bool CefServerCToCpp::HasConnection() {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, has_connection)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return false;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Execute
|
|
|
|
int _retval = _struct->has_connection(_struct);
|
|
|
|
|
|
|
|
// Return type: bool
|
|
|
|
return _retval ? true : false;
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
bool CefServerCToCpp::IsValidConnection(int connection_id) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, is_valid_connection)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return false;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Execute
|
|
|
|
int _retval = _struct->is_valid_connection(_struct, connection_id);
|
|
|
|
|
|
|
|
// Return type: bool
|
|
|
|
return _retval ? true : false;
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
void CefServerCToCpp::SendHttp200Response(int connection_id,
|
|
|
|
const CefString& content_type,
|
|
|
|
const void* data,
|
|
|
|
size_t data_size) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, send_http200response)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Verify param: content_type; type: string_byref_const
|
|
|
|
DCHECK(!content_type.empty());
|
2023-01-02 23:47:15 +01:00
|
|
|
if (content_type.empty()) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
// Verify param: data; type: simple_byaddr
|
|
|
|
DCHECK(data);
|
2023-01-02 23:47:15 +01:00
|
|
|
if (!data) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// Execute
|
|
|
|
_struct->send_http200response(_struct, connection_id,
|
|
|
|
content_type.GetStruct(), data, data_size);
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
void CefServerCToCpp::SendHttp404Response(int connection_id) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, send_http404response)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Execute
|
|
|
|
_struct->send_http404response(_struct, connection_id);
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
void CefServerCToCpp::SendHttp500Response(int connection_id,
|
|
|
|
const CefString& error_message) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, send_http500response)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Verify param: error_message; type: string_byref_const
|
|
|
|
DCHECK(!error_message.empty());
|
2023-01-02 23:47:15 +01:00
|
|
|
if (error_message.empty()) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// Execute
|
|
|
|
_struct->send_http500response(_struct, connection_id,
|
|
|
|
error_message.GetStruct());
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
void CefServerCToCpp::SendHttpResponse(int connection_id,
|
|
|
|
int response_code,
|
|
|
|
const CefString& content_type,
|
2023-06-01 16:07:20 +02:00
|
|
|
int64_t content_length,
|
2017-11-09 20:00:47 +01:00
|
|
|
const HeaderMap& extra_headers) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, send_http_response)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Verify param: content_type; type: string_byref_const
|
|
|
|
DCHECK(!content_type.empty());
|
2023-01-02 23:47:15 +01:00
|
|
|
if (content_type.empty()) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
// Unverified params: extra_headers
|
|
|
|
|
|
|
|
// Translate param: extra_headers; type: string_map_multi_byref_const
|
|
|
|
cef_string_multimap_t extra_headersMultimap = cef_string_multimap_alloc();
|
|
|
|
DCHECK(extra_headersMultimap);
|
2023-01-02 23:47:15 +01:00
|
|
|
if (extra_headersMultimap) {
|
2017-11-09 20:00:47 +01:00
|
|
|
transfer_string_multimap_contents(extra_headers, extra_headersMultimap);
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// Execute
|
|
|
|
_struct->send_http_response(_struct, connection_id, response_code,
|
|
|
|
content_type.GetStruct(), content_length,
|
|
|
|
extra_headersMultimap);
|
|
|
|
|
|
|
|
// Restore param:extra_headers; type: string_map_multi_byref_const
|
2023-01-02 23:47:15 +01:00
|
|
|
if (extra_headersMultimap) {
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_string_multimap_free(extra_headersMultimap);
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
void CefServerCToCpp::SendRawData(int connection_id,
|
|
|
|
const void* data,
|
|
|
|
size_t data_size) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, send_raw_data)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Verify param: data; type: simple_byaddr
|
|
|
|
DCHECK(data);
|
2023-01-02 23:47:15 +01:00
|
|
|
if (!data) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// Execute
|
|
|
|
_struct->send_raw_data(_struct, connection_id, data, data_size);
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
void CefServerCToCpp::CloseConnection(int connection_id) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, close_connection)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Execute
|
|
|
|
_struct->close_connection(_struct, connection_id);
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
NO_SANITIZE("cfi-icall")
|
2017-11-09 20:00:47 +01:00
|
|
|
void CefServerCToCpp::SendWebSocketMessage(int connection_id,
|
|
|
|
const void* data,
|
|
|
|
size_t data_size) {
|
2019-01-23 16:42:12 +01:00
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
cef_server_t* _struct = GetStruct();
|
2023-01-02 23:47:15 +01:00
|
|
|
if (CEF_MEMBER_MISSING(_struct, send_web_socket_message)) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
|
|
|
|
// Verify param: data; type: simple_byaddr
|
|
|
|
DCHECK(data);
|
2023-01-02 23:47:15 +01:00
|
|
|
if (!data) {
|
2017-11-09 20:00:47 +01:00
|
|
|
return;
|
2023-01-02 23:47:15 +01:00
|
|
|
}
|
2017-11-09 20:00:47 +01:00
|
|
|
|
|
|
|
// Execute
|
|
|
|
_struct->send_web_socket_message(_struct, connection_id, data, data_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CONSTRUCTOR - Do not edit by hand.
|
|
|
|
|
|
|
|
CefServerCToCpp::CefServerCToCpp() {}
|
|
|
|
|
2019-01-23 16:42:12 +01:00
|
|
|
// DESTRUCTOR - Do not edit by hand.
|
|
|
|
|
|
|
|
CefServerCToCpp::~CefServerCToCpp() {
|
|
|
|
shutdown_checker::AssertNotShutdown();
|
|
|
|
}
|
|
|
|
|
2017-11-09 20:00:47 +01:00
|
|
|
template <>
|
|
|
|
cef_server_t*
|
|
|
|
CefCToCppRefCounted<CefServerCToCpp, CefServer, cef_server_t>::UnwrapDerived(
|
|
|
|
CefWrapperType type,
|
|
|
|
CefServer* c) {
|
2023-05-08 17:15:02 +02:00
|
|
|
DCHECK(false) << "Unexpected class type: " << type;
|
2020-01-15 14:53:19 +01:00
|
|
|
return nullptr;
|
2017-11-09 20:00:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
CefWrapperType CefCToCppRefCounted<CefServerCToCpp, CefServer, cef_server_t>::
|
|
|
|
kWrapperType = WT_SERVER;
|