Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/indexedDB/IndexedDatabaseInlines.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef IndexedDatabaseInlines_h
8
#define IndexedDatabaseInlines_h
9
10
#ifndef mozilla_dom_indexeddatabase_h__
11
#error Must include IndexedDatabase.h first
12
#endif
13
14
#include "FileInfo.h"
15
#include "IDBMutableFile.h"
16
#include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
17
#include "mozilla/dom/File.h"
18
#include "nsIInputStream.h"
19
20
namespace mozilla {
21
namespace dom {
22
namespace indexedDB {
23
24
inline
25
StructuredCloneFile::StructuredCloneFile()
26
  : mType(eBlob)
27
0
{
28
0
  MOZ_COUNT_CTOR(StructuredCloneFile);
29
0
}
30
31
inline
32
StructuredCloneFile::~StructuredCloneFile()
33
0
{
34
0
  MOZ_COUNT_DTOR(StructuredCloneFile);
35
0
}
36
37
inline
38
bool
39
StructuredCloneFile::operator==(const StructuredCloneFile& aOther) const
40
0
{
41
0
  return this->mBlob == aOther.mBlob &&
42
0
         this->mMutableFile == aOther.mMutableFile &&
43
0
         this->mFileInfo == aOther.mFileInfo &&
44
0
         this->mType == aOther.mType;
45
0
}
46
47
inline
48
StructuredCloneReadInfo::StructuredCloneReadInfo(JS::StructuredCloneScope aScope)
49
  : mData(aScope)
50
  , mDatabase(nullptr)
51
  , mHasPreprocessInfo(false)
52
0
{
53
0
  MOZ_COUNT_CTOR(StructuredCloneReadInfo);
54
0
}
55
56
inline
57
StructuredCloneReadInfo::StructuredCloneReadInfo()
58
 : StructuredCloneReadInfo(JS::StructuredCloneScope::DifferentProcessForIndexedDB)
59
0
{
60
0
}
61
62
inline
63
StructuredCloneReadInfo::StructuredCloneReadInfo(
64
                             StructuredCloneReadInfo&& aCloneReadInfo)
65
  : mData(std::move(aCloneReadInfo.mData))
66
0
{
67
0
  MOZ_ASSERT(&aCloneReadInfo != this);
68
0
  MOZ_COUNT_CTOR(StructuredCloneReadInfo);
69
0
70
0
  mFiles.Clear();
71
0
  mFiles.SwapElements(aCloneReadInfo.mFiles);
72
0
  mDatabase = aCloneReadInfo.mDatabase;
73
0
  aCloneReadInfo.mDatabase = nullptr;
74
0
  mHasPreprocessInfo = aCloneReadInfo.mHasPreprocessInfo;
75
0
  aCloneReadInfo.mHasPreprocessInfo = false;
76
0
}
77
78
inline
79
StructuredCloneReadInfo::StructuredCloneReadInfo(
80
                             SerializedStructuredCloneReadInfo&& aCloneReadInfo)
81
  : mData(std::move(aCloneReadInfo.data().data))
82
  , mDatabase(nullptr)
83
  , mHasPreprocessInfo(aCloneReadInfo.hasPreprocessInfo())
84
0
{
85
0
  MOZ_COUNT_CTOR(StructuredCloneReadInfo);
86
0
}
87
88
inline
89
StructuredCloneReadInfo::~StructuredCloneReadInfo()
90
0
{
91
0
  MOZ_COUNT_DTOR(StructuredCloneReadInfo);
92
0
}
93
94
inline StructuredCloneReadInfo&
95
StructuredCloneReadInfo::operator=(StructuredCloneReadInfo&& aCloneReadInfo)
96
0
{
97
0
  MOZ_ASSERT(&aCloneReadInfo != this);
98
0
99
0
  mData = std::move(aCloneReadInfo.mData);
100
0
  mFiles.Clear();
101
0
  mFiles.SwapElements(aCloneReadInfo.mFiles);
102
0
  mDatabase = aCloneReadInfo.mDatabase;
103
0
  aCloneReadInfo.mDatabase = nullptr;
104
0
  mHasPreprocessInfo = aCloneReadInfo.mHasPreprocessInfo;
105
0
  aCloneReadInfo.mHasPreprocessInfo = false;
106
0
  return *this;
107
0
}
108
109
inline size_t
110
StructuredCloneReadInfo::Size() const
111
0
{
112
0
  size_t size = mData.Size();
113
0
114
0
  for (uint32_t i = 0, count = mFiles.Length(); i < count; ++i) {
115
0
    // We don't want to calculate the size of files and so on, because are mainly
116
0
    // file descriptors.
117
0
    size += sizeof(uint64_t);
118
0
  }
119
0
120
0
  return size;
121
0
}
122
123
} // namespace indexedDB
124
} // namespace dom
125
} // namespace mozilla
126
127
#endif // IndexedDatabaseInlines_h