2012-06-01 21:21:12 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-06-01 21:21:12 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2013-12-09 09:31:48 +04:00
|
|
|
#ifndef IndexedDatabaseInlines_h
|
|
|
|
#define IndexedDatabaseInlines_h
|
|
|
|
|
2016-02-17 00:46:08 +03:00
|
|
|
#ifndef mozilla_dom_indexeddatabase_h__
|
2012-06-01 21:21:12 +04:00
|
|
|
# error Must include IndexedDatabase.h first
|
|
|
|
#endif
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "FileInfo.h"
|
2015-09-09 14:15:05 +03:00
|
|
|
#include "IDBMutableFile.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
|
2014-10-08 20:15:23 +04:00
|
|
|
#include "mozilla/dom/File.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "nsIInputStream.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
inline StructuredCloneFile::StructuredCloneFile() : mType(eBlob) {
|
|
|
|
MOZ_COUNT_CTOR(StructuredCloneFile);
|
2012-06-03 20:33:52 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
inline StructuredCloneFile::~StructuredCloneFile() {
|
|
|
|
MOZ_COUNT_DTOR(StructuredCloneFile);
|
2014-02-01 06:50:07 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
inline bool StructuredCloneFile::operator==(
|
|
|
|
const StructuredCloneFile& aOther) const {
|
2015-05-12 15:09:51 +03:00
|
|
|
return this->mBlob == aOther.mBlob &&
|
2015-09-09 14:15:05 +03:00
|
|
|
this->mMutableFile == aOther.mMutableFile &&
|
|
|
|
this->mFileInfo == aOther.mFileInfo && this->mType == aOther.mType;
|
2014-09-13 20:12:19 +04:00
|
|
|
}
|
|
|
|
|
2018-04-03 21:17:33 +03:00
|
|
|
inline StructuredCloneReadInfo::StructuredCloneReadInfo(
|
|
|
|
JS::StructuredCloneScope aScope)
|
2016-10-26 07:51:33 +03:00
|
|
|
: mData(aScope), mDatabase(nullptr), mHasPreprocessInfo(false) {
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_COUNT_CTOR(StructuredCloneReadInfo);
|
|
|
|
}
|
|
|
|
|
2018-04-03 21:17:33 +03:00
|
|
|
inline StructuredCloneReadInfo::StructuredCloneReadInfo()
|
|
|
|
: StructuredCloneReadInfo(
|
|
|
|
JS::StructuredCloneScope::DifferentProcessForIndexedDB) {}
|
|
|
|
|
2016-08-10 09:18:29 +03:00
|
|
|
inline StructuredCloneReadInfo::StructuredCloneReadInfo(
|
|
|
|
StructuredCloneReadInfo&& aCloneReadInfo)
|
2018-05-30 22:15:35 +03:00
|
|
|
: mData(std::move(aCloneReadInfo.mData)) {
|
2016-08-10 09:18:29 +03:00
|
|
|
MOZ_ASSERT(&aCloneReadInfo != this);
|
|
|
|
MOZ_COUNT_CTOR(StructuredCloneReadInfo);
|
|
|
|
|
|
|
|
mFiles.Clear();
|
|
|
|
mFiles.SwapElements(aCloneReadInfo.mFiles);
|
|
|
|
mDatabase = aCloneReadInfo.mDatabase;
|
|
|
|
aCloneReadInfo.mDatabase = nullptr;
|
2016-10-26 07:51:33 +03:00
|
|
|
mHasPreprocessInfo = aCloneReadInfo.mHasPreprocessInfo;
|
|
|
|
aCloneReadInfo.mHasPreprocessInfo = false;
|
2016-08-10 09:18:29 +03:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
inline StructuredCloneReadInfo::StructuredCloneReadInfo(
|
|
|
|
SerializedStructuredCloneReadInfo&& aCloneReadInfo)
|
2018-05-30 22:15:35 +03:00
|
|
|
: mData(std::move(aCloneReadInfo.data().data)),
|
2014-09-27 03:21:57 +04:00
|
|
|
mDatabase(nullptr),
|
2016-10-26 07:51:33 +03:00
|
|
|
mHasPreprocessInfo(aCloneReadInfo.hasPreprocessInfo()) {
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_COUNT_CTOR(StructuredCloneReadInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline StructuredCloneReadInfo::~StructuredCloneReadInfo() {
|
|
|
|
MOZ_COUNT_DTOR(StructuredCloneReadInfo);
|
2012-06-03 20:33:52 +04:00
|
|
|
}
|
|
|
|
|
2014-02-01 06:50:07 +04:00
|
|
|
inline StructuredCloneReadInfo& StructuredCloneReadInfo::operator=(
|
|
|
|
StructuredCloneReadInfo&& aCloneReadInfo) {
|
|
|
|
MOZ_ASSERT(&aCloneReadInfo != this);
|
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
mData = std::move(aCloneReadInfo.mData);
|
2014-02-01 06:50:07 +04:00
|
|
|
mFiles.Clear();
|
|
|
|
mFiles.SwapElements(aCloneReadInfo.mFiles);
|
|
|
|
mDatabase = aCloneReadInfo.mDatabase;
|
|
|
|
aCloneReadInfo.mDatabase = nullptr;
|
2016-10-26 07:51:33 +03:00
|
|
|
mHasPreprocessInfo = aCloneReadInfo.mHasPreprocessInfo;
|
|
|
|
aCloneReadInfo.mHasPreprocessInfo = false;
|
2014-02-01 06:50:07 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-01-27 15:40:58 +03:00
|
|
|
inline size_t StructuredCloneReadInfo::Size() const {
|
|
|
|
size_t size = mData.Size();
|
|
|
|
|
|
|
|
for (uint32_t i = 0, count = mFiles.Length(); i < count; ++i) {
|
|
|
|
// We don't want to calculate the size of files and so on, because are
|
|
|
|
// mainly file descriptors.
|
|
|
|
size += sizeof(uint64_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#endif // IndexedDatabaseInlines_h
|