chromium/chrome/test/chromedriver/server/http_handler.h

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_
#define CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_

#include <memory>
#include <optional>
#include <string>
#include <vector>

#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "chrome/test/chromedriver/command.h"
#include "chrome/test/chromedriver/commands.h"
#include "chrome/test/chromedriver/connection_session_map.h"
#include "chrome/test/chromedriver/element_commands.h"
#include "chrome/test/chromedriver/net/sync_websocket_factory.h"
#include "chrome/test/chromedriver/session_commands.h"
#include "chrome/test/chromedriver/session_connection_map.h"
#include "chrome/test/chromedriver/session_thread_map.h"
#include "chrome/test/chromedriver/window_commands.h"
#include "net/http/http_status_code.h"

namespace base {
class SingleThreadTaskRunner;
}

namespace net {
class HttpServerRequestInfo;
class HttpServerResponseInfo;
}

namespace network {
class TransitionalURLLoaderFactoryOwner;
}

class Adb;
class DeviceManager;
class URLRequestContextGetter;
class WrapperURLLoaderFactory;

class HttpServer;
class HttpServerInterface;

enum HttpMethod {};

struct CommandMapping {};

extern const char kCreateWebSocketPath[];
extern const char kSendCommandFromWebSocket[];

HttpResponseSenderFunc;

class HttpHandler {};

namespace internal {

extern const char kNewSessionPathPattern[];

bool MatchesCommand(const std::string& method,
                    const std::string& path,
                    const CommandMapping& command,
                    std::string* session_id,
                    base::Value::Dict* out_params);

bool IsNewSession(const CommandMapping& command);

Status ParseBidiCommand(const std::string& data, base::Value::Dict& parsed);

base::Value::Dict CreateBidiErrorResponse(
    Status status,
    std::optional<base::Value> maybe_id = std::nullopt);

}  // namespace internal

#endif  // CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_