summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol/http/AltSvcTransactionChild.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /netwerk/protocol/http/AltSvcTransactionChild.cpp
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--netwerk/protocol/http/AltSvcTransactionChild.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/netwerk/protocol/http/AltSvcTransactionChild.cpp b/netwerk/protocol/http/AltSvcTransactionChild.cpp
new file mode 100644
index 0000000000..096d584c0e
--- /dev/null
+++ b/netwerk/protocol/http/AltSvcTransactionChild.cpp
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// HttpLog.h should generally be included first
+#include "HttpLog.h"
+
+#include "AltSvcTransactionChild.h"
+#include "AlternateServices.h"
+#include "nsHttpConnectionInfo.h"
+
+namespace mozilla {
+namespace net {
+
+AltSvcTransactionChild::AltSvcTransactionChild(nsHttpConnectionInfo* aConnInfo,
+ uint32_t aCaps)
+ : mConnInfo(aConnInfo), mCaps(aCaps) {
+ LOG(("AltSvcTransactionChild %p ctor", this));
+}
+
+AltSvcTransactionChild::~AltSvcTransactionChild() {
+ LOG(("AltSvcTransactionChild %p dtor", this));
+}
+
+void AltSvcTransactionChild::OnTransactionDestroy(bool aValidateResult) {
+ LOG(("AltSvcTransactionChild::OnTransactionDestroy %p aValidateResult=%d",
+ this, aValidateResult));
+ RefPtr<AltSvcTransactionChild> self = this;
+ auto task = [self, aValidateResult]() {
+ if (self->CanSend()) {
+ self->Send__delete__(self, aValidateResult);
+ }
+ };
+ if (!NS_IsMainThread()) {
+ NS_DispatchToMainThread(
+ NS_NewRunnableFunction("AltSvcTransactionChild::OnTransactionClose",
+ std::move(task)),
+ NS_DISPATCH_NORMAL);
+ return;
+ }
+
+ task();
+}
+
+void AltSvcTransactionChild::OnTransactionClose(bool aValidateResult) {
+ LOG(("AltSvcTransactionChild::OnTransactionClose %p aValidateResult=%d", this,
+ aValidateResult));
+ RefPtr<AltSvcTransactionChild> self = this;
+ auto task = [self, aValidateResult]() {
+ if (self->CanSend()) {
+ self->SendOnTransactionClose(aValidateResult);
+ }
+ };
+ if (!NS_IsMainThread()) {
+ NS_DispatchToMainThread(
+ NS_NewRunnableFunction("AltSvcTransactionChild::OnTransactionClose",
+ std::move(task)),
+ NS_DISPATCH_NORMAL);
+ return;
+ }
+
+ task();
+}
+
+already_AddRefed<SpeculativeTransaction>
+AltSvcTransactionChild::CreateTransaction() {
+ RefPtr<SpeculativeTransaction> transaction =
+ new AltSvcTransaction<AltSvcTransactionChild>(mConnInfo, nullptr, mCaps,
+ this, mConnInfo->IsHttp3());
+ return transaction.forget();
+}
+
+} // namespace net
+} // namespace mozilla