mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:58:12 +00:00
Userland: Migrate to argument-less deferred_invoke
Only one place used this argument and it was to hold on to a strong ref for the object. Since we already do that now, there's no need to keep this argument around since this can be easily captured. This commit contains no changes.
This commit is contained in:
parent
e9121f8b1f
commit
8ea22121ac
32 changed files with 72 additions and 75 deletions
|
@ -434,7 +434,7 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
|
||||||
};
|
};
|
||||||
|
|
||||||
new_tab.on_tab_close_request = [this](auto& tab) {
|
new_tab.on_tab_close_request = [this](auto& tab) {
|
||||||
m_tab_widget->deferred_invoke([this, &tab](auto&) {
|
m_tab_widget->deferred_invoke([this, &tab] {
|
||||||
m_tab_widget->remove_tab(tab);
|
m_tab_widget->remove_tab(tab);
|
||||||
m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1);
|
m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1);
|
||||||
if (m_tab_widget->children().is_empty())
|
if (m_tab_widget->children().is_empty())
|
||||||
|
@ -443,7 +443,7 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
|
||||||
};
|
};
|
||||||
|
|
||||||
new_tab.on_tab_close_other_request = [this](auto& tab) {
|
new_tab.on_tab_close_other_request = [this](auto& tab) {
|
||||||
m_tab_widget->deferred_invoke([this, &tab](auto&) {
|
m_tab_widget->deferred_invoke([this, &tab] {
|
||||||
m_tab_widget->remove_all_tabs_except(tab);
|
m_tab_widget->remove_all_tabs_except(tab);
|
||||||
VERIFY(m_tab_widget->children().size() == 1);
|
VERIFY(m_tab_widget->children().size() == 1);
|
||||||
m_tab_widget->set_bar_visible(false);
|
m_tab_widget->set_bar_visible(false);
|
||||||
|
|
|
@ -500,7 +500,7 @@ void FontEditorWidget::initialize(const String& path, RefPtr<Gfx::BitmapFont>&&
|
||||||
m_fixed_width_checkbox->set_checked(m_edited_font->is_fixed_width());
|
m_fixed_width_checkbox->set_checked(m_edited_font->is_fixed_width());
|
||||||
|
|
||||||
m_glyph_map_widget->set_selected_glyph('A');
|
m_glyph_map_widget->set_selected_glyph('A');
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
m_glyph_map_widget->set_focus(true);
|
m_glyph_map_widget->set_focus(true);
|
||||||
m_glyph_map_widget->scroll_to_glyph(m_glyph_map_widget->selected_glyph());
|
m_glyph_map_widget->scroll_to_glyph(m_glyph_map_widget->selected_glyph());
|
||||||
window()->set_modified(false);
|
window()->set_modified(false);
|
||||||
|
|
|
@ -196,7 +196,7 @@ NewFontDialog::NewFontDialog(GUI::Window* parent_window)
|
||||||
|
|
||||||
m_glyph_width_spinbox->on_change = [&](int value) {
|
m_glyph_width_spinbox->on_change = [&](int value) {
|
||||||
preview_editor.set_preview_size(value, m_glyph_height_spinbox->value());
|
preview_editor.set_preview_size(value, m_glyph_height_spinbox->value());
|
||||||
deferred_invoke([&](auto&) {
|
deferred_invoke([&] {
|
||||||
m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2);
|
m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -204,7 +204,7 @@ NewFontDialog::NewFontDialog(GUI::Window* parent_window)
|
||||||
preview_editor.set_preview_size(m_glyph_width_spinbox->value(), value);
|
preview_editor.set_preview_size(m_glyph_width_spinbox->value(), value);
|
||||||
m_mean_line_spinbox->set_max(max(value - 2, 0));
|
m_mean_line_spinbox->set_max(max(value - 2, 0));
|
||||||
m_baseline_spinbox->set_max(max(value - 2, 0));
|
m_baseline_spinbox->set_max(max(value - 2, 0));
|
||||||
deferred_invoke([&](auto&) {
|
deferred_invoke([&] {
|
||||||
m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2);
|
m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -154,7 +154,7 @@ int main(int argc, char* argv[])
|
||||||
auto url = URL::create_with_file_protocol(path);
|
auto url = URL::create_with_file_protocol(path);
|
||||||
page_view.load_html(html, url);
|
page_view.load_html(html, url);
|
||||||
|
|
||||||
app->deferred_invoke([&, path](auto&) {
|
app->deferred_invoke([&, path] {
|
||||||
auto tree_view_index = model->index_from_path(path);
|
auto tree_view_index = model->index_from_path(path);
|
||||||
if (tree_view_index.has_value()) {
|
if (tree_view_index.has_value()) {
|
||||||
tree_view.expand_tree(tree_view_index.value().parent());
|
tree_view.expand_tree(tree_view_index.value().parent());
|
||||||
|
|
|
@ -726,7 +726,7 @@ int main(int argc, char** argv)
|
||||||
layer_properties_widget.set_layer(nullptr);
|
layer_properties_widget.set_layer(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
tab_widget.deferred_invoke([&](auto&) {
|
tab_widget.deferred_invoke([&] {
|
||||||
tab_widget.remove_tab(image_editor);
|
tab_widget.remove_tab(image_editor);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -111,7 +111,7 @@ ComboBox::ComboBox()
|
||||||
};
|
};
|
||||||
|
|
||||||
m_list_view->on_activation = [this](auto& index) {
|
m_list_view->on_activation = [this](auto& index) {
|
||||||
deferred_invoke([this, index](auto&) {
|
deferred_invoke([this, index] {
|
||||||
selection_updated(index);
|
selection_updated(index);
|
||||||
if (on_change)
|
if (on_change)
|
||||||
on_change(m_editor->text(), index);
|
on_change(m_editor->text(), index);
|
||||||
|
|
|
@ -105,7 +105,7 @@ void TabWidget::set_active_widget(Widget* widget)
|
||||||
if (active_widget_had_focus)
|
if (active_widget_had_focus)
|
||||||
m_active_widget->set_focus(true);
|
m_active_widget->set_focus(true);
|
||||||
m_active_widget->set_visible(true);
|
m_active_widget->set_visible(true);
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
if (on_change)
|
if (on_change)
|
||||||
on_change(*m_active_widget);
|
on_change(*m_active_widget);
|
||||||
});
|
});
|
||||||
|
@ -396,7 +396,7 @@ void TabWidget::mousedown_event(MouseEvent& event)
|
||||||
set_active_widget(m_tabs[i].widget);
|
set_active_widget(m_tabs[i].widget);
|
||||||
} else if (event.button() == MouseButton::Middle) {
|
} else if (event.button() == MouseButton::Middle) {
|
||||||
auto* widget = m_tabs[i].widget;
|
auto* widget = m_tabs[i].widget;
|
||||||
deferred_invoke([this, widget](auto&) {
|
deferred_invoke([this, widget] {
|
||||||
if (on_middle_click && widget)
|
if (on_middle_click && widget)
|
||||||
on_middle_click(*widget);
|
on_middle_click(*widget);
|
||||||
});
|
});
|
||||||
|
@ -417,7 +417,7 @@ void TabWidget::mouseup_event(MouseEvent& event)
|
||||||
|
|
||||||
if (close_button_rect.contains(event.position())) {
|
if (close_button_rect.contains(event.position())) {
|
||||||
auto* widget = m_tabs[m_pressed_close_button_index.value()].widget;
|
auto* widget = m_tabs[m_pressed_close_button_index.value()].widget;
|
||||||
deferred_invoke([this, widget](auto&) {
|
deferred_invoke([this, widget] {
|
||||||
if (on_tab_close_click && widget)
|
if (on_tab_close_click && widget)
|
||||||
on_tab_close_click(*widget);
|
on_tab_close_click(*widget);
|
||||||
});
|
});
|
||||||
|
@ -573,7 +573,7 @@ void TabWidget::context_menu_event(ContextMenuEvent& context_menu_event)
|
||||||
if (!button_rect.contains(context_menu_event.position()))
|
if (!button_rect.contains(context_menu_event.position()))
|
||||||
continue;
|
continue;
|
||||||
auto* widget = m_tabs[i].widget;
|
auto* widget = m_tabs[i].widget;
|
||||||
deferred_invoke([this, widget, context_menu_event](auto&) {
|
deferred_invoke([this, widget, context_menu_event] {
|
||||||
if (on_context_menu_request && widget)
|
if (on_context_menu_request && widget)
|
||||||
on_context_menu_request(*widget, context_menu_event);
|
on_context_menu_request(*widget, context_menu_event);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1469,7 +1469,7 @@ void TextEditor::did_change()
|
||||||
m_needs_rehighlight = true;
|
m_needs_rehighlight = true;
|
||||||
if (!m_has_pending_change_notification) {
|
if (!m_has_pending_change_notification) {
|
||||||
m_has_pending_change_notification = true;
|
m_has_pending_change_notification = true;
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
m_has_pending_change_notification = false;
|
m_has_pending_change_notification = false;
|
||||||
if (on_change)
|
if (on_change)
|
||||||
on_change();
|
on_change();
|
||||||
|
|
|
@ -694,7 +694,7 @@ void Window::update(const Gfx::IntRect& a_rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pending_paint_event_rects.is_empty()) {
|
if (m_pending_paint_event_rects.is_empty()) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
auto rects = move(m_pending_paint_event_rects);
|
auto rects = move(m_pending_paint_event_rects);
|
||||||
if (rects.is_empty())
|
if (rects.is_empty())
|
||||||
return;
|
return;
|
||||||
|
@ -1029,7 +1029,7 @@ void Window::schedule_relayout()
|
||||||
if (m_layout_pending)
|
if (m_layout_pending)
|
||||||
return;
|
return;
|
||||||
m_layout_pending = true;
|
m_layout_pending = true;
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
if (main_widget())
|
if (main_widget())
|
||||||
main_widget()->do_layout();
|
main_widget()->do_layout();
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -364,7 +364,7 @@ void WindowServerConnection::display_link_notification()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_display_link_notification_pending = true;
|
m_display_link_notification_pending = true;
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
DisplayLink::notify({});
|
DisplayLink::notify({});
|
||||||
m_display_link_notification_pending = false;
|
m_display_link_notification_pending = false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,15 +25,15 @@ void GeminiJob::start()
|
||||||
};
|
};
|
||||||
m_socket->on_tls_error = [this](TLS::AlertDescription error) {
|
m_socket->on_tls_error = [this](TLS::AlertDescription error) {
|
||||||
if (error == TLS::AlertDescription::HandshakeFailure) {
|
if (error == TLS::AlertDescription::HandshakeFailure) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::ProtocolFailed);
|
return did_fail(Core::NetworkJob::Error::ProtocolFailed);
|
||||||
});
|
});
|
||||||
} else if (error == TLS::AlertDescription::DecryptError) {
|
} else if (error == TLS::AlertDescription::DecryptError) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::TransmissionFailed);
|
return did_fail(Core::NetworkJob::Error::TransmissionFailed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ void GeminiJob::start()
|
||||||
};
|
};
|
||||||
bool success = ((TLS::TLSv12&)*m_socket).connect(m_request.url().host(), m_request.url().port());
|
bool success = ((TLS::TLSv12&)*m_socket).connect(m_request.url().host(), m_request.url().port());
|
||||||
if (!success) {
|
if (!success) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ void Job::on_socket_connected()
|
||||||
}
|
}
|
||||||
bool success = write(raw_request);
|
bool success = write(raw_request);
|
||||||
if (!success)
|
if (!success)
|
||||||
deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
deferred_invoke([this] { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
||||||
});
|
});
|
||||||
register_on_ready_to_read([this] {
|
register_on_ready_to_read([this] {
|
||||||
if (is_cancelled())
|
if (is_cancelled())
|
||||||
|
@ -66,19 +66,19 @@ void Job::on_socket_connected()
|
||||||
auto line = read_line(PAGE_SIZE);
|
auto line = read_line(PAGE_SIZE);
|
||||||
if (line.is_null()) {
|
if (line.is_null()) {
|
||||||
warnln("Job: Expected status line");
|
warnln("Job: Expected status line");
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
||||||
}
|
}
|
||||||
|
|
||||||
auto parts = line.split_limit(' ', 2);
|
auto parts = line.split_limit(' ', 2);
|
||||||
if (parts.size() != 2) {
|
if (parts.size() != 2) {
|
||||||
warnln("Job: Expected 2-part status line, got '{}'", line);
|
warnln("Job: Expected 2-part status line, got '{}'", line);
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
}
|
}
|
||||||
|
|
||||||
auto status = parts[0].to_uint();
|
auto status = parts[0].to_uint();
|
||||||
if (!status.has_value()) {
|
if (!status.has_value()) {
|
||||||
warnln("Job: Expected numeric status code");
|
warnln("Job: Expected numeric status code");
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
}
|
}
|
||||||
|
|
||||||
m_status = status.value();
|
m_status = status.value();
|
||||||
|
@ -98,7 +98,7 @@ void Job::on_socket_connected()
|
||||||
m_state = State::InBody;
|
m_state = State::InBody;
|
||||||
} else {
|
} else {
|
||||||
warnln("Job: Expected status between 10 and 69; instead got {}", m_status);
|
warnln("Job: Expected status between 10 and 69; instead got {}", m_status);
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -117,7 +117,7 @@ void Job::on_socket_connected()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_fail_on_empty_payload()) {
|
if (should_fail_on_empty_payload()) {
|
||||||
deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ void Job::on_socket_connected()
|
||||||
m_received_size += payload.size();
|
m_received_size += payload.size();
|
||||||
flush_received_buffers();
|
flush_received_buffers();
|
||||||
|
|
||||||
deferred_invoke([this](auto&) { did_progress({}, m_received_size); });
|
deferred_invoke([this] { did_progress({}, m_received_size); });
|
||||||
|
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
@ -147,14 +147,14 @@ void Job::finish_up()
|
||||||
// before we can actually call `did_finish`. in a normal flow, this should
|
// before we can actually call `did_finish`. in a normal flow, this should
|
||||||
// never be hit since the client is reading as we are writing, unless there
|
// never be hit since the client is reading as we are writing, unless there
|
||||||
// are too many concurrent downloads going on.
|
// are too many concurrent downloads going on.
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
finish_up();
|
finish_up();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto response = GeminiResponse::create(m_status, m_meta);
|
auto response = GeminiResponse::create(m_status, m_meta);
|
||||||
deferred_invoke([this, response](auto&) {
|
deferred_invoke([this, response] {
|
||||||
did_finish(move(response));
|
did_finish(move(response));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,13 @@ void HttpJob::start()
|
||||||
};
|
};
|
||||||
m_socket->on_error = [this] {
|
m_socket->on_error = [this] {
|
||||||
dbgln_if(CHTTPJOB_DEBUG, "HttpJob: on_error callback");
|
dbgln_if(CHTTPJOB_DEBUG, "HttpJob: on_error callback");
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
bool success = m_socket->connect(m_request.url().host(), m_request.url().port());
|
bool success = m_socket->connect(m_request.url().host(), m_request.url().port());
|
||||||
if (!success) {
|
if (!success) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,15 +25,15 @@ void HttpsJob::start()
|
||||||
};
|
};
|
||||||
m_socket->on_tls_error = [&](TLS::AlertDescription error) {
|
m_socket->on_tls_error = [&](TLS::AlertDescription error) {
|
||||||
if (error == TLS::AlertDescription::HandshakeFailure) {
|
if (error == TLS::AlertDescription::HandshakeFailure) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::ProtocolFailed);
|
return did_fail(Core::NetworkJob::Error::ProtocolFailed);
|
||||||
});
|
});
|
||||||
} else if (error == TLS::AlertDescription::DecryptError) {
|
} else if (error == TLS::AlertDescription::DecryptError) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::TransmissionFailed);
|
return did_fail(Core::NetworkJob::Error::TransmissionFailed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void HttpsJob::start()
|
||||||
};
|
};
|
||||||
bool success = ((TLS::TLSv12&)*m_socket).connect(m_request.url().host(), m_request.url().port());
|
bool success = ((TLS::TLSv12&)*m_socket).connect(m_request.url().host(), m_request.url().port());
|
||||||
if (!success) {
|
if (!success) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
return did_fail(Core::NetworkJob::Error::ConnectionFailed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ void Job::on_socket_connected()
|
||||||
|
|
||||||
bool success = write(raw_request);
|
bool success = write(raw_request);
|
||||||
if (!success)
|
if (!success)
|
||||||
deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
deferred_invoke([this] { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
||||||
});
|
});
|
||||||
register_on_ready_to_read([&] {
|
register_on_ready_to_read([&] {
|
||||||
if (is_cancelled())
|
if (is_cancelled())
|
||||||
|
@ -137,17 +137,17 @@ void Job::on_socket_connected()
|
||||||
auto line = read_line(PAGE_SIZE);
|
auto line = read_line(PAGE_SIZE);
|
||||||
if (line.is_null()) {
|
if (line.is_null()) {
|
||||||
warnln("Job: Expected HTTP status");
|
warnln("Job: Expected HTTP status");
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
||||||
}
|
}
|
||||||
auto parts = line.split_view(' ');
|
auto parts = line.split_view(' ');
|
||||||
if (parts.size() < 3) {
|
if (parts.size() < 3) {
|
||||||
warnln("Job: Expected 3-part HTTP status, got '{}'", line);
|
warnln("Job: Expected 3-part HTTP status, got '{}'", line);
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
}
|
}
|
||||||
auto code = parts[1].to_uint();
|
auto code = parts[1].to_uint();
|
||||||
if (!code.has_value()) {
|
if (!code.has_value()) {
|
||||||
warnln("Job: Expected numeric HTTP status");
|
warnln("Job: Expected numeric HTTP status");
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
}
|
}
|
||||||
m_code = code.value();
|
m_code = code.value();
|
||||||
m_state = State::InHeaders;
|
m_state = State::InHeaders;
|
||||||
|
@ -186,7 +186,7 @@ void Job::on_socket_connected()
|
||||||
return finish_up();
|
return finish_up();
|
||||||
}
|
}
|
||||||
warnln("Job: Expected HTTP header with key/value");
|
warnln("Job: Expected HTTP header with key/value");
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
}
|
}
|
||||||
auto name = parts[0];
|
auto name = parts[0];
|
||||||
if (line.length() < name.length() + 2) {
|
if (line.length() < name.length() + 2) {
|
||||||
|
@ -197,7 +197,7 @@ void Job::on_socket_connected()
|
||||||
return finish_up();
|
return finish_up();
|
||||||
}
|
}
|
||||||
warnln("Job: Malformed HTTP header: '{}' ({})", line, line.length());
|
warnln("Job: Malformed HTTP header: '{}' ({})", line, line.length());
|
||||||
return deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
}
|
}
|
||||||
auto value = line.substring(name.length() + 2, line.length() - name.length() - 2);
|
auto value = line.substring(name.length() + 2, line.length() - name.length() - 2);
|
||||||
m_headers.set(name, value);
|
m_headers.set(name, value);
|
||||||
|
@ -238,7 +238,7 @@ void Job::on_socket_connected()
|
||||||
auto size = strtoul(size_string.characters(), &endptr, 16);
|
auto size = strtoul(size_string.characters(), &endptr, 16);
|
||||||
if (*endptr) {
|
if (*endptr) {
|
||||||
// invalid number
|
// invalid number
|
||||||
deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
deferred_invoke([this] { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
}
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
|
@ -287,7 +287,7 @@ void Job::on_socket_connected()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_fail_on_empty_payload()) {
|
if (should_fail_on_empty_payload()) {
|
||||||
deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ void Job::on_socket_connected()
|
||||||
content_length = length.value();
|
content_length = length.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
deferred_invoke([this, content_length](auto&) { did_progress(content_length, m_received_size); });
|
deferred_invoke([this, content_length] { did_progress(content_length, m_received_size); });
|
||||||
|
|
||||||
if (content_length.has_value()) {
|
if (content_length.has_value()) {
|
||||||
auto length = content_length.value();
|
auto length = content_length.value();
|
||||||
|
@ -397,7 +397,7 @@ void Job::finish_up()
|
||||||
|
|
||||||
m_has_scheduled_finish = true;
|
m_has_scheduled_finish = true;
|
||||||
auto response = HttpResponse::create(m_code, move(m_headers));
|
auto response = HttpResponse::create(m_code, move(m_headers));
|
||||||
deferred_invoke([this, response = move(response)](auto&) {
|
deferred_invoke([this, response = move(response)] {
|
||||||
did_finish(response);
|
did_finish(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ protected:
|
||||||
}
|
}
|
||||||
if (nread == 0) {
|
if (nread == 0) {
|
||||||
if (bytes.is_empty()) {
|
if (bytes.is_empty()) {
|
||||||
deferred_invoke([this](auto&) { shutdown(); });
|
deferred_invoke([this] { shutdown(); });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -241,7 +241,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_unprocessed_messages.is_empty()) {
|
if (!m_unprocessed_messages.is_empty()) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
handle_messages();
|
handle_messages();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -607,7 +607,7 @@ void Editor::resized()
|
||||||
if (set_origin(false)) {
|
if (set_origin(false)) {
|
||||||
handle_resize_event(false);
|
handle_resize_event(false);
|
||||||
} else {
|
} else {
|
||||||
deferred_invoke([this](auto&) { handle_resize_event(true); });
|
deferred_invoke([this] { handle_resize_event(true); });
|
||||||
m_has_origin_reset_scheduled = true;
|
m_has_origin_reset_scheduled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,7 +618,7 @@ void Editor::handle_resize_event(bool reset_origin)
|
||||||
m_has_origin_reset_scheduled = false;
|
m_has_origin_reset_scheduled = false;
|
||||||
if (reset_origin && !set_origin(false)) {
|
if (reset_origin && !set_origin(false)) {
|
||||||
m_has_origin_reset_scheduled = true;
|
m_has_origin_reset_scheduled = true;
|
||||||
return deferred_invoke([this](auto&) { handle_resize_event(true); });
|
return deferred_invoke([this] { handle_resize_event(true); });
|
||||||
}
|
}
|
||||||
|
|
||||||
set_origin(m_origin_row, 1);
|
set_origin(m_origin_row, 1);
|
||||||
|
@ -722,7 +722,7 @@ auto Editor::get_line(const String& prompt) -> Result<String, Editor::Error>
|
||||||
|
|
||||||
m_notifier->on_ready_to_read = [&] { try_update_once(); };
|
m_notifier->on_ready_to_read = [&] { try_update_once(); };
|
||||||
if (!m_incomplete_data.is_empty())
|
if (!m_incomplete_data.is_empty())
|
||||||
deferred_invoke([&](auto&) { try_update_once(); });
|
deferred_invoke([&] { try_update_once(); });
|
||||||
|
|
||||||
if (loop.exec() == Retry)
|
if (loop.exec() == Retry)
|
||||||
return get_line(prompt);
|
return get_line(prompt);
|
||||||
|
@ -1166,7 +1166,7 @@ void Editor::handle_read_event()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_incomplete_data.is_empty() && !m_finish)
|
if (!m_incomplete_data.is_empty() && !m_finish)
|
||||||
deferred_invoke([&](auto&) { try_update_once(); });
|
deferred_invoke([&] { try_update_once(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::cleanup_suggestions()
|
void Editor::cleanup_suggestions()
|
||||||
|
|
|
@ -265,7 +265,7 @@ void Editor::enter_search()
|
||||||
search_editor.finish();
|
search_editor.finish();
|
||||||
m_reset_buffer_on_search_end = true;
|
m_reset_buffer_on_search_end = true;
|
||||||
search_editor.end_search();
|
search_editor.end_search();
|
||||||
search_editor.deferred_invoke([&search_editor](auto&) { search_editor.really_quit_event_loop(); });
|
search_editor.deferred_invoke([&search_editor] { search_editor.really_quit_event_loop(); });
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ void TLSv12::write_packet(ByteBuffer& packet)
|
||||||
if (m_context.connection_status > ConnectionStatus::Disconnected) {
|
if (m_context.connection_status > ConnectionStatus::Disconnected) {
|
||||||
if (!m_has_scheduled_write_flush) {
|
if (!m_has_scheduled_write_flush) {
|
||||||
dbgln_if(TLS_DEBUG, "Scheduling write of {}", m_context.tls_buffer.size());
|
dbgln_if(TLS_DEBUG, "Scheduling write of {}", m_context.tls_buffer.size());
|
||||||
deferred_invoke([this](auto&) { write_into_socket(); });
|
deferred_invoke([this] { write_into_socket(); });
|
||||||
m_has_scheduled_write_flush = true;
|
m_has_scheduled_write_flush = true;
|
||||||
} else {
|
} else {
|
||||||
// multiple packet are available, let's flush some out
|
// multiple packet are available, let's flush some out
|
||||||
|
|
|
@ -97,7 +97,7 @@ bool TLSv12::common_connect(const struct sockaddr* saddr, socklen_t length)
|
||||||
auto packet = build_hello();
|
auto packet = build_hello();
|
||||||
write_packet(packet);
|
write_packet(packet);
|
||||||
|
|
||||||
deferred_invoke([&](auto&) {
|
deferred_invoke([&] {
|
||||||
m_handshake_timeout_timer = Core::Timer::create_single_shot(
|
m_handshake_timeout_timer = Core::Timer::create_single_shot(
|
||||||
m_max_wait_time_for_handshake_in_seconds * 1000, [&] {
|
m_max_wait_time_for_handshake_in_seconds * 1000, [&] {
|
||||||
auto timeout_diff = Core::DateTime::now().timestamp() - m_context.handshake_initiation_timestamp;
|
auto timeout_diff = Core::DateTime::now().timestamp() - m_context.handshake_initiation_timestamp;
|
||||||
|
@ -141,7 +141,7 @@ void TLSv12::read_from_socket()
|
||||||
auto notify_client_for_app_data = [&] {
|
auto notify_client_for_app_data = [&] {
|
||||||
if (m_context.application_buffer.size() > 0) {
|
if (m_context.application_buffer.size() > 0) {
|
||||||
if (!did_schedule_read) {
|
if (!did_schedule_read) {
|
||||||
deferred_invoke([&](auto&) { read_from_socket(); });
|
deferred_invoke([&] { read_from_socket(); });
|
||||||
did_schedule_read = true;
|
did_schedule_read = true;
|
||||||
}
|
}
|
||||||
if (on_tls_ready_to_read)
|
if (on_tls_ready_to_read)
|
||||||
|
|
|
@ -106,7 +106,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
|
||||||
|
|
||||||
if (url.protocol() == "about") {
|
if (url.protocol() == "about") {
|
||||||
dbgln_if(SPAM_DEBUG, "Loading about: URL {}", url);
|
dbgln_if(SPAM_DEBUG, "Loading about: URL {}", url);
|
||||||
deferred_invoke([success_callback = move(success_callback)](auto&) {
|
deferred_invoke([success_callback = move(success_callback)] {
|
||||||
success_callback(String::empty().to_byte_buffer(), {}, {});
|
success_callback(String::empty().to_byte_buffer(), {}, {});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -124,7 +124,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
|
||||||
else
|
else
|
||||||
data = url.data_payload().to_byte_buffer();
|
data = url.data_payload().to_byte_buffer();
|
||||||
|
|
||||||
deferred_invoke([data = move(data), success_callback = move(success_callback)](auto&) {
|
deferred_invoke([data = move(data), success_callback = move(success_callback)] {
|
||||||
success_callback(data, {}, {});
|
success_callback(data, {}, {});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -141,7 +141,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
|
||||||
}
|
}
|
||||||
|
|
||||||
auto data = f->read_all();
|
auto data = f->read_all();
|
||||||
deferred_invoke([data = move(data), success_callback = move(success_callback)](auto&) {
|
deferred_invoke([data = move(data), success_callback = move(success_callback)] {
|
||||||
success_callback(data, {}, {});
|
success_callback(data, {}, {});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -171,7 +171,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
|
||||||
error_callback("HTTP load failed", {});
|
error_callback("HTTP load failed", {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
deferred_invoke([protocol_request](auto&) {
|
deferred_invoke([protocol_request] {
|
||||||
// Clear circular reference of `protocol_request` captured by copy
|
// Clear circular reference of `protocol_request` captured by copy
|
||||||
const_cast<Protocol::Request&>(*protocol_request).on_buffered_request_finish = nullptr;
|
const_cast<Protocol::Request&>(*protocol_request).on_buffered_request_finish = nullptr;
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,7 +64,7 @@ void OutOfProcessWebView::create_client()
|
||||||
|
|
||||||
m_client_state.client = WebContentClient::construct(*this);
|
m_client_state.client = WebContentClient::construct(*this);
|
||||||
m_client_state.client->on_web_content_process_crash = [this] {
|
m_client_state.client->on_web_content_process_crash = [this] {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
handle_web_content_process_crash();
|
handle_web_content_process_crash();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,7 +36,7 @@ void TCPWebSocketConnectionImpl::connect(ConnectionInfo const& connection)
|
||||||
};
|
};
|
||||||
bool success = m_socket->connect(connection.url().host(), connection.url().port());
|
bool success = m_socket->connect(connection.url().host(), connection.url().port());
|
||||||
if (!success) {
|
if (!success) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
on_connection_error();
|
on_connection_error();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ void TLSv12WebSocketConnectionImpl::connect(ConnectionInfo const& connection)
|
||||||
};
|
};
|
||||||
bool success = m_socket->connect(connection.url().host(), connection.url().port());
|
bool success = m_socket->connect(connection.url().host(), connection.url().port());
|
||||||
if (!success) {
|
if (!success) {
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
on_connection_error();
|
on_connection_error();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ DatabaseConnection::DatabaseConnection(String database_name, int client_id)
|
||||||
|
|
||||||
dbgln_if(SQLSERVER_DEBUG, "DatabaseConnection {} initiating connection with database '{}'", connection_id(), m_database_name);
|
dbgln_if(SQLSERVER_DEBUG, "DatabaseConnection {} initiating connection with database '{}'", connection_id(), m_database_name);
|
||||||
s_connections.set(m_connection_id, *this);
|
s_connections.set(m_connection_id, *this);
|
||||||
deferred_invoke([&](Object&) {
|
deferred_invoke([&] {
|
||||||
m_database = SQL::Database::construct(String::formatted("/home/anon/sql/{}.db", m_database_name));
|
m_database = SQL::Database::construct(String::formatted("/home/anon/sql/{}.db", m_database_name));
|
||||||
m_accept_statements = true;
|
m_accept_statements = true;
|
||||||
auto client_connection = ClientConnection::client_connection_for(m_client_id);
|
auto client_connection = ClientConnection::client_connection_for(m_client_id);
|
||||||
|
@ -53,7 +53,7 @@ void DatabaseConnection::disconnect()
|
||||||
{
|
{
|
||||||
dbgln_if(SQLSERVER_DEBUG, "DatabaseConnection::disconnect(connection_id {}, database '{}'", connection_id(), m_database_name);
|
dbgln_if(SQLSERVER_DEBUG, "DatabaseConnection::disconnect(connection_id {}, database '{}'", connection_id(), m_database_name);
|
||||||
m_accept_statements = false;
|
m_accept_statements = false;
|
||||||
deferred_invoke([&](Object&) {
|
deferred_invoke([&] {
|
||||||
m_database = nullptr;
|
m_database = nullptr;
|
||||||
s_connections.remove(m_connection_id);
|
s_connections.remove(m_connection_id);
|
||||||
auto client_connection = ClientConnection::client_connection_for(client_id());
|
auto client_connection = ClientConnection::client_connection_for(client_id());
|
||||||
|
|
|
@ -60,7 +60,7 @@ void SQLStatement::execute()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deferred_invoke([&](Object&) {
|
deferred_invoke([&] {
|
||||||
auto maybe_error = parse();
|
auto maybe_error = parse();
|
||||||
if (maybe_error.has_value()) {
|
if (maybe_error.has_value()) {
|
||||||
report_error(maybe_error.value());
|
report_error(maybe_error.value());
|
||||||
|
@ -107,7 +107,7 @@ void SQLStatement::next()
|
||||||
if (m_index < m_result->results().size()) {
|
if (m_index < m_result->results().size()) {
|
||||||
auto& tuple = m_result->results()[m_index++];
|
auto& tuple = m_result->results()[m_index++];
|
||||||
client_connection->async_next_result(statement_id(), tuple.to_string_vector());
|
client_connection->async_next_result(statement_id(), tuple.to_string_vector());
|
||||||
deferred_invoke([&](Object&) {
|
deferred_invoke([&] {
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -36,10 +36,7 @@ Client::Client(NonnullRefPtr<Core::TCPSocket> socket, Core::Object* parent)
|
||||||
|
|
||||||
void Client::die()
|
void Client::die()
|
||||||
{
|
{
|
||||||
deferred_invoke([this](auto& object) {
|
deferred_invoke([this] { remove_from_parent(); });
|
||||||
NonnullRefPtr protector { object };
|
|
||||||
remove_from_parent();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::start()
|
void Client::start()
|
||||||
|
|
|
@ -126,7 +126,7 @@ void ClientConnection::did_error(i32 connection_id, i32 message)
|
||||||
void ClientConnection::did_close(i32 connection_id, u16 code, String reason, bool was_clean)
|
void ClientConnection::did_close(i32 connection_id, u16 code, String reason, bool was_clean)
|
||||||
{
|
{
|
||||||
async_closed(connection_id, code, reason, was_clean);
|
async_closed(connection_id, code, reason, was_clean);
|
||||||
deferred_invoke([this, connection_id](auto&) {
|
deferred_invoke([this, connection_id] {
|
||||||
m_connections.remove(connection_id);
|
m_connections.remove(connection_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ ClientConnection::~ClientConnection()
|
||||||
|
|
||||||
void ClientConnection::die()
|
void ClientConnection::die()
|
||||||
{
|
{
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
s_connections->remove(client_id());
|
s_connections->remove(client_id());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ WMClientConnection::~WMClientConnection()
|
||||||
|
|
||||||
void WMClientConnection::die()
|
void WMClientConnection::die()
|
||||||
{
|
{
|
||||||
deferred_invoke([this](auto&) {
|
deferred_invoke([this] {
|
||||||
s_connections.remove(client_id());
|
s_connections.remove(client_id());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -764,7 +764,7 @@ void Window::request_update(const Gfx::IntRect& rect, bool ignore_occlusion)
|
||||||
if (rect.is_empty())
|
if (rect.is_empty())
|
||||||
return;
|
return;
|
||||||
if (m_pending_paint_rects.is_empty()) {
|
if (m_pending_paint_rects.is_empty()) {
|
||||||
deferred_invoke([this, ignore_occlusion](auto&) {
|
deferred_invoke([this, ignore_occlusion] {
|
||||||
client()->post_paint_message(*this, ignore_occlusion);
|
client()->post_paint_message(*this, ignore_occlusion);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -958,7 +958,7 @@ void Shell::run_tail(const AST::Command& invoking_command, const AST::NodeWithAc
|
||||||
void Shell::run_tail(RefPtr<Job> job)
|
void Shell::run_tail(RefPtr<Job> job)
|
||||||
{
|
{
|
||||||
if (auto cmd = job->command_ptr()) {
|
if (auto cmd = job->command_ptr()) {
|
||||||
deferred_invoke([=, this](auto&) {
|
deferred_invoke([=, this] {
|
||||||
for (auto& next_in_chain : cmd->next_chain) {
|
for (auto& next_in_chain : cmd->next_chain) {
|
||||||
run_tail(*cmd, next_in_chain, job->exit_code());
|
run_tail(*cmd, next_in_chain, job->exit_code());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue