Skip to content

Commit

Permalink
Bug 1295570 - Entries API - part 6 - Rename Entries Callbacks, r=smaug
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulf committed Aug 18, 2016
1 parent 0bd06cd commit 1a7e0c9
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 38 deletions.
6 changes: 3 additions & 3 deletions dom/filesystem/compat/CallbackRunnables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace mozilla {
namespace dom {

EntryCallbackRunnable::EntryCallbackRunnable(EntryCallback* aCallback,
EntryCallbackRunnable::EntryCallbackRunnable(FileSystemEntryCallback* aCallback,
FileSystemEntry* aEntry)
: mCallback(aCallback)
, mEntry(aEntry)
Expand Down Expand Up @@ -58,7 +58,7 @@ ErrorCallbackRunnable::Run()
return NS_OK;
}

EmptyEntriesCallbackRunnable::EmptyEntriesCallbackRunnable(EntriesCallback* aCallback)
EmptyEntriesCallbackRunnable::EmptyEntriesCallbackRunnable(FileSystemEntriesCallback* aCallback)
: mCallback(aCallback)
{
MOZ_ASSERT(aCallback);
Expand All @@ -74,7 +74,7 @@ EmptyEntriesCallbackRunnable::Run()

GetEntryHelper::GetEntryHelper(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem,
EntryCallback* aSuccessCallback,
FileSystemEntryCallback* aSuccessCallback,
ErrorCallback* aErrorCallback,
FileSystemDirectoryEntry::GetInternalType aType)
: mGlobal(aGlobalObject)
Expand Down
12 changes: 6 additions & 6 deletions dom/filesystem/compat/CallbackRunnables.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ namespace dom {
class EntryCallbackRunnable final : public Runnable
{
public:
EntryCallbackRunnable(EntryCallback* aCallback,
EntryCallbackRunnable(FileSystemEntryCallback* aCallback,
FileSystemEntry* aEntry);

NS_IMETHOD
Run() override;

private:
RefPtr<EntryCallback> mCallback;
RefPtr<FileSystemEntryCallback> mCallback;
RefPtr<FileSystemEntry> mEntry;
};

Expand All @@ -49,13 +49,13 @@ class ErrorCallbackRunnable final : public Runnable
class EmptyEntriesCallbackRunnable final : public Runnable
{
public:
explicit EmptyEntriesCallbackRunnable(EntriesCallback* aCallback);
explicit EmptyEntriesCallbackRunnable(FileSystemEntriesCallback* aCallback);

NS_IMETHOD
Run() override;

private:
RefPtr<EntriesCallback> mCallback;
RefPtr<FileSystemEntriesCallback> mCallback;
};

class GetEntryHelper final : public PromiseNativeHandler
Expand All @@ -65,7 +65,7 @@ class GetEntryHelper final : public PromiseNativeHandler

GetEntryHelper(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem,
EntryCallback* aSuccessCallback,
FileSystemEntryCallback* aSuccessCallback,
ErrorCallback* aErrorCallback,
FileSystemDirectoryEntry::GetInternalType aType);

Expand All @@ -83,7 +83,7 @@ class GetEntryHelper final : public PromiseNativeHandler

nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<FileSystem> mFileSystem;
RefPtr<EntryCallback> mSuccessCallback;
RefPtr<FileSystemEntryCallback> mSuccessCallback;
RefPtr<ErrorCallback> mErrorCallback;
FileSystemDirectoryEntry::GetInternalType mType;
};
Expand Down
2 changes: 1 addition & 1 deletion dom/filesystem/compat/FileSystemDirectoryEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ FileSystemDirectoryEntry::CreateReader() const
void
FileSystemDirectoryEntry::GetInternal(const nsAString& aPath,
const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const
{
Expand Down
6 changes: 3 additions & 3 deletions dom/filesystem/compat/FileSystemDirectoryEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class FileSystemDirectoryEntry : public FileSystemEntry

void
GetFile(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
{
GetInternal(aPath, aFlag, aSuccessCallback, aErrorCallback, eGetFile);
}

void
GetDirectory(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
{
GetInternal(aPath, aFlag, aSuccessCallback, aErrorCallback, eGetDirectory);
Expand All @@ -68,7 +68,7 @@ class FileSystemDirectoryEntry : public FileSystemEntry

virtual void
GetInternal(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const;

Expand Down
6 changes: 3 additions & 3 deletions dom/filesystem/compat/FileSystemDirectoryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PromiseHandler final : public PromiseNativeHandler

PromiseHandler(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem,
EntriesCallback* aSuccessCallback,
FileSystemEntriesCallback* aSuccessCallback,
ErrorCallback* aErrorCallback)
: mGlobal(aGlobalObject)
, mFileSystem(aFileSystem)
Expand Down Expand Up @@ -108,7 +108,7 @@ class PromiseHandler final : public PromiseNativeHandler

nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<FileSystem> mFileSystem;
RefPtr<EntriesCallback> mSuccessCallback;
RefPtr<FileSystemEntriesCallback> mSuccessCallback;
RefPtr<ErrorCallback> mErrorCallback;
};

Expand Down Expand Up @@ -150,7 +150,7 @@ FileSystemDirectoryReader::WrapObject(JSContext* aCx,
}

void
FileSystemDirectoryReader::ReadEntries(EntriesCallback& aSuccessCallback,
FileSystemDirectoryReader::ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv)
{
Expand Down
2 changes: 1 addition & 1 deletion dom/filesystem/compat/FileSystemDirectoryReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FileSystemDirectoryReader
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;

virtual void
ReadEntries(EntriesCallback& aSuccessCallback,
ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv);

Expand Down
2 changes: 1 addition & 1 deletion dom/filesystem/compat/FileSystemRootDirectoryEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ FileSystemRootDirectoryEntry::CreateReader() const
void
FileSystemRootDirectoryEntry::GetInternal(const nsAString& aPath,
const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const
{
Expand Down
2 changes: 1 addition & 1 deletion dom/filesystem/compat/FileSystemRootDirectoryEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FileSystemRootDirectoryEntry final : public FileSystemDirectoryEntry

virtual void
GetInternal(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const override;

Expand Down
6 changes: 3 additions & 3 deletions dom/filesystem/compat/FileSystemRootDirectoryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace {
class EntriesCallbackRunnable final : public Runnable
{
public:
EntriesCallbackRunnable(EntriesCallback* aCallback,
EntriesCallbackRunnable(FileSystemEntriesCallback* aCallback,
const Sequence<RefPtr<FileSystemEntry>>& aEntries)
: mCallback(aCallback)
, mEntries(aEntries)
Expand All @@ -39,7 +39,7 @@ class EntriesCallbackRunnable final : public Runnable
}

private:
RefPtr<EntriesCallback> mCallback;
RefPtr<FileSystemEntriesCallback> mCallback;
Sequence<RefPtr<FileSystemEntry>> mEntries;
};

Expand Down Expand Up @@ -71,7 +71,7 @@ FileSystemRootDirectoryReader::~FileSystemRootDirectoryReader()
{}

void
FileSystemRootDirectoryReader::ReadEntries(EntriesCallback& aSuccessCallback,
FileSystemRootDirectoryReader::ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv)
{
Expand Down
2 changes: 1 addition & 1 deletion dom/filesystem/compat/FileSystemRootDirectoryReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FileSystemRootDirectoryReader final : public FileSystemDirectoryReader
const Sequence<RefPtr<FileSystemEntry>>& aEntries);

virtual void
ReadEntries(EntriesCallback& aSuccessCallback,
ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv) override;

Expand Down
47 changes: 32 additions & 15 deletions dom/webidl/FileSystem.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ interface FileSystemEntry {
readonly attribute FileSystem filesystem;

/** Not implemented:
* void getMetadata(MetadataCallback successCallback, optional ErrorCallback errorCallback);
* void moveTo(FileSystemDirectoryEntry parent, optional DOMString? name, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
* void copyTo(FileSystemDirectoryEntry parent, optional DOMString? name, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
* void getMetadata(MetadataCallback successCallback,
* optional ErrorCallback errorCallback);
* void moveTo(FileSystemDirectoryEntry parent, optional DOMString? name,
* optional FileSystemEntryCallback successCallback,
* optional ErrorCallback errorCallback);
* void copyTo(FileSystemDirectoryEntry parent, optional DOMString? name,
* optional FileSystemEntryCallback successCallback,
* optional ErrorCallback errorCallback);
* DOMString toURL();
* void remove(VoidCallback successCallback, optional ErrorCallback errorCallback);
* void getParent(optional EntryCallback successCallback, optional ErrorCallback errorCallback);
* void remove(VoidCallback successCallback,
* optional ErrorCallback errorCallback);
* void getParent(optional FileSystemEntryCallback successCallback,
* optional ErrorCallback errorCallback);
*/
};

Expand All @@ -32,7 +39,7 @@ dictionary FileSystemFlags {
boolean exclusive = false;
};

callback interface EntryCallback {
callback interface FileSystemEntryCallback {
void handleEvent(FileSystemEntry entry);
};

Expand All @@ -44,16 +51,23 @@ callback interface VoidCallback {
interface FileSystemDirectoryEntry : FileSystemEntry {
FileSystemDirectoryReader createReader();

void getFile(DOMString? path, optional FileSystemFlags options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
void getFile(DOMString? path,
optional FileSystemFlags options,
optional FileSystemEntryCallback successCallback,
optional ErrorCallback errorCallback);

void getDirectory(DOMString? path, optional FileSystemFlags options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
void getDirectory(DOMString? path,
optional FileSystemFlags options,
optional FileSystemEntryCallback successCallback,
optional ErrorCallback errorCallback);

// This method is not implemented. ErrorCallback will be called with
// NS_ERROR_DOM_NOT_SUPPORTED_ERR.
void removeRecursively(VoidCallback successCallback, optional ErrorCallback errorCallback);
// This method is not implemented. ErrorCallback will be called
// with NS_ERROR_DOM_NOT_SUPPORTED_ERR.
void removeRecursively(VoidCallback successCallback,
optional ErrorCallback errorCallback);
};

callback interface EntriesCallback {
callback interface FileSystemEntriesCallback {
void handleEvent(sequence<FileSystemEntry> entries);
};

Expand All @@ -68,7 +82,8 @@ interface FileSystemDirectoryReader {
// readEntries can be called just once. The second time it returns no data.

[Throws]
void readEntries (EntriesCallback successCallback, optional ErrorCallback errorCallback);
void readEntries(FileSystemEntriesCallback successCallback,
optional ErrorCallback errorCallback);
};

callback interface BlobCallback {
Expand All @@ -80,10 +95,12 @@ interface FileSystemFileEntry : FileSystemEntry {
// the successCallback should be a FileWriteCallback but this method is not
// implemented. ErrorCallback will be called with
// NS_ERROR_DOM_NOT_SUPPORTED_ERR.
void createWriter (VoidCallback successCallback, optional ErrorCallback errorCallback);
void createWriter (VoidCallback successCallback,
optional ErrorCallback errorCallback);

[BinaryName="GetFile"]
void file (BlobCallback successCallback, optional ErrorCallback errorCallback);
void file (BlobCallback successCallback,
optional ErrorCallback errorCallback);
};

[NoInterfaceObject]
Expand Down

0 comments on commit 1a7e0c9

Please sign in to comment.