1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:07:45 +00:00

LibCore: Convert CHttpJob to ObjectPtr

This commit is contained in:
Andreas Kling 2019-09-21 12:03:22 +02:00
parent 953cb4e436
commit 6b347747f2
8 changed files with 45 additions and 13 deletions

View file

@ -21,10 +21,10 @@ void BoardListModel::update()
CHttpRequest request;
request.set_url("http://a.4cdn.org/boards.json");
auto* job = request.schedule();
m_pending_job = request.schedule();
job->on_finish = [job, this](bool success) {
auto* response = job->response();
m_pending_job->on_finish = [this](bool success) {
auto* response = m_pending_job->response();
dbg() << "Board list download finished, success=" << success << ", response=" << response;
if (!success)

View file

@ -1,6 +1,7 @@
#pragma once
#include <AK/JsonArray.h>
#include <LibCore/CHttpJob.h>
#include <LibGUI/GModel.h>
class BoardListModel final : public GModel {
@ -24,4 +25,5 @@ private:
BoardListModel();
JsonArray m_boards;
ObjectPtr<CHttpJob> m_pending_job;
};

View file

@ -29,13 +29,13 @@ void ThreadCatalogModel::update()
CHttpRequest request;
request.set_url(String::format("http://a.4cdn.org/%s/catalog.json", m_board.characters()));
auto* job = request.schedule();
m_pending_job = request.schedule();
if (on_load_started)
on_load_started();
job->on_finish = [job, this](bool success) {
auto* response = job->response();
m_pending_job->on_finish = [this](bool success) {
auto* response = m_pending_job->response();
dbg() << "Catalog download finished, success=" << success << ", response=" << response;
if (!success) {

View file

@ -1,6 +1,7 @@
#pragma once
#include <AK/JsonArray.h>
#include <LibCore/CHttpJob.h>
#include <LibGUI/GModel.h>
class ThreadCatalogModel final : public GModel {
@ -36,4 +37,5 @@ private:
String m_board { "g" };
JsonArray m_catalog;
ObjectPtr<CHttpJob> m_pending_job;
};