chromium/chrome/browser/devtools/device/port_forwarding_controller.cc

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

#include "chrome/browser/devtools/device/port_forwarding_controller.h"

#include <map>
#include <memory>
#include <utility>

#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "net/base/address_list.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/network_isolation_key.h"
#include "net/dns/public/host_resolver_results.h"
#include "net/dns/public/resolve_error_info.h"
#include "net/log/net_log_source.h"
#include "net/log/net_log_with_source.h"
#include "net/socket/tcp_client_socket.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resolve_host_client_base.h"
#include "services/network/public/mojom/host_resolver.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/blink/public/public_buildflags.h"

BrowserThread;

namespace {

const int kBufferSize =;

enum {};

const char kErrorCodePath[] =;
const char kIdParam[] =;
const char kMethodParam[] =;
const char kParamsParam[] =;

const char kBindMethod[] =;
const char kUnbindMethod[] =;
const char kAcceptedEvent[] =;
const char kPortParam[] =;
const char kConnectionIdParam[] =;

static bool ParseNotification(const std::string& json,
                              std::string& method,
                              std::optional<base::Value::Dict>& params) {}

static bool ParseResponse(const std::string& json,
                          int* command_id,
                          int* error_code) {}

static std::string SerializeCommand(int command_id,
                                    const std::string& method,
                                    base::Value params) {}

net::NetworkTrafficAnnotationTag kPortForwardingControllerTrafficAnnotation =;

ResolveHostCallback;

// This class is created and runs on BrowserThread::UI thread.
class PortForwardingHostResolver : public network::ResolveHostClientBase {};

static void ResolveHost(Profile* profile,
                        const std::string& host,
                        int port,
                        ResolveHostCallback resolve_host_callback) {}

// This class is created and runs on the devtools ADB thread (except for the
// OnResolveHostComplete(), which runs on the BrowserThread::UI thread since it
// is called as a callback from PortForwardingHostResolver).
class SocketTunnel {};

}  // namespace

class PortForwardingController::Connection
    : public AndroidDeviceManager::AndroidWebSocket::Delegate {};

PortForwardingController::Connection::Connection(
    Profile* profile,
    Registry* registry,
    scoped_refptr<AndroidDeviceManager::Device> device,
    scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser,
    const ForwardingMap& forwarding_map)
    :{}

PortForwardingController::Connection::~Connection() {}

void PortForwardingController::Connection::UpdateForwardingMap(
    const ForwardingMap& new_forwarding_map) {}

void PortForwardingController::Connection::SerializeChanges(
    const std::string& method,
    const ForwardingMap& old_map,
    const ForwardingMap& new_map) {}

void PortForwardingController::Connection::SendCommand(
    const std::string& method, int port) {}

bool PortForwardingController::Connection::ProcessResponse(
    const std::string& message) {}

void PortForwardingController::Connection::ProcessBindResponse(
    int port, PortStatus status) {}

void PortForwardingController::Connection::ProcessUnbindResponse(
    int port, PortStatus status) {}

const PortForwardingController::PortStatusMap&
PortForwardingController::Connection::GetPortStatusMap() {}

void PortForwardingController::Connection::OnSocketOpened() {}

void PortForwardingController::Connection::OnSocketClosed() {}

void PortForwardingController::Connection::OnFrameRead(
    const std::string& message) {}

PortForwardingController::PortForwardingController(Profile* profile)
    :{}

PortForwardingController::~PortForwardingController() {}

PortForwardingController::ForwardingStatus
PortForwardingController::DeviceListChanged(
    const DevToolsAndroidBridge::CompleteDevices& complete_devices) {}

void PortForwardingController::CloseAllConnections() {}

void PortForwardingController::OnPrefsChange() {}

void PortForwardingController::UpdateConnections() {}