mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -33,7 +33,7 @@ bool ContentFilter::is_filtered(const AK::URL& url) const
|
|||
return false;
|
||||
}
|
||||
|
||||
void ContentFilter::add_pattern(String const& pattern)
|
||||
void ContentFilter::add_pattern(DeprecatedString const& pattern)
|
||||
{
|
||||
StringBuilder builder;
|
||||
if (!pattern.starts_with('*'))
|
||||
|
|
|
@ -16,14 +16,14 @@ public:
|
|||
static ContentFilter& the();
|
||||
|
||||
bool is_filtered(const AK::URL&) const;
|
||||
void add_pattern(String const&);
|
||||
void add_pattern(DeprecatedString const&);
|
||||
|
||||
private:
|
||||
ContentFilter();
|
||||
~ContentFilter();
|
||||
|
||||
struct Pattern {
|
||||
String text;
|
||||
DeprecatedString text;
|
||||
};
|
||||
Vector<Pattern> m_patterns;
|
||||
};
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
namespace Web {
|
||||
|
||||
FileRequest::FileRequest(String path)
|
||||
FileRequest::FileRequest(DeprecatedString path)
|
||||
: m_path(move(path))
|
||||
{
|
||||
}
|
||||
|
||||
String FileRequest::path() const
|
||||
DeprecatedString FileRequest::path() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
|
|
@ -6,23 +6,23 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
class FileRequest : public RefCounted<FileRequest> {
|
||||
public:
|
||||
explicit FileRequest(String path);
|
||||
explicit FileRequest(DeprecatedString path);
|
||||
|
||||
String path() const;
|
||||
DeprecatedString path() const;
|
||||
|
||||
Function<void(ErrorOr<i32>)> on_file_request_finish;
|
||||
|
||||
private:
|
||||
String m_path {};
|
||||
DeprecatedString m_path {};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
namespace Web {
|
||||
|
||||
static String s_default_favicon_path = "/res/icons/16x16/app-browser.png";
|
||||
static DeprecatedString s_default_favicon_path = "/res/icons/16x16/app-browser.png";
|
||||
static RefPtr<Gfx::Bitmap> s_default_favicon_bitmap;
|
||||
|
||||
void FrameLoader::set_default_favicon_path(String path)
|
||||
void FrameLoader::set_default_favicon_path(DeprecatedString path)
|
||||
{
|
||||
s_default_favicon_path = move(path);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ static bool build_text_document(DOM::Document& document, ByteBuffer const& data)
|
|||
auto pre_element = document.create_element("pre").release_value();
|
||||
MUST(body_element->append_child(pre_element));
|
||||
|
||||
MUST(pre_element->append_child(document.create_text_node(String::copy(data))));
|
||||
MUST(pre_element->append_child(document.create_text_node(DeprecatedString::copy(data))));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data
|
|||
MUST(head_element->append_child(title_element));
|
||||
|
||||
auto basename = LexicalPath::basename(document.url().path());
|
||||
auto title_text = document.heap().allocate<DOM::Text>(document.realm(), document, String::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height()));
|
||||
auto title_text = document.heap().allocate<DOM::Text>(document.realm(), document, DeprecatedString::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height()));
|
||||
MUST(title_element->append_child(*title_text));
|
||||
|
||||
auto body_element = document.create_element("body").release_value();
|
||||
|
@ -160,7 +160,7 @@ static bool build_gemini_document(DOM::Document& document, ByteBuffer const& dat
|
|||
{
|
||||
StringView gemini_data { data };
|
||||
auto gemini_document = Gemini::Document::parse(gemini_data, document.url());
|
||||
String html_data = gemini_document->render_to_html();
|
||||
DeprecatedString html_data = gemini_document->render_to_html();
|
||||
|
||||
dbgln_if(GEMINI_DEBUG, "Gemini data:\n\"\"\"{}\"\"\"", gemini_data);
|
||||
dbgln_if(GEMINI_DEBUG, "Converted to HTML:\n\"\"\"{}\"\"\"", html_data);
|
||||
|
@ -324,9 +324,9 @@ void FrameLoader::load_html(StringView html, const AK::URL& url)
|
|||
parser->run(url);
|
||||
}
|
||||
|
||||
static String s_error_page_url = "file:///res/html/error.html";
|
||||
static DeprecatedString s_error_page_url = "file:///res/html/error.html";
|
||||
|
||||
void FrameLoader::set_error_page_url(String error_page_url)
|
||||
void FrameLoader::set_error_page_url(DeprecatedString error_page_url)
|
||||
{
|
||||
s_error_page_url = error_page_url;
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ void FrameLoader::set_error_page_url(String error_page_url)
|
|||
// FIXME: Use an actual templating engine (our own one when it's built, preferably
|
||||
// with a way to check these usages at compile time)
|
||||
|
||||
void FrameLoader::load_error_page(const AK::URL& failed_url, String const& error)
|
||||
void FrameLoader::load_error_page(const AK::URL& failed_url, DeprecatedString const& error)
|
||||
{
|
||||
ResourceLoader::the().load(
|
||||
s_error_page_url,
|
||||
|
@ -363,7 +363,7 @@ void FrameLoader::load_favicon(RefPtr<Gfx::Bitmap> bitmap)
|
|||
}
|
||||
}
|
||||
|
||||
void FrameLoader::store_response_cookies(AK::URL const& url, String const& cookies)
|
||||
void FrameLoader::store_response_cookies(AK::URL const& url, DeprecatedString const& cookies)
|
||||
{
|
||||
auto* page = browsing_context().page();
|
||||
if (!page)
|
||||
|
|
|
@ -24,8 +24,8 @@ public:
|
|||
Redirect,
|
||||
};
|
||||
|
||||
static void set_default_favicon_path(String);
|
||||
static void set_error_page_url(String);
|
||||
static void set_default_favicon_path(DeprecatedString);
|
||||
static void set_error_page_url(DeprecatedString);
|
||||
|
||||
explicit FrameLoader(HTML::BrowsingContext&);
|
||||
~FrameLoader();
|
||||
|
@ -43,11 +43,11 @@ private:
|
|||
virtual void resource_did_load() override;
|
||||
virtual void resource_did_fail() override;
|
||||
|
||||
void load_error_page(const AK::URL& failed_url, String const& error_message);
|
||||
void load_error_page(const AK::URL& failed_url, DeprecatedString const& error_message);
|
||||
void load_favicon(RefPtr<Gfx::Bitmap> bitmap = nullptr);
|
||||
bool parse_document(DOM::Document&, ByteBuffer const& data);
|
||||
|
||||
void store_response_cookies(AK::URL const& url, String const& cookies);
|
||||
void store_response_cookies(AK::URL const& url, DeprecatedString const& cookies);
|
||||
|
||||
HTML::BrowsingContext& m_browsing_context;
|
||||
size_t m_redirects_count { 0 };
|
||||
|
|
|
@ -16,7 +16,7 @@ LoadRequest LoadRequest::create_for_url_on_page(const AK::URL& url, Page* page)
|
|||
request.set_url(url);
|
||||
|
||||
if (page) {
|
||||
String cookie = page->client().page_did_request_cookie(url, Cookie::Source::Http);
|
||||
DeprecatedString cookie = page->client().page_did_request_cookie(url, Cookie::Source::Http);
|
||||
if (!cookie.is_empty())
|
||||
request.set_header("Cookie", cookie);
|
||||
request.set_page(*page);
|
||||
|
|
|
@ -29,8 +29,8 @@ public:
|
|||
const AK::URL& url() const { return m_url; }
|
||||
void set_url(const AK::URL& url) { m_url = url; }
|
||||
|
||||
String const& method() const { return m_method; }
|
||||
void set_method(String const& method) { m_method = method; }
|
||||
DeprecatedString const& method() const { return m_method; }
|
||||
void set_method(DeprecatedString const& method) { m_method = method; }
|
||||
|
||||
ByteBuffer const& body() const { return m_body; }
|
||||
void set_body(ByteBuffer body) { m_body = move(body); }
|
||||
|
@ -63,15 +63,15 @@ public:
|
|||
return m_url == other.m_url && m_method == other.m_method && m_body == other.m_body;
|
||||
}
|
||||
|
||||
void set_header(String const& name, String const& value) { m_headers.set(name, value); }
|
||||
String header(String const& name) const { return m_headers.get(name).value_or({}); }
|
||||
void set_header(DeprecatedString const& name, DeprecatedString const& value) { m_headers.set(name, value); }
|
||||
DeprecatedString header(DeprecatedString const& name) const { return m_headers.get(name).value_or({}); }
|
||||
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
|
||||
|
||||
private:
|
||||
AK::URL m_url;
|
||||
String m_method { "GET" };
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
|
||||
DeprecatedString m_method { "GET" };
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_headers;
|
||||
ByteBuffer m_body;
|
||||
Core::ElapsedTimer m_load_timer;
|
||||
Optional<Page&> m_page;
|
||||
|
|
|
@ -29,7 +29,7 @@ Core::ProxyData Web::ProxyMappings::proxy_for_url(AK::URL const& url) const
|
|||
return {};
|
||||
}
|
||||
|
||||
void Web::ProxyMappings::set_mappings(Vector<String> proxies, OrderedHashMap<String, size_t> mappings)
|
||||
void Web::ProxyMappings::set_mappings(Vector<DeprecatedString> proxies, OrderedHashMap<DeprecatedString, size_t> mappings)
|
||||
{
|
||||
m_proxies = move(proxies);
|
||||
m_mappings = move(mappings);
|
||||
|
|
|
@ -18,14 +18,14 @@ public:
|
|||
static ProxyMappings& the();
|
||||
|
||||
Core::ProxyData proxy_for_url(AK::URL const&) const;
|
||||
void set_mappings(Vector<String> proxies, OrderedHashMap<String, size_t> mappings);
|
||||
void set_mappings(Vector<DeprecatedString> proxies, OrderedHashMap<DeprecatedString, size_t> mappings);
|
||||
|
||||
private:
|
||||
ProxyMappings() = default;
|
||||
~ProxyMappings() = default;
|
||||
|
||||
Vector<String> m_proxies;
|
||||
OrderedHashMap<String, size_t> m_mappings;
|
||||
Vector<DeprecatedString> m_proxies;
|
||||
OrderedHashMap<DeprecatedString, size_t> m_mappings;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void Resource::for_each_client(Function<void(ResourceClient&)> callback)
|
|||
}
|
||||
}
|
||||
|
||||
static Optional<String> encoding_from_content_type(String const& content_type)
|
||||
static Optional<DeprecatedString> encoding_from_content_type(DeprecatedString const& content_type)
|
||||
{
|
||||
auto offset = content_type.find("charset="sv);
|
||||
if (offset.has_value()) {
|
||||
|
@ -72,7 +72,7 @@ static Optional<String> encoding_from_content_type(String const& content_type)
|
|||
return {};
|
||||
}
|
||||
|
||||
static String mime_type_from_content_type(String const& content_type)
|
||||
static DeprecatedString mime_type_from_content_type(DeprecatedString const& content_type)
|
||||
{
|
||||
auto offset = content_type.find(';');
|
||||
if (offset.has_value())
|
||||
|
@ -81,12 +81,12 @@ static String mime_type_from_content_type(String const& content_type)
|
|||
return content_type;
|
||||
}
|
||||
|
||||
static bool is_valid_encoding(String const& encoding)
|
||||
static bool is_valid_encoding(DeprecatedString const& encoding)
|
||||
{
|
||||
return TextCodec::decoder_for(encoding);
|
||||
}
|
||||
|
||||
void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<String, String, CaseInsensitiveStringTraits> const& headers, Optional<u32> status_code)
|
||||
void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& headers, Optional<u32> status_code)
|
||||
{
|
||||
VERIFY(!m_loaded);
|
||||
// FIXME: Handle OOM failure.
|
||||
|
@ -131,7 +131,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<Strin
|
|||
});
|
||||
}
|
||||
|
||||
void Resource::did_fail(Badge<ResourceLoader>, String const& error, Optional<u32> status_code)
|
||||
void Resource::did_fail(Badge<ResourceLoader>, DeprecatedString const& error, Optional<u32> status_code)
|
||||
{
|
||||
m_error = error;
|
||||
m_status_code = move(status_code);
|
||||
|
|
|
@ -40,14 +40,14 @@ public:
|
|||
bool is_loaded() const { return m_loaded; }
|
||||
|
||||
bool is_failed() const { return m_failed; }
|
||||
String const& error() const { return m_error; }
|
||||
DeprecatedString const& error() const { return m_error; }
|
||||
|
||||
bool has_encoded_data() const { return !m_encoded_data.is_empty(); }
|
||||
|
||||
const AK::URL& url() const { return m_request.url(); }
|
||||
ByteBuffer const& encoded_data() const { return m_encoded_data; }
|
||||
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; }
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; }
|
||||
|
||||
[[nodiscard]] Optional<u32> status_code() const { return m_status_code; }
|
||||
|
||||
|
@ -55,13 +55,13 @@ public:
|
|||
void unregister_client(Badge<ResourceClient>, ResourceClient&);
|
||||
|
||||
bool has_encoding() const { return m_encoding.has_value(); }
|
||||
Optional<String> const& encoding() const { return m_encoding; }
|
||||
String const& mime_type() const { return m_mime_type; }
|
||||
Optional<DeprecatedString> const& encoding() const { return m_encoding; }
|
||||
DeprecatedString const& mime_type() const { return m_mime_type; }
|
||||
|
||||
void for_each_client(Function<void(ResourceClient&)>);
|
||||
|
||||
void did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<String, String, CaseInsensitiveStringTraits> const& headers, Optional<u32> status_code);
|
||||
void did_fail(Badge<ResourceLoader>, String const& error, Optional<u32> status_code);
|
||||
void did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& headers, Optional<u32> status_code);
|
||||
void did_fail(Badge<ResourceLoader>, DeprecatedString const& error, Optional<u32> status_code);
|
||||
|
||||
protected:
|
||||
explicit Resource(Type, LoadRequest const&);
|
||||
|
@ -73,11 +73,11 @@ private:
|
|||
Type m_type { Type::Generic };
|
||||
bool m_loaded { false };
|
||||
bool m_failed { false };
|
||||
String m_error;
|
||||
Optional<String> m_encoding;
|
||||
DeprecatedString m_error;
|
||||
Optional<DeprecatedString> m_encoding;
|
||||
|
||||
String m_mime_type;
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_response_headers;
|
||||
DeprecatedString m_mime_type;
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_response_headers;
|
||||
Optional<u32> m_status_code;
|
||||
HashTable<ResourceClient*> m_clients;
|
||||
};
|
||||
|
|
|
@ -118,14 +118,14 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, LoadRequest&
|
|||
return resource;
|
||||
}
|
||||
|
||||
static String sanitized_url_for_logging(AK::URL const& url)
|
||||
static DeprecatedString sanitized_url_for_logging(AK::URL const& url)
|
||||
{
|
||||
if (url.scheme() == "data"sv)
|
||||
return String::formatted("[data URL, mime-type={}, size={}]", url.data_mime_type(), url.data_payload().length());
|
||||
return DeprecatedString::formatted("[data URL, mime-type={}, size={}]", url.data_mime_type(), url.data_payload().length());
|
||||
return url.to_string();
|
||||
}
|
||||
|
||||
static void emit_signpost(String const& message, int id)
|
||||
static void emit_signpost(DeprecatedString const& message, int id)
|
||||
{
|
||||
#ifdef AK_OS_SERENITY
|
||||
auto string_id = perf_register_string(message.characters(), message.length());
|
||||
|
@ -138,30 +138,30 @@ static void emit_signpost(String const& message, int id)
|
|||
|
||||
static size_t resource_id = 0;
|
||||
|
||||
void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback, Optional<u32> timeout, Function<void()> timeout_callback)
|
||||
void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(DeprecatedString const&, Optional<u32> status_code)> error_callback, Optional<u32> timeout, Function<void()> timeout_callback)
|
||||
{
|
||||
auto& url = request.url();
|
||||
request.start_timer();
|
||||
|
||||
auto id = resource_id++;
|
||||
auto url_for_logging = sanitized_url_for_logging(url);
|
||||
emit_signpost(String::formatted("Starting load: {}", url_for_logging), id);
|
||||
emit_signpost(DeprecatedString::formatted("Starting load: {}", url_for_logging), id);
|
||||
dbgln("ResourceLoader: Starting load of: \"{}\"", url_for_logging);
|
||||
|
||||
auto const log_success = [url_for_logging, id](auto const& request) {
|
||||
auto load_time_ms = request.load_time().to_milliseconds();
|
||||
emit_signpost(String::formatted("Finished load: {}", url_for_logging), id);
|
||||
emit_signpost(DeprecatedString::formatted("Finished load: {}", url_for_logging), id);
|
||||
dbgln("ResourceLoader: Finished load of: \"{}\", Duration: {}ms", url_for_logging, load_time_ms);
|
||||
};
|
||||
|
||||
auto const log_failure = [url_for_logging, id](auto const& request, auto const error_message) {
|
||||
auto load_time_ms = request.load_time().to_milliseconds();
|
||||
emit_signpost(String::formatted("Failed load: {}", url_for_logging), id);
|
||||
emit_signpost(DeprecatedString::formatted("Failed load: {}", url_for_logging), id);
|
||||
dbgln("ResourceLoader: Failed load of: \"{}\", \033[31;1mError: {}\033[0m, Duration: {}ms", url_for_logging, error_message, load_time_ms);
|
||||
};
|
||||
|
||||
if (is_port_blocked(url.port_or_default())) {
|
||||
log_failure(request, String::formatted("The port #{} is blocked", url.port_or_default()));
|
||||
log_failure(request, DeprecatedString::formatted("The port #{} is blocked", url.port_or_default()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -176,11 +176,11 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
|
|||
dbgln_if(SPAM_DEBUG, "Loading about: URL {}", url);
|
||||
log_success(request);
|
||||
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> response_headers;
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> response_headers;
|
||||
response_headers.set("Content-Type", "text/html; charset=UTF-8");
|
||||
|
||||
Platform::EventLoopPlugin::the().deferred_invoke([success_callback = move(success_callback), response_headers = move(response_headers)] {
|
||||
success_callback(String::empty().to_byte_buffer(), response_headers, {});
|
||||
success_callback(DeprecatedString::empty().to_byte_buffer(), response_headers, {});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
|
|||
if (file_or_error.is_error()) {
|
||||
log_failure(request, file_or_error.error());
|
||||
if (error_callback)
|
||||
error_callback(String::formatted("{}", file_or_error.error()), file_or_error.error().code());
|
||||
error_callback(DeprecatedString::formatted("{}", file_or_error.error()), file_or_error.error().code());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
|
|||
if (maybe_file.is_error()) {
|
||||
log_failure(request, maybe_file.error());
|
||||
if (error_callback)
|
||||
error_callback(String::formatted("{}", maybe_file.error()), maybe_file.error().code());
|
||||
error_callback(DeprecatedString::formatted("{}", maybe_file.error()), maybe_file.error().code());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
|
|||
if (maybe_data.is_error()) {
|
||||
log_failure(request, maybe_data.error());
|
||||
if (error_callback)
|
||||
error_callback(String::formatted("{}", maybe_data.error()), maybe_data.error().code());
|
||||
error_callback(DeprecatedString::formatted("{}", maybe_data.error()), maybe_data.error().code());
|
||||
return;
|
||||
}
|
||||
auto data = maybe_data.release_value();
|
||||
|
@ -266,7 +266,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
|
|||
if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "gemini") {
|
||||
auto proxy = ProxyMappings::the().proxy_for_url(url);
|
||||
|
||||
HashMap<String, String> headers;
|
||||
HashMap<DeprecatedString, DeprecatedString> headers;
|
||||
headers.set("User-Agent", m_user_agent);
|
||||
headers.set("Accept-Encoding", "gzip, deflate, br");
|
||||
|
||||
|
@ -326,13 +326,13 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
|
|||
return;
|
||||
}
|
||||
|
||||
auto not_implemented_error = String::formatted("Protocol not implemented: {}", url.scheme());
|
||||
auto not_implemented_error = DeprecatedString::formatted("Protocol not implemented: {}", url.scheme());
|
||||
log_failure(request, not_implemented_error);
|
||||
if (error_callback)
|
||||
error_callback(not_implemented_error, {});
|
||||
}
|
||||
|
||||
void ResourceLoader::load(const AK::URL& url, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback, Optional<u32> timeout, Function<void()> timeout_callback)
|
||||
void ResourceLoader::load(const AK::URL& url, Function<void(ReadonlyBytes, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(DeprecatedString const&, Optional<u32> status_code)> error_callback, Optional<u32> timeout, Function<void()> timeout_callback)
|
||||
{
|
||||
LoadRequest request;
|
||||
request.set_url(url);
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/Proxy.h>
|
||||
|
@ -54,8 +54,8 @@ public:
|
|||
virtual ~ResourceLoaderConnectorRequest();
|
||||
|
||||
struct CertificateAndKey {
|
||||
String certificate;
|
||||
String key;
|
||||
DeprecatedString certificate;
|
||||
DeprecatedString key;
|
||||
};
|
||||
|
||||
virtual void set_should_buffer_all_input(bool) = 0;
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
virtual void stream_into(Core::Stream::Stream&) = 0;
|
||||
|
||||
Function<void(bool success, u32 total_size, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish;
|
||||
Function<void(bool success, u32 total_size, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish;
|
||||
Function<void(bool success, u32 total_size)> on_finish;
|
||||
Function<void(Optional<u32> total_size, u32 downloaded_size)> on_progress;
|
||||
Function<CertificateAndKey()> on_certificate_requested;
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
virtual void prefetch_dns(AK::URL const&) = 0;
|
||||
virtual void preconnect(AK::URL const&) = 0;
|
||||
|
||||
virtual RefPtr<ResourceLoaderConnectorRequest> start_request(String const& method, AK::URL const&, HashMap<String, String> const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) = 0;
|
||||
virtual RefPtr<ResourceLoaderConnectorRequest> start_request(DeprecatedString const& method, AK::URL const&, HashMap<DeprecatedString, DeprecatedString> const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) = 0;
|
||||
|
||||
protected:
|
||||
explicit ResourceLoaderConnector();
|
||||
|
@ -93,8 +93,8 @@ public:
|
|||
|
||||
RefPtr<Resource> load_resource(Resource::Type, LoadRequest&);
|
||||
|
||||
void load(LoadRequest&, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback = nullptr, Optional<u32> timeout = {}, Function<void()> timeout_callback = nullptr);
|
||||
void load(const AK::URL&, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback = nullptr, Optional<u32> timeout = {}, Function<void()> timeout_callback = nullptr);
|
||||
void load(LoadRequest&, Function<void(ReadonlyBytes, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(DeprecatedString const&, Optional<u32> status_code)> error_callback = nullptr, Optional<u32> timeout = {}, Function<void()> timeout_callback = nullptr);
|
||||
void load(const AK::URL&, Function<void(ReadonlyBytes, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(DeprecatedString const&, Optional<u32> status_code)> error_callback = nullptr, Optional<u32> timeout = {}, Function<void()> timeout_callback = nullptr);
|
||||
|
||||
ResourceLoaderConnector& connector() { return *m_connector; }
|
||||
|
||||
|
@ -105,8 +105,8 @@ public:
|
|||
|
||||
int pending_loads() const { return m_pending_loads; }
|
||||
|
||||
String const& user_agent() const { return m_user_agent; }
|
||||
void set_user_agent(String const& user_agent) { m_user_agent = user_agent; }
|
||||
DeprecatedString const& user_agent() const { return m_user_agent; }
|
||||
void set_user_agent(DeprecatedString const& user_agent) { m_user_agent = user_agent; }
|
||||
|
||||
void clear_cache();
|
||||
void evict_from_cache(LoadRequest const&);
|
||||
|
@ -121,7 +121,7 @@ private:
|
|||
|
||||
HashTable<NonnullRefPtr<ResourceLoaderConnectorRequest>> m_active_requests;
|
||||
NonnullRefPtr<ResourceLoaderConnector> m_connector;
|
||||
String m_user_agent;
|
||||
DeprecatedString m_user_agent;
|
||||
Optional<Page&> m_page {};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue