Bug 1295570 - Entries API - part 2 - Rename Entry to FileSystemEntry, r=smaug

--HG--
rename : dom/filesystem/compat/Entry.cpp => dom/filesystem/compat/FileSystemEntry.cpp
rename : dom/filesystem/compat/Entry.h => dom/filesystem/compat/FileSystemEntry.h
This commit is contained in:
Andrea Marchesini 2016-08-18 09:17:25 +02:00
Родитель f0c18d080e
Коммит 94d10aeb4c
23 изменённых файлов: 80 добавлений и 78 удалений

Просмотреть файл

@ -271,7 +271,7 @@ DataTransferItem::GetAsFile(ErrorResult& aRv)
return file.forget();
}
already_AddRefed<Entry>
already_AddRefed<FileSystemEntry>
DataTransferItem::GetAsEntry(ErrorResult& aRv)
{
RefPtr<File> file = GetAsFile(aRv);
@ -309,7 +309,7 @@ DataTransferItem::GetAsEntry(ErrorResult& aRv)
}
RefPtr<FileSystem> fs = FileSystem::Create(global);
RefPtr<Entry> entry;
RefPtr<FileSystemEntry> entry;
BlobImpl* impl = file->Impl();
MOZ_ASSERT(impl);
@ -334,7 +334,7 @@ DataTransferItem::GetAsEntry(ErrorResult& aRv)
entry = new FileEntry(global, file, fs);
}
Sequence<RefPtr<Entry>> entries;
Sequence<RefPtr<FileSystemEntry>> entries;
if (!entries.AppendElement(entry, fallible)) {
return nullptr;
}

Просмотреть файл

