Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.h

Issue 2040563002: Remove FileError interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fe-dep
Patch Set: handleEvent -> invoke and other review nits Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.h
diff --git a/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.h b/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.h
index 937f0573072b448ed9587ff47bd1b0d4c726c1a5..39a169c1a3b296604e588ae11255984715ed2636 100644
--- a/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.h
+++ b/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.h
@@ -31,6 +31,7 @@
#ifndef FileSystemCallbacks_h
#define FileSystemCallbacks_h
+#include "core/fileapi/FileError.h"
#include "modules/filesystem/EntriesCallback.h"
#include "platform/AsyncFileSystemCallbacks.h"
#include "platform/FileSystemType.h"
@@ -42,10 +43,10 @@ namespace blink {
class DOMFileSystemBase;
class DirectoryReaderBase;
+class BlobCallback;
class EntriesCallback;
class EntryCallback;
class ErrorCallback;
-class BlobCallback;
class FileMetadata;
class FileSystemCallback;
class FileWriterBase;
@@ -54,6 +55,16 @@ class MetadataCallback;
class ExecutionContext;
class VoidCallback;
+// Passed to DOMFileSystem implementations that may report errors. Subclasses
+// may capture the error for throwing on return to script (for synchronous APIs)
+// or call an actual script callback (for asynchronous APIs).
+class ErrorCallbackBase : public GarbageCollectedFinalized<ErrorCallbackBase> {
+public:
+ virtual ~ErrorCallbackBase() { }
+ DEFINE_INLINE_VIRTUAL_TRACE() { }
+ virtual void invoke(FileError::ErrorCode) = 0;
+};
+
class FileSystemCallbacksBase : public AsyncFileSystemCallbacks {
public:
~FileSystemCallbacksBase() override;
@@ -64,17 +75,20 @@ public:
// Other callback methods are implemented by each subclass.
protected:
- FileSystemCallbacksBase(ErrorCallback*, DOMFileSystemBase*, ExecutionContext*);
+ FileSystemCallbacksBase(ErrorCallbackBase*, DOMFileSystemBase*, ExecutionContext*);
bool shouldScheduleCallback() const;
template <typename CB, typename CBArg>
+ void invokeOrScheduleCallback(CB*, CBArg);
+
+ template <typename CB, typename CBArg>
void handleEventOrScheduleCallback(CB*, CBArg*);
template <typename CB>
void handleEventOrScheduleCallback(CB*);
- Persistent<ErrorCallback> m_errorCallback;
+ Persistent<ErrorCallbackBase> m_errorCallback;
Persistent<DOMFileSystemBase> m_fileSystem;
Persistent<ExecutionContext> m_executionContext;
int m_asyncOperationId;
@@ -82,13 +96,26 @@ protected:
// Subclasses ----------------------------------------------------------------
+// Wraps a script-provided callback for use in DOMFileSystem operations.
+class ScriptErrorCallback final : public ErrorCallbackBase {
+public:
+ static ScriptErrorCallback* wrap(ErrorCallback*);
+ virtual ~ScriptErrorCallback() { }
+ DECLARE_VIRTUAL_TRACE();
+
+ void invoke(FileError::ErrorCode) override;
+private:
+ explicit ScriptErrorCallback(ErrorCallback*);
+ Member<ErrorCallback> m_callback;
+};
+
class EntryCallbacks final : public FileSystemCallbacksBase {
public:
- static std::unique_ptr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCallback*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, bool isDirectory);
+ static std::unique_ptr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCallbackBase*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, bool isDirectory);
void didSucceed() override;
private:
- EntryCallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, bool isDirectory);
+ EntryCallbacks(EntryCallback*, ErrorCallbackBase*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, bool isDirectory);
Persistent<EntryCallback> m_successCallback;
String m_expectedPath;
bool m_isDirectory;
@@ -96,12 +123,12 @@ private:
class EntriesCallbacks final : public FileSystemCallbacksBase {
public:
- static std::unique_ptr<AsyncFileSystemCallbacks> create(EntriesCallback*, ErrorCallback*, ExecutionContext*, DirectoryReaderBase*, const String& basePath);
+ static std::unique_ptr<AsyncFileSystemCallbacks> create(EntriesCallback*, ErrorCallbackBase*, ExecutionContext*, DirectoryReaderBase*, const String& basePath);
void didReadDirectoryEntry(const String& name, bool isDirectory) override;
void didReadDirectoryEntries(bool hasMore) override;
private:
- EntriesCallbacks(EntriesCallback*, ErrorCallback*, ExecutionContext*, DirectoryReaderBase*, const String& basePath);
+ EntriesCallbacks(EntriesCallback*, ErrorCallbackBase*, ExecutionContext*, DirectoryReaderBase*, const String& basePath);
Persistent<EntriesCallback> m_successCallback;
Persistent<DirectoryReaderBase> m_directoryReader;
String m_basePath;
@@ -110,53 +137,53 @@ private:
class FileSystemCallbacks final : public FileSystemCallbacksBase {
public:
- static std::unique_ptr<AsyncFileSystemCallbacks> create(FileSystemCallback*, ErrorCallback*, ExecutionContext*, FileSystemType);
+ static std::unique_ptr<AsyncFileSystemCallbacks> create(FileSystemCallback*, ErrorCallbackBase*, ExecutionContext*, FileSystemType);
void didOpenFileSystem(const String& name, const KURL& rootURL) override;
private:
- FileSystemCallbacks(FileSystemCallback*, ErrorCallback*, ExecutionContext*, FileSystemType);
+ FileSystemCallbacks(FileSystemCallback*, ErrorCallbackBase*, ExecutionContext*, FileSystemType);
Persistent<FileSystemCallback> m_successCallback;
FileSystemType m_type;
};
class ResolveURICallbacks final : public FileSystemCallbacksBase {
public:
- static std::unique_ptr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCallback*, ExecutionContext*);
+ static std::unique_ptr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCallbackBase*, ExecutionContext*);
void didResolveURL(const String& name, const KURL& rootURL, FileSystemType, const String& filePath, bool isDirectry) override;
private:
- ResolveURICallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*);
+ ResolveURICallbacks(EntryCallback*, ErrorCallbackBase*, ExecutionContext*);
Persistent<EntryCallback> m_successCallback;
};
class MetadataCallbacks final : public FileSystemCallbacksBase {
public:
- static std::unique_ptr<AsyncFileSystemCallbacks> create(MetadataCallback*, ErrorCallback*, ExecutionContext*, DOMFileSystemBase*);
+ static std::unique_ptr<AsyncFileSystemCallbacks> create(MetadataCallback*, ErrorCallbackBase*, ExecutionContext*, DOMFileSystemBase*);
void didReadMetadata(const FileMetadata&) override;
private:
- MetadataCallbacks(MetadataCallback*, ErrorCallback*, ExecutionContext*, DOMFileSystemBase*);
+ MetadataCallbacks(MetadataCallback*, ErrorCallbackBase*, ExecutionContext*, DOMFileSystemBase*);
Persistent<MetadataCallback> m_successCallback;
};
class FileWriterBaseCallbacks final : public FileSystemCallbacksBase {
public:
- static std::unique_ptr<AsyncFileSystemCallbacks> create(FileWriterBase*, FileWriterBaseCallback*, ErrorCallback*, ExecutionContext*);
+ static std::unique_ptr<AsyncFileSystemCallbacks> create(FileWriterBase*, FileWriterBaseCallback*, ErrorCallbackBase*, ExecutionContext*);
void didCreateFileWriter(std::unique_ptr<WebFileWriter>, long long length) override;
private:
- FileWriterBaseCallbacks(FileWriterBase*, FileWriterBaseCallback*, ErrorCallback*, ExecutionContext*);
+ FileWriterBaseCallbacks(FileWriterBase*, FileWriterBaseCallback*, ErrorCallbackBase*, ExecutionContext*);
Persistent<FileWriterBase> m_fileWriter;
Persistent<FileWriterBaseCallback> m_successCallback;
};
class SnapshotFileCallback final : public FileSystemCallbacksBase {
public:
- static std::unique_ptr<AsyncFileSystemCallbacks> create(DOMFileSystemBase*, const String& name, const KURL&, BlobCallback*, ErrorCallback*, ExecutionContext*);
+ static std::unique_ptr<AsyncFileSystemCallbacks> create(DOMFileSystemBase*, const String& name, const KURL&, BlobCallback*, ErrorCallbackBase*, ExecutionContext*);
virtual void didCreateSnapshotFile(const FileMetadata&, PassRefPtr<BlobDataHandle> snapshot);
private:
- SnapshotFileCallback(DOMFileSystemBase*, const String& name, const KURL&, BlobCallback*, ErrorCallback*, ExecutionContext*);
+ SnapshotFileCallback(DOMFileSystemBase*, const String& name, const KURL&, BlobCallback*, ErrorCallbackBase*, ExecutionContext*);
String m_name;
KURL m_url;
Persistent<BlobCallback> m_successCallback;
@@ -164,11 +191,11 @@ private:
class VoidCallbacks final : public FileSystemCallbacksBase {
public:
- static std::unique_ptr<AsyncFileSystemCallbacks> create(VoidCallback*, ErrorCallback*, ExecutionContext*, DOMFileSystemBase*);
+ static std::unique_ptr<AsyncFileSystemCallbacks> create(VoidCallback*, ErrorCallbackBase*, ExecutionContext*, DOMFileSystemBase*);
void didSucceed() override;
private:
- VoidCallbacks(VoidCallback*, ErrorCallback*, ExecutionContext*, DOMFileSystemBase*);
+ VoidCallbacks(VoidCallback*, ErrorCallbackBase*, ExecutionContext*, DOMFileSystemBase*);
Persistent<VoidCallback> m_successCallback;
};

Powered by Google App Engine
This is Rietveld 408576698