ladybird/Userland/Services/WebDriver/Session.h
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30

76 lines
2.0 KiB
C++

/*
* Copyright (c) 2022, Florent Castelli <florent.castelli@gmail.com>
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Error.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <LibCore/Promise.h>
#include <LibWeb/WebDriver/Capabilities.h>
#include <LibWeb/WebDriver/Error.h>
#include <LibWeb/WebDriver/Response.h>
#include <WebDriver/WebContentConnection.h>
#include <unistd.h>
namespace WebDriver {
struct LaunchBrowserCallbacks;
class Session : public RefCounted<Session> {
public:
Session(unsigned session_id, NonnullRefPtr<Client> client, Web::WebDriver::LadybirdOptions options);
~Session();
unsigned session_id() const { return m_id; }
struct Window {
String handle;
NonnullRefPtr<WebContentConnection> web_content_connection;
};
WebContentConnection& web_content_connection() const
{
auto current_window = m_windows.get(m_current_window_handle);
VERIFY(current_window.has_value());
return current_window->web_content_connection;
}
String const& current_window_handle() const
{
return m_current_window_handle;
}
ErrorOr<void> start(LaunchBrowserCallbacks const&);
Web::WebDriver::Response close_window();
Web::WebDriver::Response switch_to_window(StringView);
Web::WebDriver::Response get_window_handles() const;
private:
using ServerPromise = Core::Promise<ErrorOr<void>>;
ErrorOr<NonnullRefPtr<Core::LocalServer>> create_server(NonnullRefPtr<ServerPromise> promise);
NonnullRefPtr<Client> m_client;
Web::WebDriver::LadybirdOptions m_options;
bool m_started { false };
unsigned m_id { 0 };
HashMap<String, Window> m_windows;
String m_current_window_handle;
Optional<ByteString> m_web_content_socket_path;
Optional<pid_t> m_browser_pid;
RefPtr<Core::LocalServer> m_web_content_server;
};
}