/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
// Const variable for generate padding size // XXX This will be tweaked to something more meaningful in Bug 1383656. const uint32_t kMaxRandomNumber = 102400;
response->SetURLList(aIPCResponse.metadata().urlList());
response->mHeaders = new InternalHeaders(aIPCResponse.metadata().headers(),
aIPCResponse.metadata().headersGuard());
if (aIPCResponse.body()) { auto bodySize = aIPCResponse.bodySize(); auto body = ToInputStream(*aIPCResponse.body());
response->SetBody(body.get(), bodySize);
}
if (aIPCResponse.alternativeBody()) { auto alternativeBody = ToInputStream(*aIPCResponse.alternativeBody());
response->SetAlternativeBody(alternativeBody.get());
}
// Note: all the arguments are copied rather than moved, which would be more // efficient, because there's no move-friendly constructor generated.
nsCOMPtr<nsITransportSecurityInfo> securityInfo(mChannelInfo.SecurityInfo()); return InternalResponseMetadata(
mType, GetUnfilteredURLList(), GetUnfilteredStatus(),
GetUnfilteredStatusText(), headersGuard, headers, mErrorCode,
GetAlternativeDataType(), securityInfo, principalInfo, bodyBlobURISpec,
bodyLocalPath, GetCredentialsMode());
}
if (body) {
ParentToChildStream bodyStream =
ToParentToChildStream(WrapNotNull(body), bodySize, mSerializeAsLazy); // The body stream can fail to serialize as an IPCStream. In the case, the // IPCStream's type would be T__None. Don't set up IPCInternalResponse's // body with the failed IPCStream. if (mSerializeAsLazy || bodyStream.get_IPCStream().stream().type() !=
mozilla::ipc::InputStreamParams::T__None) {
result.body() = Some(bodyStream);
result.bodySize() = bodySize;
}
}
nsCOMPtr<nsIInputStream> alternativeBody = TakeAlternativeBody(); if (alternativeBody) {
ParentToChildStream alterBodyStream = ToParentToChildStream(
WrapNotNull(alternativeBody), UNKNOWN_BODY_SIZE, mSerializeAsLazy); // The body stream can fail to serialize as an IPCStream. In the case, the // IPCStream's type would be T__None. Don't set up IPCInternalResponse's // body with the failed IPCStream. if (mSerializeAsLazy || alterBodyStream.get_IPCStream().stream().type() !=
mozilla::ipc::InputStreamParams::T__None) {
result.alternativeBody() = Some(alterBodyStream);
}
}
uint32_t InternalResponse::GetPaddingInfo() { // If it's an opaque response, the paddingInfo should be generated only when // paddingSize is unknown size. // If it's not, the paddingInfo should be nothing and the paddingSize should // be unknown size.
MOZ_DIAGNOSTIC_ASSERT(
(mType == ResponseType::Opaque && mPaddingSize == UNKNOWN_PADDING_SIZE &&
mPaddingInfo.isSome()) ||
(mType == ResponseType::Opaque && mPaddingSize != UNKNOWN_PADDING_SIZE &&
mPaddingInfo.isNothing()) ||
(mType != ResponseType::Opaque && mPaddingSize == UNKNOWN_PADDING_SIZE &&
mPaddingInfo.isNothing())); return mPaddingInfo.isSome() ? mPaddingInfo.ref() : 0;
}
int64_t InternalResponse::GetPaddingSize() { // We initialize padding size to an unknown size (-1). After cached, we only // pad opaque response. Opaque response's padding size might be unknown before // cached.
MOZ_DIAGNOSTIC_ASSERT(mType == ResponseType::Opaque ||
mPaddingSize == UNKNOWN_PADDING_SIZE);
MOZ_DIAGNOSTIC_ASSERT(mPaddingSize == UNKNOWN_PADDING_SIZE ||
mPaddingSize >= 0);
return mPaddingSize;
}
void InternalResponse::SetPaddingSize(int64_t aPaddingSize) { // We should only pad the opaque response.
MOZ_DIAGNOSTIC_ASSERT(
(mType == ResponseType::Opaque) !=
(aPaddingSize == InternalResponse::UNKNOWN_PADDING_SIZE));
MOZ_DIAGNOSTIC_ASSERT(aPaddingSize == UNKNOWN_PADDING_SIZE ||
aPaddingSize >= 0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.