Backed out 3 changesets (bug 1734132) for causing hybrid/build bustages on Http3Stream.cpp CLOSED TREE

Backed out changeset 51a131c3817b (bug 1734132)
Backed out changeset aee682c3af71 (bug 1734132)
Backed out changeset 51ba73eb5bc2 (bug 1734132)
This commit is contained in:
Cristian Tuns 2021-11-17 11:55:11 -05:00
parent 21081ecb3b
commit acd5a045f9
10 changed files with 8 additions and 339 deletions

View File

@ -10119,23 +10119,6 @@
value: 12582912
mirror: always
# Enable http3 network priorization as described in
# https://httpwg.org/http-extensions/draft-ietf-httpbis-priority.html
- name: network.http.http3.priorization
type: RelaxedAtomicBool
value: true
mirror: always
# Depriorizing background tabs notifies websites when switching to or from the
# tab while still loading resources for the website. On one hand it might
# improve performance when switching to an tab with a website using the same
# QUIC connection. On the other hand it sends more data to the website and
# might be a privacy concern.
- name: network.http.http3.send_background_tabs_depriorization
type: RelaxedAtomicBool
value: false
mirror: always
# When true, a http request will be upgraded to https when HTTPS RR is
# available.
- name: network.dns.upgrade_with_https_rr

View File

