Dillo web objects get owned.
Some checks failed
CI / ubuntu-latest-html-tests (push) Has been cancelled
CI / ubuntu-latest-no-tls (push) Has been cancelled
CI / ubuntu-latest-mbedtls2 (push) Has been cancelled
CI / ubuntu-latest-openssl-3 (push) Has been cancelled
CI / ubuntu-latest-with-old-std (push) Has been cancelled
CI / ubuntu-20-04-openssl-1-1 (push) Has been cancelled
CI / alpine-mbedtls-3_6_0 (push) Has been cancelled
CI / macOS-13-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-3 (push) Has been cancelled
CI / freebsd-14-openssl-3 (push) Has been cancelled
CI / windows-mbedtls (push) Has been cancelled
Some checks failed
CI / ubuntu-latest-html-tests (push) Has been cancelled
CI / ubuntu-latest-no-tls (push) Has been cancelled
CI / ubuntu-latest-mbedtls2 (push) Has been cancelled
CI / ubuntu-latest-openssl-3 (push) Has been cancelled
CI / ubuntu-latest-with-old-std (push) Has been cancelled
CI / ubuntu-20-04-openssl-1-1 (push) Has been cancelled
CI / alpine-mbedtls-3_6_0 (push) Has been cancelled
CI / macOS-13-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-3 (push) Has been cancelled
CI / freebsd-14-openssl-3 (push) Has been cancelled
CI / windows-mbedtls (push) Has been cancelled
This commit is contained in:
@ -180,7 +180,7 @@ static void Cache_client_dequeue(CacheClient_t *Client)
|
||||
{
|
||||
if (Client) {
|
||||
dList_remove(ClientQueue, Client);
|
||||
a_Web_free(reinterpret_cast< DilloWeb * >( Client->Web ));
|
||||
delete reinterpret_cast< DilloWeb * >( Client->Web );
|
||||
dFree(Client);
|
||||
}
|
||||
}
|
||||
@ -368,11 +368,11 @@ void a_Cache_entry_remove_by_url(DilloUrl *url)
|
||||
*
|
||||
* @return A primary key for identifying the client,
|
||||
*/
|
||||
int a_Cache_open_url(void *web, CA_Callback_t Call, void *CbData)
|
||||
int a_Cache_open_url(std::unique_ptr< DilloWeb > web, CA_Callback_t Call, void *CbData)
|
||||
{
|
||||
int ClientKey;
|
||||
CacheEntry_t *entry;
|
||||
DilloWeb *Web = reinterpret_cast< DilloWeb * >( web );
|
||||
DilloWeb *Web = web.release();
|
||||
DilloUrl *Url = Web->url.get();
|
||||
|
||||
if (URL_FLAGS(Url) & URL_E2EQuery) {
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "chain.hh"
|
||||
#include "url.hh"
|
||||
|
||||
struct DilloWeb;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -61,7 +63,7 @@ struct CacheClient {
|
||||
* Function prototypes
|
||||
*/
|
||||
void a_Cache_init(void);
|
||||
int a_Cache_open_url(void *Web, CA_Callback_t Call, void *CbData);
|
||||
int a_Cache_open_url(std::unique_ptr< DilloWeb > Web, CA_Callback_t Call, void *CbData);
|
||||
int a_Cache_get_buf(const DilloUrl *Url, char **PBuf, int *BufSize);
|
||||
void a_Cache_unref_buf(const DilloUrl *Url);
|
||||
const char *a_Cache_get_content_type(const DilloUrl *url);
|
||||
|
15
src/capi.cc
15
src/capi.cc
@ -391,7 +391,7 @@ static bool Capi_request_permitted(DilloWeb *web)
|
||||
* @return A primary key for identifying the client,
|
||||
* 0 if the client is aborted in the process.
|
||||
*/
|
||||
int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
|
||||
int a_Capi_open_url(std::unique_ptr< DilloWeb > web, CA_Callback_t Call, void *CbData)
|
||||
{
|
||||
int reload;
|
||||
char *cmd, *server;
|
||||
@ -399,7 +399,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
|
||||
const char *scheme = URL_SCHEME(web->url);
|
||||
int safe = 0, ret = 0, use_cache = 0;
|
||||
|
||||
if (Capi_request_permitted(web)) {
|
||||
if (Capi_request_permitted(web.get())) {
|
||||
/* reload test */
|
||||
reload = (!(a_Capi_get_flags(web->url.get()) & CAPI_IsCached) ||
|
||||
(URL_FLAGS(web->url.get()) & URL_E2EQuery));
|
||||
@ -418,7 +418,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
|
||||
}
|
||||
} else if (a_Cache_download_enabled(web->url.get())) {
|
||||
server = const_cast< char * >( "downloads" );
|
||||
cmd = Capi_dpi_build_cmd(web, server);
|
||||
cmd = Capi_dpi_build_cmd(web.get(), server);
|
||||
a_Capi_dpi_send_cmd(web->url.get(), web->bw, cmd, server, 1);
|
||||
dFree(cmd);
|
||||
} else {
|
||||
@ -443,7 +443,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
|
||||
a_Capi_conn_abort_by_url(web->url.get());
|
||||
/* Send dpip command */
|
||||
_MSG("a_Capi_open_url, reload url='%s'\n", URL_STR(web->url.get()));
|
||||
cmd = Capi_dpi_build_cmd(web, server);
|
||||
cmd = Capi_dpi_build_cmd(web.get(), server);
|
||||
a_Capi_dpi_send_cmd(web->url.get(), web->bw, cmd, server, 1);
|
||||
dFree(cmd);
|
||||
if (strcmp(server, "vsource") == 0) {
|
||||
@ -463,7 +463,6 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
|
||||
if (web->flags & WEB_RootUrl)
|
||||
a_UIcmd_set_msg(web->bw,
|
||||
"HTTPS was disabled at compilation time.");
|
||||
a_Web_free(web);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -474,7 +473,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
|
||||
/* start the reception branch before the query one because the DNS
|
||||
* may callback immediately. This may avoid a race condition. */
|
||||
a_Capi_ccc(OpStart, 2, BCK, a_Chain_new(), conn, const_cast< char * >( "http" ));
|
||||
a_Capi_ccc(OpStart, 1, BCK, a_Chain_new(), conn, web);
|
||||
a_Capi_ccc(OpStart, 1, BCK, a_Chain_new(), conn, web.get());
|
||||
}
|
||||
use_cache = 1;
|
||||
|
||||
@ -487,10 +486,8 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
|
||||
if (use_cache) {
|
||||
if (!conn || (conn && Capi_conn_valid(conn))) {
|
||||
/* not aborted, let's continue... */
|
||||
ret = a_Cache_open_url(web, Call, CbData);
|
||||
ret = a_Cache_open_url(std::move( web ), Call, CbData);
|
||||
}
|
||||
} else {
|
||||
a_Web_free(web);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ extern "C" {
|
||||
* Function prototypes
|
||||
*/
|
||||
void a_Capi_init(void);
|
||||
int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData);
|
||||
int a_Capi_open_url(std::unique_ptr< DilloWeb > web, CA_Callback_t Call, void *CbData);
|
||||
int a_Capi_get_buf(const DilloUrl *Url, char **PBuf, int *BufSize);
|
||||
void a_Capi_unref_buf(const DilloUrl *Url);
|
||||
const char *a_Capi_get_content_type(const DilloUrl *url);
|
||||
|
@ -2104,14 +2104,13 @@ std::shared_ptr< DilloImage > a_Html_image_new(DilloHtml *html, const char *tag,
|
||||
static bool Html_load_image(BrowserWindow *bw, DilloUrl *url,
|
||||
const DilloUrl *requester, std::shared_ptr< DilloImage > Image)
|
||||
{
|
||||
DilloWeb *Web;
|
||||
int ClientKey;
|
||||
/* Fill a Web structure for the cache query */
|
||||
Web = a_Web_new(bw, url, requester);
|
||||
auto Web = a_Web_new(bw, url, requester);
|
||||
Web->Image = Image;
|
||||
Web->flags |= WEB_Image;
|
||||
/* Request image data from the cache */
|
||||
if ((ClientKey = a_Capi_open_url(Web, NULL, NULL)) != 0) {
|
||||
if ((ClientKey = a_Capi_open_url(std::move( Web ), NULL, NULL)) != 0) {
|
||||
a_Bw_add_client(bw, ClientKey, 0);
|
||||
a_Bw_add_url(bw, a_Url_dup( url ));
|
||||
}
|
||||
@ -3178,9 +3177,9 @@ void a_Html_load_stylesheet(DilloHtml *html, DilloUrl *url)
|
||||
} else {
|
||||
/* Fill a Web structure for the cache query */
|
||||
int ClientKey;
|
||||
DilloWeb *Web = a_Web_new(html->bw, url, html->page_url.get());
|
||||
auto Web = a_Web_new(html->bw, url, html->page_url.get());
|
||||
Web->flags |= WEB_Stylesheet;
|
||||
if ((ClientKey = a_Capi_open_url(Web, Html_css_load_callback, NULL))) {
|
||||
if ((ClientKey = a_Capi_open_url(std::move( Web ), Html_css_load_callback, NULL))) {
|
||||
++html->bw->NumPendingStyleSheets;
|
||||
a_Bw_add_client(html->bw, ClientKey, 0);
|
||||
a_Bw_add_url(html->bw, a_Url_dup( url ));
|
||||
|
10
src/nav.cc
10
src/nav.cc
@ -186,7 +186,6 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url,
|
||||
const DilloUrl *old_url;
|
||||
bool MustLoad, ForceReload, IgnoreScroll;
|
||||
int x, y, idx, ClientKey;
|
||||
DilloWeb *Web;
|
||||
|
||||
MSG("Nav_open_url: new url='%s'\n", URL_STR_(url));
|
||||
|
||||
@ -221,9 +220,9 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url,
|
||||
|
||||
// a_Menu_pagemarks_new(bw);
|
||||
|
||||
Web = a_Web_new(bw, url, requester);
|
||||
auto Web = a_Web_new(bw, url, requester);
|
||||
Web->flags |= WEB_RootUrl;
|
||||
if ((ClientKey = a_Capi_open_url(Web, NULL, NULL)) != 0) {
|
||||
if ((ClientKey = a_Capi_open_url(std::move( Web ), NULL, NULL)) != 0) {
|
||||
a_Bw_add_client(bw, ClientKey, 1);
|
||||
a_Bw_add_url(bw, a_Url_dup( url ));
|
||||
}
|
||||
@ -548,11 +547,12 @@ static void Nav_save_cb(int Op, CacheClient_t *Client)
|
||||
void a_Nav_save_url(BrowserWindow *bw,
|
||||
const DilloUrl *url, const char *filename)
|
||||
{
|
||||
DilloWeb *Web = a_Web_new(bw, url, NULL);
|
||||
auto Web = a_Web_new(bw, url, NULL);
|
||||
Web->filename = filename;
|
||||
Web->flags |= WEB_Download;
|
||||
/* TODO: keep track of this client */
|
||||
a_Capi_open_url(Web, Nav_save_cb, Web);
|
||||
auto *const web_p= Web.get();
|
||||
a_Capi_open_url(std::move( Web ), Nav_save_cb, web_p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -760,12 +760,12 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
|
||||
|
||||
// we use the pageUrl as requester to prevent cross
|
||||
// domain requests as specified in domainrc
|
||||
DilloWeb *web = a_Web_new(bw, imgUrl.get(), pageUrl.get());
|
||||
auto web = a_Web_new(bw, imgUrl.get(), pageUrl.get());
|
||||
web->Image = std::move( image );
|
||||
web->flags |= WEB_Image;
|
||||
|
||||
int clientKey;
|
||||
if ((clientKey = a_Capi_open_url(web, NULL, NULL)) != 0) {
|
||||
if ((clientKey = a_Capi_open_url(std::move( web ), nullptr, nullptr)) != 0) {
|
||||
a_Bw_add_client(bw, clientKey, 0);
|
||||
a_Bw_add_url(bw, std::move( imgUrl ));
|
||||
attrs->backgroundImage->connectDeletion
|
||||
|
12
src/web.cc
12
src/web.cc
@ -119,10 +119,10 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
|
||||
/**
|
||||
* Allocate and set safe values for a DilloWeb structure
|
||||
*/
|
||||
DilloWeb* a_Web_new(BrowserWindow *bw, const DilloUrl *url,
|
||||
std::unique_ptr< DilloWeb > a_Web_new(BrowserWindow *bw, const DilloUrl *url,
|
||||
const DilloUrl *requester)
|
||||
{
|
||||
DilloWeb *web= new DilloWeb;
|
||||
auto web= std::make_unique< DilloWeb >();
|
||||
|
||||
_MSG(" a_Web_new: ValidWebs ==> %d\n", dList_length(ValidWebs));
|
||||
web->url = a_Url_dup(url);
|
||||
@ -134,7 +134,7 @@ DilloWeb* a_Web_new(BrowserWindow *bw, const DilloUrl *url,
|
||||
web->SavedBytes = 0;
|
||||
web->bgColor = 0x000000; /* Dummy value will be overwritten
|
||||
* in a_Web_dispatch_by_type. */
|
||||
dList_append(ValidWebs, (void *)web);
|
||||
dList_append(ValidWebs, (void *)web.get());
|
||||
return web;
|
||||
}
|
||||
|
||||
@ -149,11 +149,9 @@ int a_Web_valid(DilloWeb *web)
|
||||
/**
|
||||
* Deallocate a DilloWeb structure
|
||||
*/
|
||||
void a_Web_free(DilloWeb *web)
|
||||
DilloWeb::~DilloWeb()
|
||||
{
|
||||
if (!web) return;
|
||||
dList_remove(ValidWebs, (void *)web);
|
||||
dList_remove(ValidWebs, (void *)this);
|
||||
_MSG("a_Web_free: ValidWebs=%d\n", dList_length(ValidWebs));
|
||||
delete web;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ extern "C" {
|
||||
|
||||
|
||||
struct DilloWeb {
|
||||
~DilloWeb();
|
||||
std::unique_ptr< DilloUrl > url; /**< Requested URL */
|
||||
std::unique_ptr< DilloUrl > requester; /**< URL that caused this request, or
|
||||
**< NULL if user-initiated. */
|
||||
@ -35,10 +36,9 @@ struct DilloWeb {
|
||||
};
|
||||
|
||||
void a_Web_init(void);
|
||||
DilloWeb* a_Web_new (BrowserWindow *bw, const DilloUrl* url,
|
||||
const DilloUrl *requester);
|
||||
std::unique_ptr< DilloWeb > a_Web_new( BrowserWindow *bw, const DilloUrl* url,
|
||||
const DilloUrl *requester );
|
||||
int a_Web_valid(DilloWeb *web);
|
||||
void a_Web_free (DilloWeb*);
|
||||
int a_Web_dispatch_by_type (const char *Type, DilloWeb *web,
|
||||
CA_Callback_t *Call, void **Data);
|
||||
|
||||
|
Reference in New Issue
Block a user