Files
sousa-gecko/netwerk/base/ContentRange.h
T
Emilio Cobos Álvarez abbeff4fd9 Bug 2054311 - Sort headers in netwerk/. r=webrtc-reviewers,cookie-reviewers,mjf,timhuang
Autogenerated with:

    cp dom/.clang-format netwerk/ && mach format netwerk/**.{cpp,h,mm}

Manual fixes:

 * mozurl/cbindgen.toml (including headers earlier)
 * NetlinkService.h (forward-declaring a necessary struct)
 * nsIWebSocketChannel.idl (forward-declaring OriginAttributes).
 * nsAsyncRedirectVerifyHelper.h (forward-declaring nsIEventTarget)
 * CapsuleEncoder.h gets a missing Capsule forward-decl.
 * WebSocketConnectionBase.h gets some missing includes.
 * HappyEyeballsConnectionAttempt gets some missing includes.
 * nsUDPSocket missed nsSocketTransportService2.h for OnSocketThread().
 * HttpInfo missed a forward declaration.
 * MockHttpAuth missed an nsCOMPtr include.
 * nsHttpAuthManager missed a forward declaration for nsIHttpAuthCache.
 * WebTransportSessionProxy was using mozilla::Mutex in a member without
   including it.
 * win32 fixes to keep include order because windows headers suck.
 * nsInputStreamPump needs an Atomics.h include.

Differential Revision: https://phabricator.services.mozilla.com/D311696
2026-07-13 09:55:57 +00:00

44 lines
1.4 KiB
C++

/* 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/. */
#ifndef ContentRange_h_
#define ContentRange_h_
#include "nsContentUtils.h"
#include "nsISupportsImpl.h"
#include "nsString.h"
// nsIBaseChannel subclasses may support range headers when accessed via
// Fetch or XMLHTTPRequest, even if they are not HTTP assets and so do not
// normally have access to headers (such as the blob URLs). The ContentRange
// class helps to encapsulate much of the common logic involved in parsing,
// storing, validating, and writing out Content-Range headers.
namespace mozilla::net {
class ContentRange {
private:
~ContentRange() = default;
uint64_t mStart{0};
uint64_t mEnd{0};
uint64_t mSize{0};
public:
uint64_t Start() const { return mStart; }
uint64_t End() const { return mEnd; }
uint64_t Size() const { return mSize; }
bool IsValid() const { return mStart < mSize; }
ContentRange(uint64_t aStart, uint64_t aEnd, uint64_t aSize)
: mStart(aStart), mEnd(aEnd), mSize(aSize) {}
ContentRange(const nsContentUtils::ParsedRange& aRangeHeader, uint64_t aSize);
void AsHeader(nsACString& aOutString) const;
NS_INLINE_DECL_REFCOUNTING(ContentRange)
};
} // namespace mozilla::net
#endif // ContentRange_h_