@ -180,13 +180,6 @@ void Http3Session::DoSetEchConfig(const nsACString& aEchConfig) {
}
}
nsresult Http3Session::SendPriorityUpdateFrame(uint64_t aStreamId,
uint8_t aPriorityUrgency,
bool aPriorityIncremental) {
return mHttp3Connection->PriorityUpdate(aStreamId, aPriorityUrgency,
aPriorityIncremental);
}
// Shutdown the http3session and close all transactions.
void Http3Session::Shutdown() {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
@ -741,14 +734,8 @@ bool Http3Session::AddStream(nsAHttpTransaction* aHttpTransaction,
// reset the read timers to wash away any idle time
mLastWriteTime = PR_IntervalNow();
uint32_t cos = 0;
if (trans) {
cos = trans->ClassOfService();
}
LOG3(("Http3Session::AddStream %p atrans=%p.\n", this, aHttpTransaction));
Http3Stream* stream = new Http3Stream(aHttpTransaction, this, cos,
mCurrentTopBrowsingContextId);
Http3Stream* stream = new Http3Stream(aHttpTransaction, this);
mStreamTransactionHash.InsertOrUpdate(aHttpTransaction, RefPtr{stream});
if (mState == ZERORTT) {
@ -852,9 +839,8 @@ nsresult Http3Session::TryActivating(
}
}
nsresult rv = mHttp3Connection->Fetch(
aMethod, aScheme, aAuthorityHeader, aPath, aHeaders, aStreamId,
aStream->PriorityUrgency(), aStream->PriorityIncremental());
nsresult rv = mHttp3Connection->Fetch(aMethod, aScheme, aAuthorityHeader,
aPath, aHeaders, aStreamId, 3, false);
if (NS_FAILED(rv)) {
LOG(("Http3Session::TryActivating returns error=0x%" PRIx32 "[stream=%p, "
"this=%p]",

View File

@ -102,9 +102,6 @@ class Http3Session final : public nsAHttpTransaction, public nsAHttpConnection {
void DoSetEchConfig(const nsACString& aEchConfig);
nsresult SendPriorityUpdateFrame(uint64_t aStreamId, uint8_t aPriorityUrgency,
bool aPriorityIncremental);
private:
~Http3Session();

View File

@ -9,8 +9,6 @@
#include "Http3Session.h"
#include "Http3Stream.h"
#include "nsHttpRequestHead.h"
#include "nsHttpTransaction.h"
#include "nsIClassOfService.h"
#include "nsISocketTransport.h"
#include "nsSocketTransportService2.h"
#include "mozilla/Telemetry.h"
@ -23,19 +21,10 @@ namespace mozilla {
namespace net {
Http3Stream::Http3Stream(nsAHttpTransaction* httpTransaction,
Http3Session* session, uint32_t aCos, uint64_t bcId)
: mSession(session),
mTransaction(httpTransaction),
mCurrentTopBrowsingContextId(bcId) {
Http3Session* session)
: mSession(session), mTransaction(httpTransaction) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http3Stream::Http3Stream [this=%p]", this));
nsHttpTransaction* trans = mTransaction->QueryHttpTransaction();
if (trans) {
mTransactionTabId = trans->TopBrowsingContextId();
}
SetPriority(aCos);
}
void Http3Stream::Close(nsresult aResult) {
@ -113,31 +102,6 @@ void Http3Stream::FindRequestContentLength() {
}
}
void Http3Stream::SetPriority(uint32_t aCos) {
if (aCos & nsIClassOfService::UrgentStart) {
// coming from an user interaction => response should be the highest
// priority
mPriorityUrgency = 1;
} else if (aCos & nsIClassOfService::Leader) {
// main html document normal priority
mPriorityUrgency = 2;
} else if (aCos & nsIClassOfService::Unblocked) {
mPriorityUrgency = 3;
} else if (aCos & nsIClassOfService::Follower) {
mPriorityUrgency = 4;
} else if (aCos & nsIClassOfService::Speculative) {
mPriorityUrgency = 6;
} else if (aCos & nsIClassOfService::Background) {
// background tasks can be deprioritzed to the lowest priority
mPriorityUrgency = 6;
} else if (aCos & nsIClassOfService::Tail) {
mPriorityUrgency = 6;
} else {
// all others get a lower priority than the main html document
mPriorityUrgency = 4;
}
}
nsresult Http3Stream::TryActivating() {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("Http3Stream::TryActivating [this=%p]", this));
@ -161,22 +125,6 @@ nsresult Http3Stream::TryActivating() {
mFlatHttpRequestHeaders, &mStreamId, this);
}
void Http3Stream::TopBrowsingContextIdChanged(uint64_t id) {
MOZ_ASSERT(gHttpHandler->ActiveTabPriority());
bool previouslyFocused = (mCurrentTopBrowsingContextId == mTransactionTabId);
mCurrentTopBrowsingContextId = id;
bool nowFocused = (mCurrentTopBrowsingContextId == mTransactionTabId);
if (!StaticPrefs::network_http_http3_send_background_tabs_depriorization() ||
previouslyFocused == nowFocused) {
return;
}
mSession->SendPriorityUpdateFrame(mStreamId, PriorityUrgency(),
PriorityIncremental());
}
nsresult Http3Stream::OnReadSegment(const char* buf, uint32_t count,
uint32_t* countRead) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
@ -528,27 +476,5 @@ nsresult Http3Stream::Finish0RTT(bool aRestart) {
return rv;
}
uint8_t Http3Stream::PriorityUrgency() {
if (!StaticPrefs::network_http_http3_priorization()) {
// send default priorization which is equivalent to sending no priorization
return 3;
}
if (StaticPrefs::network_http_http3_send_background_tabs_depriorization() &&
mCurrentTopBrowsingContextId != mTransactionTabId) {
// Low priority
return 6;
}
return mPriorityUrgency;
}
bool Http3Stream::PriorityIncremental() {
if (!StaticPrefs::network_http_http3_priorization()) {
// send default priorization which is equivalent to sending no priorization
return false;
}
return mPriorityIncremental;
}
} // namespace net
} // namespace mozilla

View File

@ -25,14 +25,15 @@ class Http3Stream final : public nsAHttpSegmentReader,
// for RefPtr
NS_INLINE_DECL_REFCOUNTING(Http3Stream, override)
Http3Stream(nsAHttpTransaction*, Http3Session*, uint32_t, uint64_t);
Http3Stream(nsAHttpTransaction* httpTransaction, Http3Session* session);
bool HasStreamId() const { return mStreamId != UINT64_MAX; }
uint64_t StreamId() const { return mStreamId; }
nsresult TryActivating();
void TopBrowsingContextIdChanged(uint64_t id);
// TODO priorities
void TopBrowsingContextIdChanged(uint64_t id){};
[[nodiscard]] nsresult ReadSegments(nsAHttpSegmentReader*);
[[nodiscard]] nsresult WriteSegments(nsAHttpSegmentWriter*, uint32_t,
@ -59,9 +60,6 @@ class Http3Stream final : public nsAHttpSegmentReader,
bool Do0RTT();
nsresult Finish0RTT(bool aRestart);
uint8_t PriorityUrgency();
bool PriorityIncremental();
private:
~Http3Stream() = default;
@ -69,8 +67,6 @@ class Http3Stream final : public nsAHttpSegmentReader,
nsresult StartRequest();
void FindRequestContentLength();
void SetPriority(uint32_t aCos);
/**
* SendStreamState:
* While sending request:
@ -138,10 +134,6 @@ class Http3Stream final : public nsAHttpSegmentReader,
bool mResetRecv{false};
nsTArray<uint8_t> mFlatResponseHeaders;
uint32_t mRequestBodyLenRemaining{0};
uint64_t mTransactionTabId{0};
uint64_t mCurrentTopBrowsingContextId;
uint8_t mPriorityUrgency{3}; // urgency field of http priority
bool mPriorityIncremental{false};
// For Progress Events
uint64_t mTotalSent{0};

View File

@ -62,12 +62,6 @@ class NeqoHttp3Conn final {
&aHeaders, aStreamId, aUrgency, aIncremental);
}
nsresult PriorityUpdate(uint64_t aStreamId, uint8_t aUrgency,
bool aIncremental) {
return neqo_http3conn_priority_update(this, aStreamId, aUrgency,
aIncremental);
}
nsresult SendRequestBody(uint64_t aStreamId, const uint8_t* aBuf,
uint32_t aCount, uint32_t* aCountRead) {
return neqo_htttp3conn_send_request_body(this, aStreamId, aBuf, aCount,

View File

@ -410,23 +410,6 @@ pub extern "C" fn neqo_http3conn_fetch(
}
}
#[no_mangle]
pub extern "C" fn neqo_http3conn_priority_update(
conn: &mut NeqoHttp3Conn,
stream_id: u64,
urgency: u8,
incremental: bool,
) -> nsresult {
if urgency >= 8 {
return NS_ERROR_INVALID_ARG;
}
let priority = Priority::new(urgency, incremental);
match conn.conn.priority_update(stream_id, priority) {
Ok(_) => NS_OK,
Err(_) => NS_ERROR_UNEXPECTED,
}
}
#[no_mangle]
pub extern "C" fn neqo_htttp3conn_send_request_body(
conn: &mut NeqoHttp3Conn,

View File

@ -202,36 +202,6 @@ impl HttpServer for Http3TestServer {
} else if path == "/post" {
// Read all data before responding.
self.posts.insert(request, 0);
} else if path == "/priority_mirror" {
if let Some(priority) =
headers.iter().find(|h| h.name() == "priority")
{
request
.set_response(
&[
Header::new(":status", "200"),
Header::new("cache-control", "no-cache"),
Header::new("content-type", "text/plain"),
Header::new("priority-mirror", priority.value()),
Header::new(
"content-length",
priority.value().len().to_string(),
),
],
priority.value().as_bytes(),
)
.unwrap();
} else {
request
.set_response(
&[
Header::new(":status", "200"),
Header::new("cache-control", "no-cache"),
],
&[],
)
.unwrap();
}
} else {
match path.trim_matches(|p| p == '/').parse::<usize>() {
Ok(v) => request

View File

@ -1,157 +0,0 @@
/* 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/. */
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.ssl_tokens_cache_enabled");
http3_clear_prefs();
});
add_task(async function setup() {
await http3_setup_tests("h3-29");
});
let Http3Listener = function(closure, expected_priority, context) {
this._closure = closure;
this._expected_priority = expected_priority;
this._context = context;
};
Http3Listener.prototype = {
resumed: false,
onStartRequest: function testOnStartRequest(request) {
Assert.equal(request.status, Cr.NS_OK);
Assert.equal(request.responseStatus, 200);
let secinfo = request.securityInfo;
secinfo.QueryInterface(Ci.nsITransportSecurityInfo);
Assert.equal(secinfo.resumed, this.resumed);
Assert.ok(secinfo.serverCert != null);
let priority = null;
try {
priority = request.getResponseHeader("priority-mirror");
} catch (e) {}
Assert.equal(priority, this._expected_priority, this._context);
},
onDataAvailable: function testOnDataAvailable(request, stream, off, cnt) {
read_stream(stream, cnt);
},
onStopRequest: function testOnStopRequest(request, status) {
let httpVersion = "";
try {
httpVersion = request.protocolVersion;
} catch (e) {}
Assert.equal(httpVersion, "h3-29");
try {
this._closure();
} catch (ex) {
do_throw("Error in closure function: " + ex);
}
},
};
function make_channel(url) {
var request = NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true,
});
request.QueryInterface(Ci.nsIHttpChannel);
return request;
}
async function test_flag_priority(context, flag, expected_priority) {
var chan = make_channel("https://foo.example.com/priority_mirror");
var cos = chan.QueryInterface(Ci.nsIClassOfService);
if (flag != null) {
cos.addClassFlags(flag);
}
await new Promise(resolve =>
chan.asyncOpen(new Http3Listener(resolve, expected_priority, context))
);
}
add_task(async function test_http3_prio() {
Services.prefs.setBoolPref("network.http.http3.priorization", false);
await test_flag_priority("disabled (none)", null, null);
await test_flag_priority(
"disabled (urgent_start)",
Ci.nsIClassOfService.UrgentStart,
null
);
await test_flag_priority(
"disabled (leader)",
Ci.nsIClassOfService.Leader,
null
);
await test_flag_priority(
"disabled (unblocked)",
Ci.nsIClassOfService.Unblocked,
null
);
await test_flag_priority(
"disabled (follower)",
Ci.nsIClassOfService.Follower,
null
);
await test_flag_priority(
"disabled (speculative)",
Ci.nsIClassOfService.Speculative,
null
);
await test_flag_priority(
"disabled (background)",
Ci.nsIClassOfService.Background,
null
);
await test_flag_priority(
"disabled (background)",
Ci.nsIClassOfService.Tail,
null
);
});
add_task(async function test_http3_prio_enabled() {
Services.prefs.setBoolPref("network.http.http3.priorization", true);
await test_flag_priority("enabled (none)", null, "u=4");
await test_flag_priority(
"enabled (urgent_start)",
Ci.nsIClassOfService.UrgentStart,
"u=1"
);
await test_flag_priority(
"enabled (leader)",
Ci.nsIClassOfService.Leader,
"u=2"
);
await test_flag_priority(
"enabled (unblocked)",
Ci.nsIClassOfService.Unblocked,
null
);
await test_flag_priority(
"enabled (follower)",
Ci.nsIClassOfService.Follower,
"u=4"
);
await test_flag_priority(
"enabled (speculative)",
Ci.nsIClassOfService.Speculative,
"u=6"
);
await test_flag_priority(
"enabled (background)",
Ci.nsIClassOfService.Background,
"u=6"
);
await test_flag_priority(
"enabled (background)",
Ci.nsIClassOfService.Tail,
"u=6"
);
});

View File

@ -441,11 +441,6 @@ skip-if =
tsan
os =='android'
run-sequentially = http3server
[test_http3_prio.js]
skip-if =
tsan
os == 'android'
run-sequentially = http3server
[test_node_execute.js]
[test_loadgroup_cancel.js]
[test_obs-fold.js]