Bug 1734573 - Add a new activity type to report proxy response header, r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D127824
This commit is contained in:
Kershaw Chang 2021-10-26 19:39:27 +00:00
Родитель 55472298f9
Коммит 6f8690e393
2 изменённых файлов: 28 добавлений и 18 удалений

Просмотреть файл

@ -2395,18 +2395,25 @@ nsresult nsHttpTransaction::ProcessData(char* buf, uint32_t count,
if (count && bytesConsumed) memmove(buf, buf + bytesConsumed, count);
// report the completed response header
if (mActivityDistributor && mResponseHead && mHaveAllHeaders &&
!mReportedResponseHeader) {
mReportedResponseHeader = true;
nsAutoCString completeResponseHeaders;
mResponseHead->Flatten(completeResponseHeaders, false);
completeResponseHeaders.AppendLiteral("\r\n");
rv = mActivityDistributor->ObserveActivityWithArgs(
HttpActivityArgs(mChannelId), NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_HEADER, PR_Now(), 0,
completeResponseHeaders);
if (NS_FAILED(rv)) {
LOG3(("ObserveActivity failed (%08x)", static_cast<uint32_t>(rv)));
if (mActivityDistributor && mResponseHead && mHaveAllHeaders) {
auto reportResponseHeader = [&](uint32_t aSubType) {
nsAutoCString completeResponseHeaders;
mResponseHead->Flatten(completeResponseHeaders, false);
completeResponseHeaders.AppendLiteral("\r\n");
rv = mActivityDistributor->ObserveActivityWithArgs(
HttpActivityArgs(mChannelId),
NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION, aSubType, PR_Now(), 0,
completeResponseHeaders);
if (NS_FAILED(rv)) {
LOG3(("ObserveActivity failed (%08x)", static_cast<uint32_t>(rv)));
}
};
if (mConnection->IsProxyConnectInProgress()) {
reportResponseHeader(NS_HTTP_ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER);
} else if (!mReportedResponseHeader) {
mReportedResponseHeader = true;
reportResponseHeader(NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_HEADER);
}
}
}

Просмотреть файл

@ -97,12 +97,13 @@ interface nsIHttpActivityObserver : nsISupports
const unsigned long ACTIVITY_TYPE_SOCKET_TRANSPORT = 0x0001;
const unsigned long ACTIVITY_TYPE_HTTP_TRANSACTION = 0x0002;
const unsigned long ACTIVITY_SUBTYPE_REQUEST_HEADER = 0x5001;
const unsigned long ACTIVITY_SUBTYPE_REQUEST_BODY_SENT = 0x5002;
const unsigned long ACTIVITY_SUBTYPE_RESPONSE_START = 0x5003;
const unsigned long ACTIVITY_SUBTYPE_RESPONSE_HEADER = 0x5004;
const unsigned long ACTIVITY_SUBTYPE_RESPONSE_COMPLETE = 0x5005;
const unsigned long ACTIVITY_SUBTYPE_TRANSACTION_CLOSE = 0x5006;
const unsigned long ACTIVITY_SUBTYPE_REQUEST_HEADER = 0x5001;
const unsigned long ACTIVITY_SUBTYPE_REQUEST_BODY_SENT = 0x5002;
const unsigned long ACTIVITY_SUBTYPE_RESPONSE_START = 0x5003;
const unsigned long ACTIVITY_SUBTYPE_RESPONSE_HEADER = 0x5004;
const unsigned long ACTIVITY_SUBTYPE_RESPONSE_COMPLETE = 0x5005;
const unsigned long ACTIVITY_SUBTYPE_TRANSACTION_CLOSE = 0x5006;
const unsigned long ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER = 0x5007;
/**
* When aActivityType is ACTIVITY_TYPE_SOCKET_TRANSPORT
@ -145,6 +146,8 @@ interface nsIHttpActivityObserver : nsISupports
nsIHttpActivityObserver::ACTIVITY_SUBTYPE_RESPONSE_COMPLETE
#define NS_HTTP_ACTIVITY_SUBTYPE_TRANSACTION_CLOSE \
nsIHttpActivityObserver::ACTIVITY_SUBTYPE_TRANSACTION_CLOSE
#define NS_HTTP_ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER \
nsIHttpActivityObserver::ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER
%}