diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 9bd9a46bb58b..071988105ac6 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -337,27 +337,31 @@ nsresult nsHttpHandler::Init() { Telemetry::ScalarSet(Telemetry::ScalarID::NETWORKING_HTTPS_RR_PREFS_USAGE, static_cast(usageOfHTTPSRRPrefs.to_ulong())); mActivityDistributor = components::HttpActivityDistributor::Service(); + + auto initQLogDir = [&]() { + if (!StaticPrefs::network_http_http3_enable_qlog()) { + return EmptyCString(); + } + + nsCOMPtr qlogDir; + nsresult rv = + NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(qlogDir)); + if (NS_WARN_IF(NS_FAILED(rv))) { + return EmptyCString(); + } + + nsAutoCString dirName("qlog_"); + dirName.AppendInt(mProcessId); + rv = qlogDir->AppendNative(dirName); + if (NS_WARN_IF(NS_FAILED(rv))) { + return EmptyCString(); + } + + return qlogDir->HumanReadablePath(); + }; + mHttp3QlogDir = initQLogDir(); } - auto initQLogDir = [&]() { - nsCOMPtr qlogDir; - nsresult rv = - NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(qlogDir)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return EmptyCString(); - } - - nsAutoCString dirName("qlog_"); - dirName.AppendInt(mProcessId); - rv = qlogDir->AppendNative(dirName); - if (NS_WARN_IF(NS_FAILED(rv))) { - return EmptyCString(); - } - - return qlogDir->HumanReadablePath(); - }; - mHttp3QlogDir = initQLogDir(); - // monitor some preference changes Preferences::RegisterPrefixCallbacks(nsHttpHandler::PrefsChanged, gCallbackPrefs, this);