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

#include "third_party/blink/renderer/modules/webtransport/web_transport_send_group.h"

#include "third_party/blink/renderer/bindings/modules/v8/v8_web_transport_send_stream_stats.h"
#include "third_party/blink/renderer/modules/webtransport/web_transport.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"

namespace blink {

WebTransportSendGroup::WebTransportSendGroup(WebTransport* transport,
                                             uint32_t group_id)
    : transport_(transport), group_id_(group_id) {}

WebTransportSendGroup::~WebTransportSendGroup() = default;

ScriptPromise<WebTransportSendStreamStats> WebTransportSendGroup::getStats(
    ScriptState* script_state) {
  // TODO(crbug.com/430125723): Implement actual stats collection from the
  // network service. For now, return a resolved promise with zeroed stats.
  auto* stats = MakeGarbageCollected<WebTransportSendStreamStats>();
  stats->setBytesWritten(0);
  stats->setBytesSent(0);
  stats->setBytesAcknowledged(0);
  return ToResolvedPromise<WebTransportSendStreamStats>(script_state, stats);
}

void WebTransportSendGroup::Trace(Visitor* visitor) const {
  visitor->Trace(transport_);
  ScriptWrappable::Trace(visitor);
}

}  // namespace blink
