Bug 1866894 - Update failing subtest for content-visibility-auto-resize.html. r=fredw
[gecko.git] / dom / file / BaseBlobImpl.cpp
blob5871b9da047b25d2c3a475195a47a9805f1f75db
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/BaseBlobImpl.h"
8 #include "mozilla/dom/BindingDeclarations.h"
9 #include "nsRFPService.h"
10 #include "prtime.h"
12 namespace mozilla::dom {
14 void BaseBlobImpl::GetName(nsAString& aName) const {
15 MOZ_ASSERT(mIsFile, "Should only be called on files");
16 aName = mName;
19 void BaseBlobImpl::GetDOMPath(nsAString& aPath) const {
20 MOZ_ASSERT(mIsFile, "Should only be called on files");
21 aPath = mPath;
24 void BaseBlobImpl::SetDOMPath(const nsAString& aPath) {
25 MOZ_ASSERT(mIsFile, "Should only be called on files");
26 mPath = aPath;
29 void BaseBlobImpl::GetMozFullPath(nsAString& aFileName,
30 SystemCallerGuarantee /* unused */,
31 ErrorResult& aRv) {
32 MOZ_ASSERT(mIsFile, "Should only be called on files");
34 GetMozFullPathInternal(aFileName, aRv);
37 void BaseBlobImpl::GetMozFullPathInternal(nsAString& aFileName,
38 ErrorResult& aRv) {
39 if (!mIsFile) {
40 aRv.Throw(NS_ERROR_FAILURE);
41 return;
44 aFileName.Truncate();
47 void BaseBlobImpl::GetType(nsAString& aType) { aType = mContentType; }
49 int64_t BaseBlobImpl::GetLastModified(ErrorResult& aRv) {
50 MOZ_ASSERT(mIsFile, "Should only be called on files");
51 return mLastModificationDate / PR_USEC_PER_MSEC;
54 int64_t BaseBlobImpl::GetFileId() const { return -1; }
56 /* static */
57 uint64_t BaseBlobImpl::NextSerialNumber() {
58 static Atomic<uint64_t> nextSerialNumber;
59 return nextSerialNumber++;
62 void BaseBlobImpl::SetLastModificationDatePrecisely(int64_t aDate) {
63 MOZ_ASSERT(mIsFile, "Should only be called on files");
64 mLastModificationDate = aDate;
67 void BaseBlobImpl::SetLastModificationDate(RTPCallerType aRTPCallerType,
68 int64_t aDate) {
69 return SetLastModificationDatePrecisely(
70 nsRFPService::ReduceTimePrecisionAsUSecs(aDate, 0, aRTPCallerType));
71 // mLastModificationDate is an absolute timestamp so we supply a zero
72 // context mix-in
75 } // namespace mozilla::dom