@ -14,7 +14,7 @@
namespace mozilla {
namespace dom {
class Entry;
class FileSystemEntry;
class FunctionStringCallback;
class DataTransferItem final : public nsISupports
@ -75,7 +75,7 @@ public:
already_AddRefed<File> GetAsFile(ErrorResult& aRv);
already_AddRefed<Entry> GetAsEntry(ErrorResult& aRv);
already_AddRefed<FileSystemEntry> GetAsEntry(ErrorResult& aRv);
DataTransferItemList* GetParentObject() const
{

Просмотреть файл

@ -18,7 +18,7 @@ namespace mozilla {
namespace dom {
EntryCallbackRunnable::EntryCallbackRunnable(EntryCallback* aCallback,
Entry* aEntry)
FileSystemEntry* aEntry)
: mCallback(aCallback)
, mEntry(aEntry)
{
@ -67,7 +67,7 @@ EmptyEntriesCallbackRunnable::EmptyEntriesCallbackRunnable(EntriesCallback* aCal
NS_IMETHODIMP
EmptyEntriesCallbackRunnable::Run()
{
Sequence<OwningNonNull<Entry>> sequence;
Sequence<OwningNonNull<FileSystemEntry>> sequence;
mCallback->HandleEvent(sequence);
return NS_OK;
}

Просмотреть файл

@ -20,14 +20,14 @@ class EntryCallbackRunnable final : public Runnable
{
public:
EntryCallbackRunnable(EntryCallback* aCallback,
Entry* aEntry);
FileSystemEntry* aEntry);
NS_IMETHOD
Run() override;
private:
RefPtr<EntryCallback> mCallback;
RefPtr<Entry> mEntry;
RefPtr<FileSystemEntry> mEntry;
};
class ErrorCallbackRunnable final : public Runnable

Просмотреть файл

@ -13,18 +13,18 @@
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_INHERITED(DirectoryEntry, Entry, mDirectory)
NS_IMPL_CYCLE_COLLECTION_INHERITED(DirectoryEntry, FileSystemEntry, mDirectory)
NS_IMPL_ADDREF_INHERITED(DirectoryEntry, Entry)
NS_IMPL_RELEASE_INHERITED(DirectoryEntry, Entry)
NS_IMPL_ADDREF_INHERITED(DirectoryEntry, FileSystemEntry)
NS_IMPL_RELEASE_INHERITED(DirectoryEntry, FileSystemEntry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DirectoryEntry)
NS_INTERFACE_MAP_END_INHERITING(Entry)
NS_INTERFACE_MAP_END_INHERITING(FileSystemEntry)
DirectoryEntry::DirectoryEntry(nsIGlobalObject* aGlobal,
Directory* aDirectory,
FileSystem* aFileSystem)
: Entry(aGlobal, aFileSystem)
: FileSystemEntry(aGlobal, aFileSystem)
, mDirectory(aDirectory)
{
MOZ_ASSERT(aGlobal);

Просмотреть файл

@ -7,19 +7,19 @@
#ifndef mozilla_dom_DirectoryEntry_h
#define mozilla_dom_DirectoryEntry_h
#include "mozilla/dom/Entry.h"
#include "mozilla/dom/FileSystemBinding.h"
#include "mozilla/dom/FileSystemEntry.h"
namespace mozilla {
namespace dom {
class Directory;
class DirectoryEntry : public Entry
class DirectoryEntry : public FileSystemEntry
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DirectoryEntry, Entry)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DirectoryEntry, FileSystemEntry)
DirectoryEntry(nsIGlobalObject* aGlobalObject, Directory* aDirectory,
FileSystem* aFileSystem);

Просмотреть файл

@ -52,7 +52,7 @@ public:
return;
}
Sequence<OwningNonNull<Entry>> sequence;
Sequence<OwningNonNull<FileSystemEntry>> sequence;
if (NS_WARN_IF(!sequence.SetLength(length, fallible))) {
return;
}

Просмотреть файл

@ -38,18 +38,18 @@ private:
} // anonymous namespace
NS_IMPL_CYCLE_COLLECTION_INHERITED(FileEntry, Entry, mFile)
NS_IMPL_CYCLE_COLLECTION_INHERITED(FileEntry, FileSystemEntry, mFile)
NS_IMPL_ADDREF_INHERITED(FileEntry, Entry)
NS_IMPL_RELEASE_INHERITED(FileEntry, Entry)
NS_IMPL_ADDREF_INHERITED(FileEntry, FileSystemEntry)
NS_IMPL_RELEASE_INHERITED(FileEntry, FileSystemEntry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileEntry)
NS_INTERFACE_MAP_END_INHERITING(Entry)
NS_INTERFACE_MAP_END_INHERITING(FileSystemEntry)
FileEntry::FileEntry(nsIGlobalObject* aGlobal,
File* aFile,
FileSystem* aFileSystem)
: Entry(aGlobal, aFileSystem)
: FileSystemEntry(aGlobal, aFileSystem)
, mFile(aFile)
{
MOZ_ASSERT(aGlobal);

Просмотреть файл

@ -7,18 +7,18 @@
#ifndef mozilla_dom_FileEntry_h
#define mozilla_dom_FileEntry_h
#include "mozilla/dom/Entry.h"
#include "mozilla/dom/FileSystemEntry.h"
namespace mozilla {
namespace dom {
class File;
class FileEntry final : public Entry
class FileEntry final : public FileSystemEntry
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileEntry, Entry)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileEntry, FileSystemEntry)
FileEntry(nsIGlobalObject* aGlobalObject, File* aFile,
FileSystem* aFileSystem);

Просмотреть файл

@ -65,7 +65,7 @@ FileSystem::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
}
void
FileSystem::CreateRoot(const Sequence<RefPtr<Entry>>& aEntries)
FileSystem::CreateRoot(const Sequence<RefPtr<FileSystemEntry>>& aEntries)
{
MOZ_ASSERT(!mRoot);
mRoot = new RootDirectoryEntry(mParent, aEntries, this);

Просмотреть файл

@ -19,7 +19,7 @@ namespace mozilla {
namespace dom {
class DirectoryEntry;
class Entry;
class FileSystemEntry;
class OwningFileOrDirectory;
class FileSystem final
@ -55,7 +55,7 @@ public:
}
void
CreateRoot(const Sequence<RefPtr<Entry>>& aEntries);
CreateRoot(const Sequence<RefPtr<FileSystemEntry>>& aEntries);
private:
explicit FileSystem(nsIGlobalObject* aGlobalObject,

Просмотреть файл

@ -4,7 +4,7 @@
* 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/. */
#include "Entry.h"
#include "FileSystemEntry.h"
#include "DirectoryEntry.h"
#include "FileEntry.h"
#include "mozilla/dom/UnionTypes.h"
@ -12,25 +12,25 @@
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Entry, mParent, mFileSystem)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FileSystemEntry, mParent, mFileSystem)
NS_IMPL_CYCLE_COLLECTING_ADDREF(Entry)
NS_IMPL_CYCLE_COLLECTING_RELEASE(Entry)
NS_IMPL_CYCLE_COLLECTING_ADDREF(FileSystemEntry)
NS_IMPL_CYCLE_COLLECTING_RELEASE(FileSystemEntry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Entry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileSystemEntry)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
/* static */ already_AddRefed<Entry>
Entry::Create(nsIGlobalObject* aGlobalObject,
const OwningFileOrDirectory& aFileOrDirectory,
FileSystem* aFileSystem)
/* static */ already_AddRefed<FileSystemEntry>
FileSystemEntry::Create(nsIGlobalObject* aGlobalObject,
const OwningFileOrDirectory& aFileOrDirectory,
FileSystem* aFileSystem)
{
MOZ_ASSERT(aGlobalObject);
MOZ_ASSERT(aFileSystem);
RefPtr<Entry> entry;
RefPtr<FileSystemEntry> entry;
if (aFileOrDirectory.IsFile()) {
entry = new FileEntry(aGlobalObject,
aFileOrDirectory.GetAsFile(),
@ -45,7 +45,8 @@ Entry::Create(nsIGlobalObject* aGlobalObject,
return entry.forget();
}
Entry::Entry(nsIGlobalObject* aGlobal, FileSystem* aFileSystem)
FileSystemEntry::FileSystemEntry(nsIGlobalObject* aGlobal,
FileSystem* aFileSystem)
: mParent(aGlobal)
, mFileSystem(aFileSystem)
{
@ -53,13 +54,13 @@ Entry::Entry(nsIGlobalObject* aGlobal, FileSystem* aFileSystem)
MOZ_ASSERT(aFileSystem);
}
Entry::~Entry()
FileSystemEntry::~FileSystemEntry()
{}
JSObject*
Entry::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
FileSystemEntry::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return EntryBinding::Wrap(aCx, this, aGivenProto);
return FileSystemEntryBinding::Wrap(aCx, this, aGivenProto);
}
} // dom namespace

Просмотреть файл

@ -4,8 +4,8 @@
* 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 mozilla_dom_Entry_h
#define mozilla_dom_Entry_h
#ifndef mozilla_dom_FileSystemEntry_h
#define mozilla_dom_FileSystemEntry_h
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
@ -20,15 +20,15 @@ namespace dom {
class FileSystem;
class OwningFileOrDirectory;
class Entry
class FileSystemEntry
: public nsISupports
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Entry)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FileSystemEntry)
static already_AddRefed<Entry>
static already_AddRefed<FileSystemEntry>
Create(nsIGlobalObject* aGlobalObject,
const OwningFileOrDirectory& aFileOrDirectory,
FileSystem* aFileSystem);
@ -67,9 +67,9 @@ public:
}
protected:
Entry(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem);
virtual ~Entry();
FileSystemEntry(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem);
virtual ~FileSystemEntry();
private:
nsCOMPtr<nsIGlobalObject> mParent;
@ -79,4 +79,4 @@ private:
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_Entry_h
#endif // mozilla_dom_FileSystemEntry_h

Просмотреть файл

@ -20,7 +20,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(RootDirectoryEntry)
NS_INTERFACE_MAP_END_INHERITING(DirectoryEntry)
RootDirectoryEntry::RootDirectoryEntry(nsIGlobalObject* aGlobal,
const Sequence<RefPtr<Entry>>& aEntries,
const Sequence<RefPtr<FileSystemEntry>>& aEntries,
FileSystem* aFileSystem)
: DirectoryEntry(aGlobal, nullptr, aFileSystem)
, mEntries(aEntries)
@ -76,7 +76,7 @@ RootDirectoryEntry::GetInternal(const nsAString& aPath, const FileSystemFlags& a
MOZ_ASSERT(!parts.IsEmpty());
RefPtr<Entry> entry;
RefPtr<FileSystemEntry> entry;
for (uint32_t i = 0; i < mEntries.Length(); ++i) {
ErrorResult rv;
nsAutoString name;

Просмотреть файл

@ -19,7 +19,7 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RootDirectoryEntry, DirectoryEntry)
RootDirectoryEntry(nsIGlobalObject* aGlobalObject,
const Sequence<RefPtr<Entry>>& aEntries,
const Sequence<RefPtr<FileSystemEntry>>& aEntries,
FileSystem* aFileSystem);
virtual void
@ -44,7 +44,7 @@ private:
Error(const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
nsresult aError) const;
Sequence<RefPtr<Entry>> mEntries;
Sequence<RefPtr<FileSystemEntry>> mEntries;
};
} // namespace dom

Просмотреть файл

@ -17,7 +17,7 @@ class EntriesCallbackRunnable final : public Runnable
{
public:
EntriesCallbackRunnable(EntriesCallback* aCallback,
const Sequence<RefPtr<Entry>>& aEntries)
const Sequence<RefPtr<FileSystemEntry>>& aEntries)
: mCallback(aCallback)
, mEntries(aEntries)
{
@ -27,7 +27,7 @@ public:
NS_IMETHOD
Run() override
{
Sequence<OwningNonNull<Entry>> entries;
Sequence<OwningNonNull<FileSystemEntry>> entries;
for (uint32_t i = 0; i < mEntries.Length(); ++i) {
if (!entries.AppendElement(mEntries[i].forget(), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
@ -40,7 +40,7 @@ public:
private:
RefPtr<EntriesCallback> mCallback;
Sequence<RefPtr<Entry>> mEntries;
Sequence<RefPtr<FileSystemEntry>> mEntries;
};
} // anonymous namespace
@ -55,7 +55,7 @@ NS_INTERFACE_MAP_END_INHERITING(DirectoryReader)
RootDirectoryReader::RootDirectoryReader(nsIGlobalObject* aGlobal,
FileSystem* aFileSystem,
const Sequence<RefPtr<Entry>>& aEntries)
const Sequence<RefPtr<FileSystemEntry>>& aEntries)
: DirectoryReader(aGlobal, aFileSystem, nullptr)
, mEntries(aEntries)
, mAlreadyRead(false)

Просмотреть файл

@ -20,7 +20,7 @@ public:
explicit RootDirectoryReader(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem,
const Sequence<RefPtr<Entry>>& aEntries);
const Sequence<RefPtr<FileSystemEntry>>& aEntries);
virtual void
ReadEntries(EntriesCallback& aSuccessCallback,
@ -30,7 +30,7 @@ public:
private:
~RootDirectoryReader();
Sequence<RefPtr<Entry>> mEntries;
Sequence<RefPtr<FileSystemEntry>> mEntries;
bool mAlreadyRead;
};

Просмотреть файл

@ -9,18 +9,18 @@ TEST_DIRS += ['tests']
EXPORTS.mozilla.dom += [
'DirectoryEntry.h',
'DirectoryReader.h',
'Entry.h',
'FileEntry.h',
'FileSystem.h',
'FileSystemEntry.h',
]
UNIFIED_SOURCES += [
'CallbackRunnables.cpp',
'DirectoryEntry.cpp',
'DirectoryReader.cpp',
'Entry.cpp',
'FileEntry.cpp',
'FileSystem.cpp',
'FileSystemEntry.cpp',
'RootDirectoryEntry.cpp',
'RootDirectoryReader.cpp',
]

Просмотреть файл

@ -79,7 +79,7 @@
#include "nsIRadioGroupContainer.h"
// input type=file
#include "mozilla/dom/Entry.h"
#include "mozilla/dom/FileSystemEntry.h"
#include "mozilla/dom/FileSystem.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/FileList.h"
@ -8264,9 +8264,10 @@ HTMLInputElement::UpdateEntries(const nsTArray<OwningFileOrDirectory>& aFilesOrD
return;
}
Sequence<RefPtr<Entry>> entries;
Sequence<RefPtr<FileSystemEntry>> entries;
for (uint32_t i = 0; i < aFilesOrDirectories.Length(); ++i) {
RefPtr<Entry> entry = Entry::Create(global, aFilesOrDirectories[i], fs);
RefPtr<FileSystemEntry> entry =
FileSystemEntry::Create(global, aFilesOrDirectories[i], fs);
MOZ_ASSERT(entry);
if (!entries.AppendElement(entry, fallible)) {
@ -8282,7 +8283,7 @@ HTMLInputElement::UpdateEntries(const nsTArray<OwningFileOrDirectory>& aFilesOrD
}
void
HTMLInputElement::GetWebkitEntries(nsTArray<RefPtr<Entry>>& aSequence)
HTMLInputElement::GetWebkitEntries(nsTArray<RefPtr<FileSystemEntry>>& aSequence)
{
Telemetry::Accumulate(Telemetry::BLINK_FILESYSTEM_USED, true);
aSequence.AppendElements(mEntries);

Просмотреть файл

@ -40,9 +40,9 @@ namespace dom {
class AfterSetFilesOrDirectoriesRunnable;
class Date;
class DispatchChangeEventCallback;
class Entry;
class File;
class FileList;
class FileSystemEntry;
class GetFilesHelper;
/**
@ -747,7 +747,7 @@ public:
SetHTMLBoolAttr(nsGkAtoms::webkitdirectory, aValue, aRv);
}
void GetWebkitEntries(nsTArray<RefPtr<Entry>>& aSequence);
void GetWebkitEntries(nsTArray<RefPtr<FileSystemEntry>>& aSequence);
bool IsFilesAndDirectoriesSupported() const;
@ -1420,7 +1420,7 @@ protected:
nsString mFirstFilePath;
RefPtr<FileList> mFileList;
Sequence<RefPtr<Entry>> mEntries;
Sequence<RefPtr<FileSystemEntry>> mEntries;
nsString mStaticDocFileList;

Просмотреть файл

@ -20,5 +20,5 @@ callback FunctionStringCallback = void (DOMString data);
partial interface DataTransferItem {
[Pref="dom.webkitBlink.filesystem.enabled", BinaryName="getAsEntry", Throws]
Entry? webkitGetAsEntry();
FileSystemEntry? webkitGetAsEntry();
};

Просмотреть файл

@ -5,7 +5,7 @@
*/
[NoInterfaceObject]
interface Entry {
interface FileSystemEntry {
readonly attribute boolean isFile;
readonly attribute boolean isDirectory;
@ -33,7 +33,7 @@ dictionary FileSystemFlags {
};
callback interface EntryCallback {
void handleEvent(Entry entry);
void handleEvent(FileSystemEntry entry);
};
callback interface VoidCallback {
@ -41,7 +41,7 @@ callback interface VoidCallback {
};
[NoInterfaceObject]
interface DirectoryEntry : Entry {
interface DirectoryEntry : FileSystemEntry {
DirectoryReader createReader();
void getFile(DOMString? path, optional FileSystemFlags options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
@ -54,7 +54,7 @@ interface DirectoryEntry : Entry {
};
callback interface EntriesCallback {
void handleEvent(sequence<Entry> entries);
void handleEvent(sequence<FileSystemEntry> entries);
};
callback interface ErrorCallback {
@ -76,7 +76,7 @@ callback interface BlobCallback {
};
[NoInterfaceObject]
interface FileEntry : Entry {
interface FileEntry : FileSystemEntry {
// the successCallback should be a FileWriteCallback but this method is not
// implemented. ErrorCallback will be called with
// NS_ERROR_DOM_NOT_SUPPORTED_ERR.

Просмотреть файл

@ -229,7 +229,7 @@ HTMLInputElement implements MozPhonetic;
// Webkit/Blink
partial interface HTMLInputElement {
[Pref="dom.webkitBlink.filesystem.enabled", Frozen, Cached, Pure]
readonly attribute sequence<Entry> webkitEntries;
readonly attribute sequence<FileSystemEntry> webkitEntries;
[Pref="dom.webkitBlink.dirPicker.enabled", BinaryName="WebkitDirectoryAttr", SetterThrows]
attribute boolean webkitdirectory;