#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "perfetto/base/logging.h"
#include "perfetto/base/status.h"
#include "perfetto/ext/base/http/http_server.h"
#include "perfetto/ext/base/string_utils.h"
#include "perfetto/ext/base/string_view.h"
#include "perfetto/ext/base/unix_task_runner.h"
#include "perfetto/protozero/scattered_heap_buffer.h"
#include "perfetto/trace_processor/trace_processor.h"
#include "src/trace_processor/rpc/httpd.h"
#include "src/trace_processor/rpc/rpc.h"
#include "protos/perfetto/trace_processor/trace_processor.pbzero.h"
namespace perfetto::trace_processor {
namespace {
constexpr int kBindPort = …;
const char* kAllowedCORSOrigins[] = …;
class Httpd : public base::HttpRequestHandler { … };
base::StringView Vec2Sv(const std::vector<uint8_t>& v) { … }
void SendRpcChunk(base::HttpServerConnection* conn,
const void* data,
uint32_t len) { … }
Httpd::Httpd(std::unique_ptr<TraceProcessor> preloaded_instance)
: … { … }
Httpd::~Httpd() = default;
void Httpd::Run(int port) { … }
void Httpd::OnHttpRequest(const base::HttpRequest& req) { … }
void Httpd::OnWebsocketMessage(const base::WebsocketMessage& msg) { … }
}
void RunHttpRPCServer(std::unique_ptr<TraceProcessor> preloaded_instance,
const std::string& port_number) { … }
void Httpd::ServeHelpPage(const base::HttpRequest& req) { … }
}