Remove FileError interface

FileError was removed from File API [1] after Chrome had shipped the
functionality. Other browsers do not use it, returning a DOMError
instead. Using the `code` property has been logging deprecation
warnings since August 2013. The affected APIs will now yield
DOMExceptions instead (as DOMError is being removed from the platform
[2]). Script should inspect the `name` and `message` properties of the
error objects.

This affects:
* FileReader.error
* FileWriter.error
* FileSystem async API: passed to ErrorCallback on failure
* FileSystem sync API: thrown on failure

Intent: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/kJMa2rpAYqI
Dashboard: https://www.chromestatus.com/feature/6687420359639040

[1] https://w3c.github.io/FileAPI/
[2] https://dom.spec.whatwg.org/#domerror

BUG=496901
R=foolip@chromium.org

Review-Url: https://codereview.chromium.org/2040563002
Cr-Commit-Position: refs/heads/master@{#406169}
diff --git a/third_party/WebKit/LayoutTests/fast/dom/script-tests/constructed-objects-prototypes.js b/third_party/WebKit/LayoutTests/fast/dom/script-tests/constructed-objects-prototypes.js
index 4c83d40..1ebf908 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/script-tests/constructed-objects-prototypes.js
+++ b/third_party/WebKit/LayoutTests/fast/dom/script-tests/constructed-objects-prototypes.js
@@ -39,7 +39,6 @@
             type =="Uint8ClampedArrayConstructor" ||
             type =="Uint16ArrayConstructor" ||
             type =="Uint32ArrayConstructor" ||
-            type == "FileErrorConstructor" ||
             type == "FileReaderConstructor" ||
             type == "AudioContextConstructor" ||
             type == "SpeechSynthesisUtteranceConstructor")
diff --git a/third_party/WebKit/LayoutTests/fast/js/script-tests/global-constructors.js b/third_party/WebKit/LayoutTests/fast/js/script-tests/global-constructors.js
index 1be91ef..b9b1ff9 100644
--- a/third_party/WebKit/LayoutTests/fast/js/script-tests/global-constructors.js
+++ b/third_party/WebKit/LayoutTests/fast/js/script-tests/global-constructors.js
@@ -40,7 +40,6 @@
         name == "Uint32Array" ||
         name == "Float32Array" ||
         name == "Float64Array" ||
-        name == "FileError" ||
         name == "FileReader")
         continue;
 
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js
index 1ac85af..3929c0d 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js
@@ -142,7 +142,7 @@
         var entry = this;
         for (var token of path.split("/"))
             entry = entry._childrenMap[token];
-        entry ? callback(entry) : errorCallback({ code: FileError.NOT_FOUND_ERR});
+        entry ? callback(entry) : errorCallback(new DOMException('Path not found: ' + path, 'NotFoundError'));
     },
 
     getMetadata: function(success, failure)
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
index fc71a38..9253523 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
@@ -206,21 +206,6 @@
     getter name
     getter webkitRelativePath
     method constructor
-interface FileError : DOMError
-    attribute ABORT_ERR
-    attribute ENCODING_ERR
-    attribute INVALID_MODIFICATION_ERR
-    attribute INVALID_STATE_ERR
-    attribute NOT_FOUND_ERR
-    attribute NOT_READABLE_ERR
-    attribute NO_MODIFICATION_ALLOWED_ERR
-    attribute PATH_EXISTS_ERR
-    attribute QUOTA_EXCEEDED_ERR
-    attribute SECURITY_ERR
-    attribute SYNTAX_ERR
-    attribute TYPE_MISMATCH_ERR
-    getter code
-    method constructor
 interface FileList
     getter length
     method constructor
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/FileAPI/historical-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/FileAPI/historical-expected.txt
index 0a9dceb..deac009 100644
--- a/third_party/WebKit/LayoutTests/imported/wpt/FileAPI/historical-expected.txt
+++ b/third_party/WebKit/LayoutTests/imported/wpt/FileAPI/historical-expected.txt
@@ -1,6 +1,6 @@
 This is a testharness.js-based test.
 PASS "toNativeLineEndings" should not be supported 
-FAIL "FileError" should not be supported assert_false: expected false got true
+PASS "FileError" should not be supported 
 PASS "FileException" should not be supported 
 PASS Blob should not support slice prefixed 
 PASS BlobBuilder should not be supported. 
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
index 5c20efc..447ed73 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
@@ -192,21 +192,6 @@
     getter name
     getter webkitRelativePath
     method constructor
-interface FileError : DOMError
-    attribute ABORT_ERR
-    attribute ENCODING_ERR
-    attribute INVALID_MODIFICATION_ERR
-    attribute INVALID_STATE_ERR
-    attribute NOT_FOUND_ERR
-    attribute NOT_READABLE_ERR
-    attribute NO_MODIFICATION_ALLOWED_ERR
-    attribute PATH_EXISTS_ERR
-    attribute QUOTA_EXCEEDED_ERR
-    attribute SECURITY_ERR
-    attribute SYNTAX_ERR
-    attribute TYPE_MISMATCH_ERR
-    getter code
-    method constructor
 interface FileList
     getter length
     method constructor
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
index 39350da..da7ce275 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
@@ -197,22 +197,6 @@
 [Worker]     getter name
 [Worker]     getter webkitRelativePath
 [Worker]     method constructor
-[Worker] interface FileError : DOMError
-[Worker]     attribute @@toStringTag
-[Worker]     attribute ABORT_ERR
-[Worker]     attribute ENCODING_ERR
-[Worker]     attribute INVALID_MODIFICATION_ERR
-[Worker]     attribute INVALID_STATE_ERR
-[Worker]     attribute NOT_FOUND_ERR
-[Worker]     attribute NOT_READABLE_ERR
-[Worker]     attribute NO_MODIFICATION_ALLOWED_ERR
-[Worker]     attribute PATH_EXISTS_ERR
-[Worker]     attribute QUOTA_EXCEEDED_ERR
-[Worker]     attribute SECURITY_ERR
-[Worker]     attribute SYNTAX_ERR
-[Worker]     attribute TYPE_MISMATCH_ERR
-[Worker]     getter code
-[Worker]     method constructor
 [Worker] interface FileList
 [Worker]     attribute @@toStringTag
 [Worker]     getter length
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
index adcf8b3..66d5100 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
@@ -1226,22 +1226,6 @@
     getter name
     getter webkitRelativePath
     method constructor
-interface FileError : DOMError
-    attribute @@toStringTag
-    attribute ABORT_ERR
-    attribute ENCODING_ERR
-    attribute INVALID_MODIFICATION_ERR
-    attribute INVALID_STATE_ERR
-    attribute NOT_FOUND_ERR
-    attribute NOT_READABLE_ERR
-    attribute NO_MODIFICATION_ALLOWED_ERR
-    attribute PATH_EXISTS_ERR
-    attribute QUOTA_EXCEEDED_ERR
-    attribute SECURITY_ERR
-    attribute SYNTAX_ERR
-    attribute TYPE_MISMATCH_ERR
-    getter code
-    method constructor
 interface FileList
     attribute @@toStringTag
     getter length
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
index e489b87b..1dba26e 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
@@ -184,22 +184,6 @@
 [Worker]     getter name
 [Worker]     getter webkitRelativePath
 [Worker]     method constructor
-[Worker] interface FileError : DOMError
-[Worker]     attribute @@toStringTag
-[Worker]     attribute ABORT_ERR
-[Worker]     attribute ENCODING_ERR
-[Worker]     attribute INVALID_MODIFICATION_ERR
-[Worker]     attribute INVALID_STATE_ERR
-[Worker]     attribute NOT_FOUND_ERR
-[Worker]     attribute NOT_READABLE_ERR
-[Worker]     attribute NO_MODIFICATION_ALLOWED_ERR
-[Worker]     attribute PATH_EXISTS_ERR
-[Worker]     attribute QUOTA_EXCEEDED_ERR
-[Worker]     attribute SECURITY_ERR
-[Worker]     attribute SYNTAX_ERR
-[Worker]     attribute TYPE_MISMATCH_ERR
-[Worker]     getter code
-[Worker]     method constructor
 [Worker] interface FileList
 [Worker]     attribute @@toStringTag
 [Worker]     getter length
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt
index e2f80f0..cf2e37e 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt
@@ -214,22 +214,6 @@
 [Worker]     getter name
 [Worker]     getter webkitRelativePath
 [Worker]     method constructor
-[Worker] interface FileError : DOMError
-[Worker]     attribute @@toStringTag
-[Worker]     attribute ABORT_ERR
-[Worker]     attribute ENCODING_ERR
-[Worker]     attribute INVALID_MODIFICATION_ERR
-[Worker]     attribute INVALID_STATE_ERR
-[Worker]     attribute NOT_FOUND_ERR
-[Worker]     attribute NOT_READABLE_ERR
-[Worker]     attribute NO_MODIFICATION_ALLOWED_ERR
-[Worker]     attribute PATH_EXISTS_ERR
-[Worker]     attribute QUOTA_EXCEEDED_ERR
-[Worker]     attribute SECURITY_ERR
-[Worker]     attribute SYNTAX_ERR
-[Worker]     attribute TYPE_MISMATCH_ERR
-[Worker]     getter code
-[Worker]     method constructor
 [Worker] interface FileList
 [Worker]     attribute @@toStringTag
 [Worker]     getter length
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
index b166017d..11bac31 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -1716,22 +1716,6 @@
     getter name
     getter webkitRelativePath
     method constructor
-interface FileError : DOMError
-    attribute @@toStringTag
-    attribute ABORT_ERR
-    attribute ENCODING_ERR
-    attribute INVALID_MODIFICATION_ERR
-    attribute INVALID_STATE_ERR
-    attribute NOT_FOUND_ERR
-    attribute NOT_READABLE_ERR
-    attribute NO_MODIFICATION_ALLOWED_ERR
-    attribute PATH_EXISTS_ERR
-    attribute QUOTA_EXCEEDED_ERR
-    attribute SECURITY_ERR
-    attribute SYNTAX_ERR
-    attribute TYPE_MISMATCH_ERR
-    getter code
-    method constructor
 interface FileList
     attribute @@toStringTag
     getter length
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt
index 124b556..ff9fc06 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt
@@ -201,22 +201,6 @@
 [Worker]     getter name
 [Worker]     getter webkitRelativePath
 [Worker]     method constructor
-[Worker] interface FileError : DOMError
-[Worker]     attribute @@toStringTag
-[Worker]     attribute ABORT_ERR
-[Worker]     attribute ENCODING_ERR
-[Worker]     attribute INVALID_MODIFICATION_ERR
-[Worker]     attribute INVALID_STATE_ERR
-[Worker]     attribute NOT_FOUND_ERR
-[Worker]     attribute NOT_READABLE_ERR
-[Worker]     attribute NO_MODIFICATION_ALLOWED_ERR
-[Worker]     attribute PATH_EXISTS_ERR
-[Worker]     attribute QUOTA_EXCEEDED_ERR
-[Worker]     attribute SECURITY_ERR
-[Worker]     attribute SYNTAX_ERR
-[Worker]     attribute TYPE_MISMATCH_ERR
-[Worker]     getter code
-[Worker]     method constructor
 [Worker] interface FileList
 [Worker]     attribute @@toStringTag
 [Worker]     getter length
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi
index c635ed9..756e5034 100644
--- a/third_party/WebKit/Source/core/core.gypi
+++ b/third_party/WebKit/Source/core/core.gypi
@@ -155,7 +155,6 @@
             'fileapi/Blob.idl',
             'fileapi/File.idl',
             'fileapi/BlobCallback.idl',
-            'fileapi/FileError.idl',
             'fileapi/FileList.idl',
             'fileapi/FileReader.idl',
             'fileapi/FileReaderSync.idl',
diff --git a/third_party/WebKit/Source/core/fileapi/FileError.cpp b/third_party/WebKit/Source/core/fileapi/FileError.cpp
index 4e17dd5..0f5813f 100644
--- a/third_party/WebKit/Source/core/fileapi/FileError.cpp
+++ b/third_party/WebKit/Source/core/fileapi/FileError.cpp
@@ -31,52 +31,55 @@
 #include "core/fileapi/FileError.h"
 
 #include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/DOMException.h"
 #include "core/dom/ExceptionCode.h"
 
 namespace blink {
 
-const char FileError::abortErrorMessage[] = "An ongoing operation was aborted, typically with a call to abort().";
-const char FileError::encodingErrorMessage[] = "A URI supplied to the API was malformed, or the resulting Data URL has exceeded the URL length limitations for Data URLs.";
-const char FileError::invalidStateErrorMessage[] = "An operation that depends on state cached in an interface object was made but the state had changed since it was read from disk.";
-const char FileError::noModificationAllowedErrorMessage[] = "An attempt was made to write to a file or directory which could not be modified due to the state of the underlying filesystem.";
-const char FileError::notFoundErrorMessage[] = "A requested file or directory could not be found at the time an operation was processed.";
-const char FileError::notReadableErrorMessage[] = "The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.";
-const char FileError::pathExistsErrorMessage[] = "An attempt was made to create a file or directory where an element already exists.";
-const char FileError::quotaExceededErrorMessage[] = "The operation failed because it would cause the application to exceed its storage quota.";
-const char FileError::securityErrorMessage[] = "It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.";
-const char FileError::syntaxErrorMessage[] = "An invalid or unsupported argument was given, like an invalid line ending specifier.";
-const char FileError::typeMismatchErrorMessage[] = "The path supplied exists, but was not an entry of requested type.";
+namespace FileError {
+
+const char abortErrorMessage[] = "An ongoing operation was aborted, typically with a call to abort().";
+const char encodingErrorMessage[] = "A URI supplied to the API was malformed, or the resulting Data URL has exceeded the URL length limitations for Data URLs.";
+const char invalidStateErrorMessage[] = "An operation that depends on state cached in an interface object was made but the state had changed since it was read from disk.";
+const char noModificationAllowedErrorMessage[] = "An attempt was made to write to a file or directory which could not be modified due to the state of the underlying filesystem.";
+const char notFoundErrorMessage[] = "A requested file or directory could not be found at the time an operation was processed.";
+const char notReadableErrorMessage[] = "The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.";
+const char pathExistsErrorMessage[] = "An attempt was made to create a file or directory where an element already exists.";
+const char quotaExceededErrorMessage[] = "The operation failed because it would cause the application to exceed its storage quota.";
+const char securityErrorMessage[] = "It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.";
+const char syntaxErrorMessage[] = "An invalid or unsupported argument was given, like an invalid line ending specifier.";
+const char typeMismatchErrorMessage[] = "The path supplied exists, but was not an entry of requested type.";
 
 namespace {
 
-ExceptionCode errorCodeToExceptionCode(FileError::ErrorCode code)
+ExceptionCode errorCodeToExceptionCode(ErrorCode code)
 {
     switch (code) {
-    case FileError::OK:
+    case OK:
         return 0;
-    case FileError::NOT_FOUND_ERR:
+    case NOT_FOUND_ERR:
         return NotFoundError;
-    case FileError::SECURITY_ERR:
+    case SECURITY_ERR:
         return SecurityError;
-    case FileError::ABORT_ERR:
+    case ABORT_ERR:
         return AbortError;
-    case FileError::NOT_READABLE_ERR:
+    case NOT_READABLE_ERR:
         return NotReadableError;
-    case FileError::ENCODING_ERR:
+    case ENCODING_ERR:
         return EncodingError;
-    case FileError::NO_MODIFICATION_ALLOWED_ERR:
+    case NO_MODIFICATION_ALLOWED_ERR:
         return NoModificationAllowedError;
-    case FileError::INVALID_STATE_ERR:
+    case INVALID_STATE_ERR:
         return InvalidStateError;
-    case FileError::SYNTAX_ERR:
+    case SYNTAX_ERR:
         return SyntaxError;
-    case FileError::INVALID_MODIFICATION_ERR:
+    case INVALID_MODIFICATION_ERR:
         return InvalidModificationError;
-    case FileError::QUOTA_EXCEEDED_ERR:
+    case QUOTA_EXCEEDED_ERR:
         return QuotaExceededError;
-    case FileError::TYPE_MISMATCH_ERR:
+    case TYPE_MISMATCH_ERR:
         return TypeMismatchError;
-    case FileError::PATH_EXISTS_ERR:
+    case PATH_EXISTS_ERR:
         return PathExistsError;
     default:
         ASSERT_NOT_REACHED();
@@ -84,36 +87,36 @@
     }
 }
 
-const char* errorCodeToMessage(FileError::ErrorCode code)
+const char* errorCodeToMessage(ErrorCode code)
 {
     // Note that some of these do not set message. If message is 0 then the default message is used.
     switch (code) {
-    case FileError::OK:
+    case OK:
         return 0;
-    case FileError::SECURITY_ERR:
-        return FileError::securityErrorMessage;
-    case FileError::NOT_FOUND_ERR:
-        return FileError::notFoundErrorMessage;
-    case FileError::ABORT_ERR:
-        return FileError::abortErrorMessage;
-    case FileError::NOT_READABLE_ERR:
-        return FileError::notReadableErrorMessage;
-    case FileError::ENCODING_ERR:
-        return FileError::encodingErrorMessage;
-    case FileError::NO_MODIFICATION_ALLOWED_ERR:
-        return FileError::noModificationAllowedErrorMessage;
-    case FileError::INVALID_STATE_ERR:
-        return FileError::invalidStateErrorMessage;
-    case FileError::SYNTAX_ERR:
-        return FileError::syntaxErrorMessage;
-    case FileError::INVALID_MODIFICATION_ERR:
+    case SECURITY_ERR:
+        return securityErrorMessage;
+    case NOT_FOUND_ERR:
+        return notFoundErrorMessage;
+    case ABORT_ERR:
+        return abortErrorMessage;
+    case NOT_READABLE_ERR:
+        return notReadableErrorMessage;
+    case ENCODING_ERR:
+        return encodingErrorMessage;
+    case NO_MODIFICATION_ALLOWED_ERR:
+        return noModificationAllowedErrorMessage;
+    case INVALID_STATE_ERR:
+        return invalidStateErrorMessage;
+    case SYNTAX_ERR:
+        return syntaxErrorMessage;
+    case INVALID_MODIFICATION_ERR:
         return 0;
-    case FileError::QUOTA_EXCEEDED_ERR:
-        return FileError::quotaExceededErrorMessage;
-    case FileError::TYPE_MISMATCH_ERR:
+    case QUOTA_EXCEEDED_ERR:
+        return quotaExceededErrorMessage;
+    case TYPE_MISMATCH_ERR:
         return 0;
-    case FileError::PATH_EXISTS_ERR:
-        return FileError::pathExistsErrorMessage;
+    case PATH_EXISTS_ERR:
+        return pathExistsErrorMessage;
     default:
         ASSERT_NOT_REACHED();
         return 0;
@@ -122,24 +125,26 @@
 
 } // namespace
 
-void FileError::throwDOMException(ExceptionState& exceptionState, ErrorCode code)
+void throwDOMException(ExceptionState& exceptionState, ErrorCode code)
 {
-    if (code == FileError::OK)
+    if (code == OK)
         return;
 
     // SecurityError is special-cased, as we want to route those exceptions through ExceptionState::throwSecurityError.
-    if (code == FileError::SECURITY_ERR) {
-        exceptionState.throwSecurityError(FileError::securityErrorMessage);
+    if (code == SECURITY_ERR) {
+        exceptionState.throwSecurityError(securityErrorMessage);
         return;
     }
 
     exceptionState.throwDOMException(errorCodeToExceptionCode(code), errorCodeToMessage(code));
 }
 
-FileError::FileError(ErrorCode code)
-    : DOMError(DOMException::getErrorName(errorCodeToExceptionCode(code)), errorCodeToMessage(code))
-    , m_code(code)
+DOMException* createDOMException(ErrorCode code)
 {
+    DCHECK_NE(code, OK);
+    return DOMException::create(errorCodeToExceptionCode(code), errorCodeToMessage(code));
 }
 
+} // namespace FileError
+
 } // namespace blink
diff --git a/third_party/WebKit/Source/core/fileapi/FileError.h b/third_party/WebKit/Source/core/fileapi/FileError.h
index 0d9c65f..2c18bd1 100644
--- a/third_party/WebKit/Source/core/fileapi/FileError.h
+++ b/third_party/WebKit/Source/core/fileapi/FileError.h
@@ -31,18 +31,15 @@
 #ifndef FileError_h
 #define FileError_h
 
-#include "bindings/core/v8/ScriptWrappable.h"
 #include "core/CoreExport.h"
-#include "core/dom/DOMError.h"
-#include "platform/heap/Handle.h"
 
 namespace blink {
 
+class DOMException;
 class ExceptionState;
 
-class CORE_EXPORT FileError final : public DOMError {
-    DEFINE_WRAPPERTYPEINFO();
-public:
+namespace FileError {
+
     enum ErrorCode {
         OK = 0,
         NOT_FOUND_ERR = 1,
@@ -59,32 +56,22 @@
         PATH_EXISTS_ERR = 12,
     };
 
-    static const char abortErrorMessage[];
-    static const char encodingErrorMessage[];
-    static const char invalidStateErrorMessage[];
-    static const char noModificationAllowedErrorMessage[];
-    static const char notFoundErrorMessage[];
-    static const char notReadableErrorMessage[];
-    static const char pathExistsErrorMessage[];
-    static const char quotaExceededErrorMessage[];
-    static const char securityErrorMessage[];
-    static const char syntaxErrorMessage[];
-    static const char typeMismatchErrorMessage[];
+    CORE_EXPORT extern const char abortErrorMessage[];
+    CORE_EXPORT extern const char encodingErrorMessage[];
+    CORE_EXPORT extern const char invalidStateErrorMessage[];
+    CORE_EXPORT extern const char noModificationAllowedErrorMessage[];
+    CORE_EXPORT extern const char notFoundErrorMessage[];
+    CORE_EXPORT extern const char notReadableErrorMessage[];
+    CORE_EXPORT extern const char pathExistsErrorMessage[];
+    CORE_EXPORT extern const char quotaExceededErrorMessage[];
+    CORE_EXPORT extern const char securityErrorMessage[];
+    CORE_EXPORT extern const char syntaxErrorMessage[];
+    CORE_EXPORT extern const char typeMismatchErrorMessage[];
 
-    static FileError* create(ErrorCode code)
-    {
-        return new FileError(code);
-    }
+    CORE_EXPORT void throwDOMException(ExceptionState&, ErrorCode);
+    CORE_EXPORT DOMException* createDOMException(ErrorCode);
 
-    ErrorCode code() const { return m_code; }
-
-    static void throwDOMException(ExceptionState&, ErrorCode);
-
-private:
-    explicit FileError(ErrorCode);
-
-    ErrorCode m_code;
-};
+} // namespace FileError
 
 } // namespace blink
 
diff --git a/third_party/WebKit/Source/core/fileapi/FileError.idl b/third_party/WebKit/Source/core/fileapi/FileError.idl
deleted file mode 100644
index b8c2904..0000000
--- a/third_party/WebKit/Source/core/fileapi/FileError.idl
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// TODO(foolip): Remove the FileError interface. crbug.com/496901
-[Exposed=(Window,Worker)]
-interface FileError : DOMError {
-    const unsigned short NOT_FOUND_ERR = 1;
-    const unsigned short SECURITY_ERR = 2;
-    const unsigned short ABORT_ERR = 3;
-    const unsigned short NOT_READABLE_ERR = 4;
-    const unsigned short ENCODING_ERR = 5;
-    const unsigned short NO_MODIFICATION_ALLOWED_ERR = 6;
-    const unsigned short INVALID_STATE_ERR = 7;
-    const unsigned short SYNTAX_ERR = 8;
-    const unsigned short INVALID_MODIFICATION_ERR = 9;
-    const unsigned short QUOTA_EXCEEDED_ERR = 10;
-    const unsigned short TYPE_MISMATCH_ERR = 11;
-    const unsigned short PATH_EXISTS_ERR = 12;
-
-    [DeprecateAs=FileError] readonly attribute unsigned short code;
-};
diff --git a/third_party/WebKit/Source/core/fileapi/FileReader.cpp b/third_party/WebKit/Source/core/fileapi/FileReader.cpp
index f1d3237..eba2df1 100644
--- a/third_party/WebKit/Source/core/fileapi/FileReader.cpp
+++ b/third_party/WebKit/Source/core/fileapi/FileReader.cpp
@@ -347,7 +347,7 @@
 
     terminate();
 
-    m_error = FileError::create(FileError::ABORT_ERR);
+    m_error = FileError::createDOMException(FileError::ABORT_ERR);
 
     // Unregister the reader.
     ThrottlingController::FinishReaderType finalStep = ThrottlingController::removeReader(getExecutionContext(), this);
@@ -446,7 +446,7 @@
     ASSERT(m_state != DONE);
     m_state = DONE;
 
-    m_error = FileError::create(static_cast<FileError::ErrorCode>(errorCode));
+    m_error = FileError::createDOMException(static_cast<FileError::ErrorCode>(errorCode));
 
     // Unregister the reader.
     ThrottlingController::FinishReaderType finalStep = ThrottlingController::removeReader(getExecutionContext(), this);
diff --git a/third_party/WebKit/Source/core/fileapi/FileReader.h b/third_party/WebKit/Source/core/fileapi/FileReader.h
index d960570..c619f9e 100644
--- a/third_party/WebKit/Source/core/fileapi/FileReader.h
+++ b/third_party/WebKit/Source/core/fileapi/FileReader.h
@@ -73,7 +73,7 @@
     void doAbort();
 
     ReadyState getReadyState() const { return m_state; }
-    FileError* error() { return m_error; }
+    DOMException* error() { return m_error; }
     void result(StringOrArrayBuffer& resultAttribute) const;
 
     // ActiveDOMObject
@@ -131,7 +131,7 @@
     String m_encoding;
 
     std::unique_ptr<FileReaderLoader> m_loader;
-    Member<FileError> m_error;
+    Member<DOMException> m_error;
     double m_lastProgressNotificationTimeMS;
 };
 
diff --git a/third_party/WebKit/Source/core/fileapi/FileReader.idl b/third_party/WebKit/Source/core/fileapi/FileReader.idl
index f3bb0f1..d44da50 100644
--- a/third_party/WebKit/Source/core/fileapi/FileReader.idl
+++ b/third_party/WebKit/Source/core/fileapi/FileReader.idl
@@ -58,8 +58,8 @@
     // File or Blob data
     readonly attribute (DOMString or ArrayBuffer)? result;
 
-    // TODO(foolip): error should be DOMError. crbug.com/496901
-    [Measure] readonly attribute FileError? error;
+    // TODO(jsbell): Spec has DOMError, which is being deprecated.
+    readonly attribute DOMException? error;
 
     // event handler attributes
     attribute EventHandler onloadstart;
diff --git a/third_party/WebKit/Source/core/frame/Deprecation.cpp b/third_party/WebKit/Source/core/frame/Deprecation.cpp
index f578e0ae..15937cb 100644
--- a/third_party/WebKit/Source/core/frame/Deprecation.cpp
+++ b/third_party/WebKit/Source/core/frame/Deprecation.cpp
@@ -179,9 +179,6 @@
     case UseCounter::ConsoleMarkTimeline:
         return replacedBy("'console.markTimeline'", "'console.timeStamp'");
 
-    case UseCounter::FileError:
-        return String::format("'FileError is deprecated and will be removed in %s. Please use the 'name' or 'message' attributes of the error rather than 'code'. See https://www.chromestatus.com/features/6687420359639040 for more details.", milestoneString(54));
-
     case UseCounter::CSSStyleSheetInsertRuleOptionalArg:
         return "Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).";
 
diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h
index b3880fa..c8417f0 100644
--- a/third_party/WebKit/Source/core/frame/UseCounter.h
+++ b/third_party/WebKit/Source/core/frame/UseCounter.h
@@ -139,7 +139,6 @@
         NavigatorProductSub = 123,
         NavigatorVendor = 124,
         NavigatorVendorSub = 125,
-        FileError = 126,
         PrefixedAnimationEndEvent = 128,
         UnprefixedAnimationEndEvent = 129,
         PrefixedAndUnprefixedAnimationEndEvent = 130,
diff --git a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
index d8ad4a8..5fbfa1a 100644
--- a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
+++ b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
@@ -31,6 +31,7 @@
 #include "core/imagebitmap/ImageBitmapFactories.h"
 
 #include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/DOMException.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/fileapi/Blob.h"
 #include "core/frame/ImageBitmap.h"
diff --git a/third_party/WebKit/Source/devtools/front_end/devtools.js b/third_party/WebKit/Source/devtools/front_end/devtools.js
index 9618a14..f2a1325 100644
--- a/third_party/WebKit/Source/devtools/front_end/devtools.js
+++ b/third_party/WebKit/Source/devtools/front_end/devtools.js
@@ -1077,6 +1077,7 @@
 
 /**
  * @suppressGlobalPropertiesCheck
+ * @suppress {checkTypes}
  */
 function installBackwardsCompatibility()
 {
@@ -1140,6 +1141,14 @@
 
     // Support for legacy (<M49) frontends.
     Event.prototype.deepPath = undefined;
+
+    // Support for legacy (<53) frontends.
+    window.FileError = {
+        NOT_FOUND_ERR: DOMException.NOT_FOUND_ERR,
+        ABORT_ERR: DOMException.ABORT_ERR,
+        INVALID_MODIFICATION_ERR: DOMException.INVALID_MODIFICATION_ERR,
+        NOT_READABLE_ERR: 0  // No matching DOMException, so code will be 0.
+    };
 }
 
 function windowLoaded()
diff --git a/third_party/WebKit/Source/devtools/front_end/externs.js b/third_party/WebKit/Source/devtools/front_end/externs.js
index 3efe70a..3d2ac15 100644
--- a/third_party/WebKit/Source/devtools/front_end/externs.js
+++ b/third_party/WebKit/Source/devtools/front_end/externs.js
@@ -757,3 +757,10 @@
     /** @type {(string|!Array<!Gonzales.Node>)} */
     this.content;
 }
+
+/**
+ * @type {string}
+ * @see http://heycam.github.io/webidl/#es-DOMException-prototype-object
+ * TODO(jsbell): DOMException should be a subclass of Error.
+ */
+DOMException.prototype.message;
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLoader.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLoader.js
index 4d318ba..96bd1e1 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLoader.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLoader.js
@@ -214,14 +214,14 @@
      */
     onError: function(reader, event)
     {
-        switch (event.target.error.code) {
-        case FileError.NOT_FOUND_ERR:
+        switch (event.target.error.name) {
+        case 'NotFoundError':
             this._reportErrorAndCancelLoading(WebInspector.UIString("File \"%s\" not found.", reader.fileName()));
             break;
-        case FileError.NOT_READABLE_ERR:
+        case 'NotReadableError':
             this._reportErrorAndCancelLoading(WebInspector.UIString("File \"%s\" is not readable", reader.fileName()));
             break;
-        case FileError.ABORT_ERR:
+        case 'AbortError':
             break;
         default:
             this._reportErrorAndCancelLoading(WebInspector.UIString("An error occurred while reading the file \"%s\"", reader.fileName()));
diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/IsolatedFileSystem.js b/third_party/WebKit/Source/devtools/front_end/workspace/IsolatedFileSystem.js
index c3983ea..53330ea 100644
--- a/third_party/WebKit/Source/devtools/front_end/workspace/IsolatedFileSystem.js
+++ b/third_party/WebKit/Source/devtools/front_end/workspace/IsolatedFileSystem.js
@@ -96,7 +96,7 @@
 }
 
 /**
- * @param {!FileError} error
+ * @param {!DOMException} error
  * @return {string}
  */
 WebInspector.IsolatedFileSystem.errorMessage = function(error)
@@ -216,7 +216,7 @@
              */
             function fileCreationError(error)
             {
-                if (error.code === FileError.INVALID_MODIFICATION_ERR) {
+                if (error.name === 'InvalidModificationError') {
                     dirEntryLoaded.call(this, dirEntry);
                     return;
                 }
@@ -264,6 +264,8 @@
         /**
          * @param {!FileError} error
          * @this {WebInspector.IsolatedFileSystem}
+         * @suppress {checkTypes}
+         * TODO(jsbell): Update externs replacing FileError with DOMException. https://crbug.com/496901
          */
         function errorHandler(error)
         {
@@ -322,7 +324,7 @@
          */
         function errorHandler(error)
         {
-            if (error.code === FileError.NOT_FOUND_ERR) {
+            if (error.name === 'NotFoundError') {
                 callback(null);
                 return;
             }
@@ -436,7 +438,7 @@
          */
         function newFileEntryLoadErrorHandler(error)
         {
-            if (error.code !== FileError.NOT_FOUND_ERR) {
+            if (error.name !== 'NotFoundError') {
                 callback(false);
                 return;
             }
diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp b/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp
index ce734f4..79551d0 100644
--- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp
@@ -33,7 +33,6 @@
 #include "core/fileapi/BlobCallback.h"
 #include "modules/filesystem/DOMFilePath.h"
 #include "modules/filesystem/DirectoryEntry.h"
-#include "modules/filesystem/ErrorCallback.h"
 #include "modules/filesystem/FileEntry.h"
 #include "modules/filesystem/FileSystemCallbacks.h"
 #include "modules/filesystem/FileWriter.h"
@@ -115,15 +114,15 @@
     return m_numberOfPendingCallbacks;
 }
 
-void DOMFileSystem::reportError(ErrorCallback* errorCallback, FileError* fileError)
+void DOMFileSystem::reportError(ErrorCallbackBase* errorCallback, FileError::ErrorCode fileError)
 {
     reportError(getExecutionContext(), errorCallback, fileError);
 }
 
-void DOMFileSystem::reportError(ExecutionContext* executionContext, ErrorCallback* errorCallback, FileError* fileError)
+void DOMFileSystem::reportError(ExecutionContext* executionContext, ErrorCallbackBase* errorCallback, FileError::ErrorCode fileError)
 {
     if (errorCallback)
-        scheduleCallback(executionContext, createSameThreadTask(&ErrorCallback::handleEvent, wrapPersistent(errorCallback), wrapPersistent(fileError)));
+        scheduleCallback(executionContext, createSameThreadTask(&ErrorCallbackBase::invoke, wrapPersistent(errorCallback), fileError));
 }
 
 namespace {
@@ -155,12 +154,12 @@
 
 } // namespace
 
-void DOMFileSystem::createWriter(const FileEntry* fileEntry, FileWriterCallback* successCallback, ErrorCallback* errorCallback)
+void DOMFileSystem::createWriter(const FileEntry* fileEntry, FileWriterCallback* successCallback, ErrorCallbackBase* errorCallback)
 {
     ASSERT(fileEntry);
 
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
@@ -170,11 +169,11 @@
     fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, std::move(callbacks));
 }
 
-void DOMFileSystem::createFile(const FileEntry* fileEntry, BlobCallback* successCallback, ErrorCallback* errorCallback)
+void DOMFileSystem::createFile(const FileEntry* fileEntry, BlobCallback* successCallback, ErrorCallbackBase* errorCallback)
 {
     KURL fileSystemURL = createFileSystemURL(fileEntry);
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.h b/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.h
index 4f40348..9d74798 100644
--- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.h
+++ b/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.h
@@ -64,15 +64,15 @@
     // DOMFileSystemBase overrides.
     void addPendingCallbacks() override;
     void removePendingCallbacks() override;
-    void reportError(ErrorCallback*, FileError*) override;
+    void reportError(ErrorCallbackBase*, FileError::ErrorCode) override;
 
-    static void reportError(ExecutionContext*, ErrorCallback*, FileError*);
+    static void reportError(ExecutionContext*, ErrorCallbackBase*, FileError::ErrorCode);
 
     // ActiveScriptWrappable overrides.
     bool hasPendingActivity() const final;
 
-    void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallback*);
-    void createFile(const FileEntry*, BlobCallback*, ErrorCallback*);
+    void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallbackBase*);
+    void createFile(const FileEntry*, BlobCallback*, ErrorCallbackBase*);
 
     // Schedule a callback. This should not cross threads (should be called on the same context thread).
     static void scheduleCallback(ExecutionContext* executionContext, std::unique_ptr<ExecutionContextTask> task)
diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp
index 02cf027..f2c280e 100644
--- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp
@@ -41,7 +41,6 @@
 #include "modules/filesystem/Entry.h"
 #include "modules/filesystem/EntryBase.h"
 #include "modules/filesystem/EntryCallback.h"
-#include "modules/filesystem/ErrorCallback.h"
 #include "modules/filesystem/FileSystemCallbacks.h"
 #include "modules/filesystem/MetadataCallback.h"
 #include "platform/weborigin/SecurityOrigin.h"
@@ -215,10 +214,10 @@
     }
 }
 
-void DOMFileSystemBase::getMetadata(const EntryBase* entry, MetadataCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
+void DOMFileSystemBase::getMetadata(const EntryBase* entry, MetadataCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
@@ -256,16 +255,16 @@
     return true;
 }
 
-void DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const String& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
+void DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const String& newName, EntryCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
     String destinationPath;
     if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath)) {
-        reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
@@ -275,16 +274,16 @@
     fileSystem()->move(createFileSystemURL(source), parent->filesystem()->createFileSystemURL(destinationPath), std::move(callbacks));
 }
 
-void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const String& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
+void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const String& newName, EntryCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
     String destinationPath;
     if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath)) {
-        reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
@@ -294,17 +293,17 @@
     fileSystem()->copy(createFileSystemURL(source), parent->filesystem()->createFileSystemURL(destinationPath), std::move(callbacks));
 }
 
-void DOMFileSystemBase::remove(const EntryBase* entry, VoidCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
+void DOMFileSystemBase::remove(const EntryBase* entry, VoidCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
     ASSERT(entry);
     // We don't allow calling remove() on the root directory.
     if (entry->fullPath() == String(DOMFilePath::root)) {
-        reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
@@ -314,17 +313,17 @@
     fileSystem()->remove(createFileSystemURL(entry), std::move(callbacks));
 }
 
-void DOMFileSystemBase::removeRecursively(const EntryBase* entry, VoidCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
+void DOMFileSystemBase::removeRecursively(const EntryBase* entry, VoidCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
     ASSERT(entry && entry->isDirectory());
     // We don't allow calling remove() on the root directory.
     if (entry->fullPath() == String(DOMFilePath::root)) {
-        reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
@@ -334,10 +333,10 @@
     fileSystem()->removeRecursively(createFileSystemURL(entry), std::move(callbacks));
 }
 
-void DOMFileSystemBase::getParent(const EntryBase* entry, EntryCallback* successCallback, ErrorCallback* errorCallback)
+void DOMFileSystemBase::getParent(const EntryBase* entry, EntryCallback* successCallback, ErrorCallbackBase* errorCallback)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
@@ -347,16 +346,16 @@
     fileSystem()->directoryExists(createFileSystemURL(path), EntryCallbacks::create(successCallback, errorCallback, m_context, this, path, true));
 }
 
-void DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
+void DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
     String absolutePath;
     if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) {
-        reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
@@ -369,16 +368,16 @@
         fileSystem()->fileExists(createFileSystemURL(absolutePath), std::move(callbacks));
 }
 
-void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path, const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
+void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path, const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return;
     }
 
     String absolutePath;
     if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) {
-        reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
@@ -391,10 +390,10 @@
         fileSystem()->directoryExists(createFileSystemURL(absolutePath), std::move(callbacks));
 }
 
-int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String& path, EntriesCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
+int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String& path, EntriesCallback* successCallback, ErrorCallbackBase* errorCallback, SynchronousType synchronousType)
 {
     if (!fileSystem()) {
-        reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
+        reportError(errorCallback, FileError::ABORT_ERR);
         return 0;
     }
 
diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.h b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.h
index 5473f5d..4fe751b 100644
--- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.h
+++ b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.h
@@ -31,6 +31,7 @@
 #ifndef DOMFileSystemBase_h
 #define DOMFileSystemBase_h
 
+#include "core/fileapi/FileError.h"
 #include "modules/ModulesExport.h"
 #include "modules/filesystem/FileSystemFlags.h"
 #include "platform/FileSystemType.h"
@@ -48,9 +49,8 @@
 class EntriesCallback;
 class EntryBase;
 class EntryCallback;
-class ErrorCallback;
+class ErrorCallbackBase;
 class File;
-class FileError;
 class FileMetadata;
 class MetadataCallback;
 class ExecutionContext;
@@ -81,7 +81,7 @@
     virtual void removePendingCallbacks() { }
 
     // Overridden by subclasses to handle sync vs async error-handling.
-    virtual void reportError(ErrorCallback*, FileError*) = 0;
+    virtual void reportError(ErrorCallbackBase*, FileError::ErrorCode) = 0;
 
     const String& name() const { return m_name; }
     FileSystemType type() const { return m_type; }
@@ -106,15 +106,15 @@
     static File* createFile(const FileMetadata&, const KURL& fileSystemURL, FileSystemType, const String name);
 
     // Actual FileSystem API implementations. All the validity checks on virtual paths are done at this level.
-    void getMetadata(const EntryBase*, MetadataCallback*, ErrorCallback*, SynchronousType = Asynchronous);
-    void move(const EntryBase* source, EntryBase* parent, const String& name, EntryCallback*, ErrorCallback*, SynchronousType = Asynchronous);
-    void copy(const EntryBase* source, EntryBase* parent, const String& name, EntryCallback*, ErrorCallback*, SynchronousType = Asynchronous);
-    void remove(const EntryBase*, VoidCallback*, ErrorCallback*, SynchronousType = Asynchronous);
-    void removeRecursively(const EntryBase*, VoidCallback*, ErrorCallback*, SynchronousType = Asynchronous);
-    void getParent(const EntryBase*, EntryCallback*, ErrorCallback*);
-    void getFile(const EntryBase*, const String& path, const FileSystemFlags&, EntryCallback*, ErrorCallback*, SynchronousType = Asynchronous);
-    void getDirectory(const EntryBase*, const String& path, const FileSystemFlags&, EntryCallback*, ErrorCallback*, SynchronousType = Asynchronous);
-    int readDirectory(DirectoryReaderBase*, const String& path, EntriesCallback*, ErrorCallback*, SynchronousType = Asynchronous);
+    void getMetadata(const EntryBase*, MetadataCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous);
+    void move(const EntryBase* source, EntryBase* parent, const String& name, EntryCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous);
+    void copy(const EntryBase* source, EntryBase* parent, const String& name, EntryCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous);
+    void remove(const EntryBase*, VoidCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous);
+    void removeRecursively(const EntryBase*, VoidCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous);
+    void getParent(const EntryBase*, EntryCallback*, ErrorCallbackBase*);
+    void getFile(const EntryBase*, const String& path, const FileSystemFlags&, EntryCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous);
+    void getDirectory(const EntryBase*, const String& path, const FileSystemFlags&, EntryCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous);
+    int readDirectory(DirectoryReaderBase*, const String& path, EntriesCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous);
     bool waitForAdditionalResult(int callbacksId);
 
     DECLARE_VIRTUAL_TRACE();
diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemSync.cpp b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemSync.cpp
index e57da4d..59c2136 100644
--- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemSync.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemSync.cpp
@@ -65,9 +65,9 @@
 {
 }
 
-void DOMFileSystemSync::reportError(ErrorCallback* errorCallback, FileError* fileError)
+void DOMFileSystemSync::reportError(ErrorCallbackBase* errorCallback, FileError::ErrorCode fileError)
 {
-    errorCallback->handleEvent(fileError);
+    errorCallback->invoke(fileError);
 }
 
 DirectoryEntrySync* DOMFileSystemSync::root()
@@ -181,17 +181,17 @@
     }
 };
 
-class LocalErrorCallback final : public ErrorCallback {
+class LocalErrorCallback final : public ErrorCallbackBase {
 public:
     static LocalErrorCallback* create(FileError::ErrorCode& errorCode)
     {
         return new LocalErrorCallback(errorCode);
     }
 
-    void handleEvent(FileError* error) override
+    void invoke(FileError::ErrorCode error) override
     {
-        ASSERT(error->code() != FileError::OK);
-        m_errorCode = error->code();
+        DCHECK_NE(error, FileError::OK);
+        m_errorCode = error;
     }
 
 private:
diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemSync.h b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemSync.h
index 4e59b33..de921b2 100644
--- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemSync.h
+++ b/third_party/WebKit/Source/modules/filesystem/DOMFileSystemSync.h
@@ -55,7 +55,7 @@
 
     ~DOMFileSystemSync() override;
 
-    void reportError(ErrorCallback*, FileError*) override;
+    void reportError(ErrorCallbackBase*, FileError::ErrorCode) override;
 
     DirectoryEntrySync* root();
 
diff --git a/third_party/WebKit/Source/modules/filesystem/DOMWindowFileSystem.cpp b/third_party/WebKit/Source/modules/filesystem/DOMWindowFileSystem.cpp
index 5eee230..fcfb42f 100644
--- a/third_party/WebKit/Source/modules/filesystem/DOMWindowFileSystem.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DOMWindowFileSystem.cpp
@@ -55,17 +55,17 @@
         UseCounter::count(document, UseCounter::RequestFileSystemNonWebbyOrigin);
 
     if (!document->getSecurityOrigin()->canAccessFileSystem()) {
-        DOMFileSystem::reportError(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
+        DOMFileSystem::reportError(document, ScriptErrorCallback::wrap(errorCallback), FileError::SECURITY_ERR);
         return;
     }
 
     FileSystemType fileSystemType = static_cast<FileSystemType>(type);
     if (!DOMFileSystemBase::isValidType(fileSystemType)) {
-        DOMFileSystem::reportError(document, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        DOMFileSystem::reportError(document, ScriptErrorCallback::wrap(errorCallback), FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
-    LocalFileSystem::from(*document)->requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, document, fileSystemType));
+    LocalFileSystem::from(*document)->requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, ScriptErrorCallback::wrap(errorCallback), document, fileSystemType));
 }
 
 void DOMWindowFileSystem::webkitResolveLocalFileSystemURL(DOMWindow& windowArg, const String& url, EntryCallback* successCallback, ErrorCallback* errorCallback)
@@ -81,16 +81,16 @@
     SecurityOrigin* securityOrigin = document->getSecurityOrigin();
     KURL completedURL = document->completeURL(url);
     if (!securityOrigin->canAccessFileSystem() || !securityOrigin->canRequest(completedURL)) {
-        DOMFileSystem::reportError(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
+        DOMFileSystem::reportError(document, ScriptErrorCallback::wrap(errorCallback), FileError::SECURITY_ERR);
         return;
     }
 
     if (!completedURL.isValid()) {
-        DOMFileSystem::reportError(document, errorCallback, FileError::create(FileError::ENCODING_ERR));
+        DOMFileSystem::reportError(document, ScriptErrorCallback::wrap(errorCallback), FileError::ENCODING_ERR);
         return;
     }
 
-    LocalFileSystem::from(*document)->resolveURL(document, completedURL, ResolveURICallbacks::create(successCallback, errorCallback, document));
+    LocalFileSystem::from(*document)->resolveURL(document, completedURL, ResolveURICallbacks::create(successCallback, ScriptErrorCallback::wrap(errorCallback), document));
 }
 
 static_assert(static_cast<int>(DOMWindowFileSystem::TEMPORARY) == static_cast<int>(FileSystemTypeTemporary), "DOMWindowFileSystem::TEMPORARY should match FileSystemTypeTemporary");
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp b/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp
index b3a274d..983474c3 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryEntry.cpp
@@ -35,6 +35,7 @@
 #include "modules/filesystem/DirectoryReader.h"
 #include "modules/filesystem/EntryCallback.h"
 #include "modules/filesystem/ErrorCallback.h"
+#include "modules/filesystem/FileSystemCallbacks.h"
 #include "modules/filesystem/FileSystemFlags.h"
 
 namespace blink {
@@ -51,17 +52,17 @@
 
 void DirectoryEntry::getFile(const String& path, const FileSystemFlags& options, EntryCallback* successCallback, ErrorCallback* errorCallback)
 {
-    m_fileSystem->getFile(this, path, options, successCallback, errorCallback);
+    m_fileSystem->getFile(this, path, options, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 void DirectoryEntry::getDirectory(const String& path, const FileSystemFlags& options, EntryCallback* successCallback, ErrorCallback* errorCallback)
 {
-    m_fileSystem->getDirectory(this, path, options, successCallback, errorCallback);
+    m_fileSystem->getDirectory(this, path, options, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 void DirectoryEntry::removeRecursively(VoidCallback* successCallback, ErrorCallback* errorCallback) const
 {
-    m_fileSystem->removeRecursively(this, successCallback, errorCallback);
+    m_fileSystem->removeRecursively(this, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 DEFINE_TRACE(DirectoryEntry)
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryReader.cpp b/third_party/WebKit/Source/modules/filesystem/DirectoryReader.cpp
index cda4d57..d3627f3 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryReader.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryReader.cpp
@@ -34,6 +34,7 @@
 #include "modules/filesystem/EntriesCallback.h"
 #include "modules/filesystem/Entry.h"
 #include "modules/filesystem/ErrorCallback.h"
+#include "modules/filesystem/FileSystemCallbacks.h"
 
 namespace blink {
 
@@ -60,14 +61,14 @@
     Member<DirectoryReader> m_reader;
 };
 
-class DirectoryReader::ErrorCallbackHelper final : public ErrorCallback {
+class DirectoryReader::ErrorCallbackHelper final : public ErrorCallbackBase {
 public:
     explicit ErrorCallbackHelper(DirectoryReader* reader)
         : m_reader(reader)
     {
     }
 
-    void handleEvent(FileError* error) override
+    void invoke(FileError::ErrorCode error) override
     {
         m_reader->onError(error);
     }
@@ -75,7 +76,7 @@
     DEFINE_INLINE_VIRTUAL_TRACE()
     {
         visitor->trace(m_reader);
-        ErrorCallback::trace(visitor);
+        ErrorCallbackBase::trace(visitor);
     }
 
 private:
@@ -100,13 +101,13 @@
     }
 
     if (m_error) {
-        filesystem()->reportError(errorCallback, m_error.get());
+        filesystem()->reportError(ScriptErrorCallback::wrap(errorCallback), m_error);
         return;
     }
 
     if (m_entriesCallback) {
         // Non-null m_entriesCallback means multiple readEntries() calls are made concurrently. We don't allow doing it.
-        filesystem()->reportError(errorCallback, FileError::create(FileError::INVALID_STATE_ERR));
+        filesystem()->reportError(ScriptErrorCallback::wrap(errorCallback), FileError::INVALID_STATE_ERR);
         return;
     }
 
@@ -133,20 +134,17 @@
     }
 }
 
-void DirectoryReader::onError(FileError* error)
+void DirectoryReader::onError(FileError::ErrorCode error)
 {
     m_error = error;
     m_entriesCallback = nullptr;
-    if (m_errorCallback) {
-        ErrorCallback* errorCallback = m_errorCallback.release();
-        errorCallback->handleEvent(error);
-    }
+    if (m_errorCallback)
+        m_errorCallback->handleEvent(FileError::createDOMException(error));
 }
 
 DEFINE_TRACE(DirectoryReader)
 {
     visitor->trace(m_entries);
-    visitor->trace(m_error);
     visitor->trace(m_entriesCallback);
     visitor->trace(m_errorCallback);
     DirectoryReaderBase::trace(visitor);
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryReader.h b/third_party/WebKit/Source/modules/filesystem/DirectoryReader.h
index 45d8b1b..7eb8107d 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryReader.h
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryReader.h
@@ -66,11 +66,11 @@
 
     void addEntries(const EntryHeapVector& entries);
 
-    void onError(FileError*);
+    void onError(FileError::ErrorCode);
 
     bool m_isReading;
     EntryHeapVector m_entries;
-    Member<FileError> m_error;
+    FileError::ErrorCode m_error = FileError::ErrorCode::OK;
     Member<EntriesCallback> m_entriesCallback;
     Member<ErrorCallback> m_errorCallback;
 };
diff --git a/third_party/WebKit/Source/modules/filesystem/DirectoryReaderSync.cpp b/third_party/WebKit/Source/modules/filesystem/DirectoryReaderSync.cpp
index 6fcb188..c1652f1 100644
--- a/third_party/WebKit/Source/modules/filesystem/DirectoryReaderSync.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/DirectoryReaderSync.cpp
@@ -37,6 +37,7 @@
 #include "modules/filesystem/EntrySync.h"
 #include "modules/filesystem/ErrorCallback.h"
 #include "modules/filesystem/FileEntrySync.h"
+#include "modules/filesystem/FileSystemCallbacks.h"
 
 namespace blink {
 
@@ -66,22 +67,22 @@
     Member<DirectoryReaderSync> m_reader;
 };
 
-class DirectoryReaderSync::ErrorCallbackHelper final : public ErrorCallback {
+class DirectoryReaderSync::ErrorCallbackHelper final : public ErrorCallbackBase {
 public:
     explicit ErrorCallbackHelper(DirectoryReaderSync* reader)
         : m_reader(reader)
     {
     }
 
-    void handleEvent(FileError* error) override
+    void invoke(FileError::ErrorCode error) override
     {
-        m_reader->setError(error->code());
+        m_reader->setError(error);
     }
 
     DEFINE_INLINE_VIRTUAL_TRACE()
     {
         visitor->trace(m_reader);
-        ErrorCallback::trace(visitor);
+        ErrorCallbackBase::trace(visitor);
     }
 
 private:
diff --git a/third_party/WebKit/Source/modules/filesystem/Entry.cpp b/third_party/WebKit/Source/modules/filesystem/Entry.cpp
index 159bc40..32b5f80 100644
--- a/third_party/WebKit/Source/modules/filesystem/Entry.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/Entry.cpp
@@ -59,35 +59,35 @@
 {
     if (m_fileSystem->type() == FileSystemTypeIsolated)
         UseCounter::count(context, UseCounter::Entry_GetMetadata_Method_IsolatedFileSystem);
-    m_fileSystem->getMetadata(this, successCallback, errorCallback);
+    m_fileSystem->getMetadata(this, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 void Entry::moveTo(ExecutionContext* context, DirectoryEntry* parent, const String& name, EntryCallback* successCallback, ErrorCallback* errorCallback) const
 {
     if (m_fileSystem->type() == FileSystemTypeIsolated)
         UseCounter::count(context, UseCounter::Entry_MoveTo_Method_IsolatedFileSystem);
-    m_fileSystem->move(this, parent, name, successCallback, errorCallback);
+    m_fileSystem->move(this, parent, name, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 void Entry::copyTo(ExecutionContext* context, DirectoryEntry* parent, const String& name, EntryCallback* successCallback, ErrorCallback* errorCallback) const
 {
     if (m_fileSystem->type() == FileSystemTypeIsolated)
         UseCounter::count(context, UseCounter::Entry_CopyTo_Method_IsolatedFileSystem);
-    m_fileSystem->copy(this, parent, name, successCallback, errorCallback);
+    m_fileSystem->copy(this, parent, name, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 void Entry::remove(ExecutionContext* context, VoidCallback* successCallback, ErrorCallback* errorCallback) const
 {
     if (m_fileSystem->type() == FileSystemTypeIsolated)
         UseCounter::count(context, UseCounter::Entry_Remove_Method_IsolatedFileSystem);
-    m_fileSystem->remove(this, successCallback, errorCallback);
+    m_fileSystem->remove(this, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 void Entry::getParent(ExecutionContext* context, EntryCallback* successCallback, ErrorCallback* errorCallback) const
 {
     if (m_fileSystem->type() == FileSystemTypeIsolated)
         UseCounter::count(context, UseCounter::Entry_GetParent_Method_IsolatedFileSystem);
-    m_fileSystem->getParent(this, successCallback, errorCallback);
+    m_fileSystem->getParent(this, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 String Entry::toURL(ExecutionContext* context) const
diff --git a/third_party/WebKit/Source/modules/filesystem/ErrorCallback.h b/third_party/WebKit/Source/modules/filesystem/ErrorCallback.h
index 655b495..3c05cec 100644
--- a/third_party/WebKit/Source/modules/filesystem/ErrorCallback.h
+++ b/third_party/WebKit/Source/modules/filesystem/ErrorCallback.h
@@ -35,13 +35,11 @@
 
 namespace blink {
 
-class FileError;
-
 class ErrorCallback : public GarbageCollectedFinalized<ErrorCallback> {
 public:
     virtual ~ErrorCallback() { }
     DEFINE_INLINE_VIRTUAL_TRACE() { }
-    virtual void handleEvent(FileError*) = 0;
+    virtual void handleEvent(DOMException*) = 0;
 };
 
 } // namespace blink
diff --git a/third_party/WebKit/Source/modules/filesystem/ErrorCallback.idl b/third_party/WebKit/Source/modules/filesystem/ErrorCallback.idl
index 8f05cf4..991c587 100644
--- a/third_party/WebKit/Source/modules/filesystem/ErrorCallback.idl
+++ b/third_party/WebKit/Source/modules/filesystem/ErrorCallback.idl
@@ -29,5 +29,5 @@
  */
 
 callback interface ErrorCallback {
-    void handleEvent(FileError error);
+    void handleEvent(DOMException error);
 };
diff --git a/third_party/WebKit/Source/modules/filesystem/FileEntry.cpp b/third_party/WebKit/Source/modules/filesystem/FileEntry.cpp
index 503fa95..ff1f2e2 100644
--- a/third_party/WebKit/Source/modules/filesystem/FileEntry.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/FileEntry.cpp
@@ -34,6 +34,7 @@
 #include "core/fileapi/File.h"
 #include "modules/filesystem/DOMFileSystem.h"
 #include "modules/filesystem/ErrorCallback.h"
+#include "modules/filesystem/FileSystemCallbacks.h"
 #include "modules/filesystem/FileWriterCallback.h"
 
 namespace blink {
@@ -45,12 +46,12 @@
 
 void FileEntry::createWriter(FileWriterCallback* successCallback, ErrorCallback* errorCallback)
 {
-    filesystem()->createWriter(this, successCallback, errorCallback);
+    filesystem()->createWriter(this, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 void FileEntry::file(BlobCallback* successCallback, ErrorCallback* errorCallback)
 {
-    filesystem()->createFile(this, successCallback, errorCallback);
+    filesystem()->createFile(this, successCallback, ScriptErrorCallback::wrap(errorCallback));
 }
 
 DEFINE_TRACE(FileEntry)
diff --git a/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.cpp b/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.cpp
index d4c1a04..133ec39 100644
--- a/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.cpp
@@ -56,7 +56,7 @@
 
 namespace blink {
 
-FileSystemCallbacksBase::FileSystemCallbacksBase(ErrorCallback* errorCallback, DOMFileSystemBase* fileSystem, ExecutionContext* context)
+FileSystemCallbacksBase::FileSystemCallbacksBase(ErrorCallbackBase* errorCallback, DOMFileSystemBase* fileSystem, ExecutionContext* context)
     : m_errorCallback(errorCallback)
     , m_fileSystem(fileSystem)
     , m_executionContext(context)
@@ -74,7 +74,7 @@
 void FileSystemCallbacksBase::didFail(int code)
 {
     if (m_errorCallback)
-        handleEventOrScheduleCallback(m_errorCallback.release(), FileError::create(static_cast<FileError::ErrorCode>(code)));
+        invokeOrScheduleCallback(m_errorCallback.release(), static_cast<FileError::ErrorCode>(code));
 }
 
 bool FileSystemCallbacksBase::shouldScheduleCallback() const
@@ -83,9 +83,22 @@
 }
 
 template <typename CB, typename CBArg>
+void FileSystemCallbacksBase::invokeOrScheduleCallback(CB* callback, CBArg arg)
+{
+    DCHECK(callback);
+    if (callback) {
+        if (shouldScheduleCallback())
+            DOMFileSystem::scheduleCallback(m_executionContext.get(), createSameThreadTask(&CB::invoke, wrapPersistent(callback), arg));
+        else
+            callback->invoke(arg);
+    }
+    m_executionContext.clear();
+}
+
+template <typename CB, typename CBArg>
 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback, CBArg* arg)
 {
-    ASSERT(callback);
+    DCHECK(callback);
     if (callback) {
         if (shouldScheduleCallback())
             DOMFileSystem::scheduleCallback(m_executionContext.get(), createSameThreadTask(&CB::handleEvent, wrapPersistent(callback), wrapPersistent(arg)));
@@ -98,7 +111,7 @@
 template <typename CB>
 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback)
 {
-    ASSERT(callback);
+    DCHECK(callback);
     if (callback) {
         if (shouldScheduleCallback())
             DOMFileSystem::scheduleCallback(m_executionContext.get(), createSameThreadTask(&CB::handleEvent, wrapPersistent(callback)));
@@ -108,14 +121,43 @@
     m_executionContext.clear();
 }
 
+// ScriptErrorCallback --------------------------------------------------------
+
+// static
+ScriptErrorCallback* ScriptErrorCallback::wrap(ErrorCallback* callback)
+{
+    // DOMFileSystem operations take an optional (nullable) callback. If a
+    // script callback was not passed, don't bother creating a dummy wrapper
+    // and checking during invoke().
+    if (!callback)
+        return nullptr;
+    return new ScriptErrorCallback(callback);
+}
+
+DEFINE_TRACE(ScriptErrorCallback)
+{
+    ErrorCallbackBase::trace(visitor);
+    visitor->trace(m_callback);
+}
+
+void ScriptErrorCallback::invoke(FileError::ErrorCode error)
+{
+    m_callback->handleEvent(FileError::createDOMException(error));
+};
+
+ScriptErrorCallback::ScriptErrorCallback(ErrorCallback* callback)
+    : m_callback(callback)
+{
+}
+
 // EntryCallbacks -------------------------------------------------------------
 
-std::unique_ptr<AsyncFileSystemCallbacks> EntryCallbacks::create(EntryCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory)
+std::unique_ptr<AsyncFileSystemCallbacks> EntryCallbacks::create(EntryCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory)
 {
     return wrapUnique(new EntryCallbacks(successCallback, errorCallback, context, fileSystem, expectedPath, isDirectory));
 }
 
-EntryCallbacks::EntryCallbacks(EntryCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory)
+EntryCallbacks::EntryCallbacks(EntryCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory)
     : FileSystemCallbacksBase(errorCallback, fileSystem, context)
     , m_successCallback(successCallback)
     , m_expectedPath(expectedPath)
@@ -135,12 +177,12 @@
 
 // EntriesCallbacks -----------------------------------------------------------
 
-std::unique_ptr<AsyncFileSystemCallbacks> EntriesCallbacks::create(EntriesCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DirectoryReaderBase* directoryReader, const String& basePath)
+std::unique_ptr<AsyncFileSystemCallbacks> EntriesCallbacks::create(EntriesCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, DirectoryReaderBase* directoryReader, const String& basePath)
 {
     return wrapUnique(new EntriesCallbacks(successCallback, errorCallback, context, directoryReader, basePath));
 }
 
-EntriesCallbacks::EntriesCallbacks(EntriesCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DirectoryReaderBase* directoryReader, const String& basePath)
+EntriesCallbacks::EntriesCallbacks(EntriesCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, DirectoryReaderBase* directoryReader, const String& basePath)
     : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem(), context)
     , m_successCallback(successCallback)
     , m_directoryReader(directoryReader)
@@ -169,12 +211,12 @@
 
 // FileSystemCallbacks --------------------------------------------------------
 
-std::unique_ptr<AsyncFileSystemCallbacks> FileSystemCallbacks::create(FileSystemCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, FileSystemType type)
+std::unique_ptr<AsyncFileSystemCallbacks> FileSystemCallbacks::create(FileSystemCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, FileSystemType type)
 {
     return wrapUnique(new FileSystemCallbacks(successCallback, errorCallback, context, type));
 }
 
-FileSystemCallbacks::FileSystemCallbacks(FileSystemCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, FileSystemType type)
+FileSystemCallbacks::FileSystemCallbacks(FileSystemCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, FileSystemType type)
     : FileSystemCallbacksBase(errorCallback, nullptr, context)
     , m_successCallback(successCallback)
     , m_type(type)
@@ -189,12 +231,12 @@
 
 // ResolveURICallbacks --------------------------------------------------------
 
-std::unique_ptr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(EntryCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context)
+std::unique_ptr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(EntryCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context)
 {
     return wrapUnique(new ResolveURICallbacks(successCallback, errorCallback, context));
 }
 
-ResolveURICallbacks::ResolveURICallbacks(EntryCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context)
+ResolveURICallbacks::ResolveURICallbacks(EntryCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context)
     : FileSystemCallbacksBase(errorCallback, nullptr, context)
     , m_successCallback(successCallback)
 {
@@ -207,7 +249,7 @@
 
     String absolutePath;
     if (!DOMFileSystemBase::pathToAbsolutePath(type, root, filePath, absolutePath)) {
-        handleEventOrScheduleCallback(m_errorCallback.release(), FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        invokeOrScheduleCallback(m_errorCallback.release(), FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
@@ -219,12 +261,12 @@
 
 // MetadataCallbacks ----------------------------------------------------------
 
-std::unique_ptr<AsyncFileSystemCallbacks> MetadataCallbacks::create(MetadataCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
+std::unique_ptr<AsyncFileSystemCallbacks> MetadataCallbacks::create(MetadataCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
 {
     return wrapUnique(new MetadataCallbacks(successCallback, errorCallback, context, fileSystem));
 }
 
-MetadataCallbacks::MetadataCallbacks(MetadataCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
+MetadataCallbacks::MetadataCallbacks(MetadataCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
     : FileSystemCallbacksBase(errorCallback, fileSystem, context)
     , m_successCallback(successCallback)
 {
@@ -238,12 +280,12 @@
 
 // FileWriterBaseCallbacks ----------------------------------------------------
 
-std::unique_ptr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(FileWriterBase* fileWriter, FileWriterBaseCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context)
+std::unique_ptr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(FileWriterBase* fileWriter, FileWriterBaseCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context)
 {
     return wrapUnique(new FileWriterBaseCallbacks(fileWriter, successCallback, errorCallback, context));
 }
 
-FileWriterBaseCallbacks::FileWriterBaseCallbacks(FileWriterBase* fileWriter, FileWriterBaseCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context)
+FileWriterBaseCallbacks::FileWriterBaseCallbacks(FileWriterBase* fileWriter, FileWriterBaseCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context)
     : FileSystemCallbacksBase(errorCallback, nullptr, context)
     , m_fileWriter(fileWriter)
     , m_successCallback(successCallback)
@@ -259,12 +301,12 @@
 
 // SnapshotFileCallback -------------------------------------------------------
 
-std::unique_ptr<AsyncFileSystemCallbacks> SnapshotFileCallback::create(DOMFileSystemBase* filesystem, const String& name, const KURL& url, BlobCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context)
+std::unique_ptr<AsyncFileSystemCallbacks> SnapshotFileCallback::create(DOMFileSystemBase* filesystem, const String& name, const KURL& url, BlobCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context)
 {
     return wrapUnique(new SnapshotFileCallback(filesystem, name, url, successCallback, errorCallback, context));
 }
 
-SnapshotFileCallback::SnapshotFileCallback(DOMFileSystemBase* filesystem, const String& name, const KURL& url, BlobCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context)
+SnapshotFileCallback::SnapshotFileCallback(DOMFileSystemBase* filesystem, const String& name, const KURL& url, BlobCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context)
     : FileSystemCallbacksBase(errorCallback, filesystem, context)
     , m_name(name)
     , m_url(url)
@@ -287,12 +329,12 @@
 
 // VoidCallbacks --------------------------------------------------------------
 
-std::unique_ptr<AsyncFileSystemCallbacks> VoidCallbacks::create(VoidCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
+std::unique_ptr<AsyncFileSystemCallbacks> VoidCallbacks::create(VoidCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
 {
     return wrapUnique(new VoidCallbacks(successCallback, errorCallback, context, fileSystem));
 }
 
-VoidCallbacks::VoidCallbacks(VoidCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
+VoidCallbacks::VoidCallbacks(VoidCallback* successCallback, ErrorCallbackBase* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
     : FileSystemCallbacksBase(errorCallback, fileSystem, context)
     , m_successCallback(successCallback)
 {
diff --git a/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.h b/third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.h
index 937f0573..39a169c1 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 @@
 
 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 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 @@
     // 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 @@
 
 // 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 @@
 
 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 @@
 
 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 @@
 
 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;
 };
 
diff --git a/third_party/WebKit/Source/modules/filesystem/FileWriter.cpp b/third_party/WebKit/Source/modules/filesystem/FileWriter.cpp
index 28b16df..e7a941d 100644
--- a/third_party/WebKit/Source/modules/filesystem/FileWriter.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/FileWriter.cpp
@@ -288,7 +288,7 @@
     m_readyState = DONE;
     m_truncateLength = -1;
     if (FileError::OK != code) {
-        m_error = FileError::create(code);
+        m_error = FileError::createDOMException(code);
         if (FileError::ABORT_ERR == code)
             fireEvent(EventTypeNames::abort);
         else
@@ -313,7 +313,7 @@
 {
     ASSERT(errorCode);
     FileError::throwDOMException(exceptionState, errorCode);
-    m_error = FileError::create(errorCode);
+    m_error = FileError::createDOMException(errorCode);
 }
 
 DEFINE_TRACE(FileWriter)
diff --git a/third_party/WebKit/Source/modules/filesystem/FileWriter.h b/third_party/WebKit/Source/modules/filesystem/FileWriter.h
index 0ea4dca1..128d926 100644
--- a/third_party/WebKit/Source/modules/filesystem/FileWriter.h
+++ b/third_party/WebKit/Source/modules/filesystem/FileWriter.h
@@ -69,7 +69,7 @@
     void truncate(long long length, ExceptionState&);
     void abort(ExceptionState&);
     ReadyState getReadyState() const { return m_readyState; }
-    FileError* error() const { return m_error.get(); }
+    DOMException* error() const { return m_error.get(); }
 
     // WebFileWriterClient
     void didWrite(long long bytes, bool complete) override;
@@ -115,7 +115,7 @@
 
     void setError(FileError::ErrorCode, ExceptionState&);
 
-    Member<FileError> m_error;
+    Member<DOMException> m_error;
     ReadyState m_readyState;
     Operation m_operationInProgress;
     Operation m_queuedOperation;
diff --git a/third_party/WebKit/Source/modules/filesystem/FileWriter.idl b/third_party/WebKit/Source/modules/filesystem/FileWriter.idl
index 038404e..5d3f73e 100644
--- a/third_party/WebKit/Source/modules/filesystem/FileWriter.idl
+++ b/third_party/WebKit/Source/modules/filesystem/FileWriter.idl
@@ -47,7 +47,7 @@
 
     [RaisesException] void abort();
 
-    readonly attribute FileError error;
+    readonly attribute DOMException? error;
     readonly attribute long long position;
     readonly attribute long long length;
 
diff --git a/third_party/WebKit/Source/modules/filesystem/SyncCallbackHelper.h b/third_party/WebKit/Source/modules/filesystem/SyncCallbackHelper.h
index 534242f..18cbc19 100644
--- a/third_party/WebKit/Source/modules/filesystem/SyncCallbackHelper.h
+++ b/third_party/WebKit/Source/modules/filesystem/SyncCallbackHelper.h
@@ -39,9 +39,9 @@
 #include "modules/filesystem/EntriesCallback.h"
 #include "modules/filesystem/EntryCallback.h"
 #include "modules/filesystem/EntrySync.h"
-#include "modules/filesystem/ErrorCallback.h"
 #include "modules/filesystem/FileEntry.h"
 #include "modules/filesystem/FileSystemCallback.h"
+#include "modules/filesystem/FileSystemCallbacks.h"
 #include "modules/filesystem/MetadataCallback.h"
 #include "platform/heap/Handle.h"
 
@@ -67,7 +67,7 @@
     }
 
     SuccessCallback* getSuccessCallback() { return SuccessCallbackImpl::create(this); }
-    ErrorCallback* getErrorCallback() { return ErrorCallbackImpl::create(this); }
+    ErrorCallbackBase* getErrorCallback() { return ErrorCallbackImpl::create(this); }
 
     DEFINE_INLINE_TRACE()
     {
@@ -112,23 +112,22 @@
         Member<HelperType> m_helper;
     };
 
-    class ErrorCallbackImpl final : public ErrorCallback {
+    class ErrorCallbackImpl final : public ErrorCallbackBase {
     public:
         static ErrorCallbackImpl* create(HelperType* helper)
         {
             return new ErrorCallbackImpl(helper);
         }
 
-        void handleEvent(FileError* error) override
+        void invoke(FileError::ErrorCode error) override
         {
-            ASSERT(error);
-            m_helper->setError(error->code());
+            m_helper->setError(error);
         }
 
         DEFINE_INLINE_TRACE()
         {
             visitor->trace(m_helper);
-            ErrorCallback::trace(visitor);
+            ErrorCallbackBase::trace(visitor);
         }
 
     private:
@@ -139,9 +138,9 @@
         Member<HelperType> m_helper;
     };
 
-    void setError(FileError::ErrorCode code)
+    void setError(FileError::ErrorCode error)
     {
-        m_errorCode = code;
+        m_errorCode = error;
         m_completed = true;
     }
 
diff --git a/third_party/WebKit/Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp b/third_party/WebKit/Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp
index b13018d..56687be 100644
--- a/third_party/WebKit/Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp
+++ b/third_party/WebKit/Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp
@@ -49,17 +49,17 @@
 {
     ExecutionContext* secureContext = worker.getExecutionContext();
     if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) {
-        DOMFileSystem::reportError(&worker, errorCallback, FileError::create(FileError::SECURITY_ERR));
+        DOMFileSystem::reportError(&worker, ScriptErrorCallback::wrap(errorCallback), FileError::SECURITY_ERR);
         return;
     }
 
     FileSystemType fileSystemType = static_cast<FileSystemType>(type);
     if (!DOMFileSystemBase::isValidType(fileSystemType)) {
-        DOMFileSystem::reportError(&worker, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
+        DOMFileSystem::reportError(&worker, ScriptErrorCallback::wrap(errorCallback), FileError::INVALID_MODIFICATION_ERR);
         return;
     }
 
-    LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, &worker, fileSystemType));
+    LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, size, FileSystemCallbacks::create(successCallback, ScriptErrorCallback::wrap(errorCallback), &worker, fileSystemType));
 }
 
 DOMFileSystemSync* WorkerGlobalScopeFileSystem::webkitRequestFileSystemSync(WorkerGlobalScope& worker, int type, long long size, ExceptionState& exceptionState)
@@ -89,16 +89,16 @@
     KURL completedURL = worker.completeURL(url);
     ExecutionContext* secureContext = worker.getExecutionContext();
     if (!secureContext->getSecurityOrigin()->canAccessFileSystem() || !secureContext->getSecurityOrigin()->canRequest(completedURL)) {
-        DOMFileSystem::reportError(&worker, errorCallback, FileError::create(FileError::SECURITY_ERR));
+        DOMFileSystem::reportError(&worker, ScriptErrorCallback::wrap(errorCallback), FileError::SECURITY_ERR);
         return;
     }
 
     if (!completedURL.isValid()) {
-        DOMFileSystem::reportError(&worker, errorCallback, FileError::create(FileError::ENCODING_ERR));
+        DOMFileSystem::reportError(&worker, ScriptErrorCallback::wrap(errorCallback), FileError::ENCODING_ERR);
         return;
     }
 
-    LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, ResolveURICallbacks::create(successCallback, errorCallback, &worker));
+    LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, ResolveURICallbacks::create(successCallback, ScriptErrorCallback::wrap(errorCallback), &worker));
 }
 
 EntrySync* WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemSyncURL(WorkerGlobalScope& worker, const String& url, ExceptionState& exceptionState)
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp b/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp
index e9511d1..3311168 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp
@@ -5,6 +5,7 @@
 #include "modules/presentation/PresentationConnectionCallbacks.h"
 
 #include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "core/dom/DOMException.h"
 #include "modules/presentation/PresentationConnection.h"
 #include "modules/presentation/PresentationError.h"
 #include "modules/presentation/PresentationRequest.h"
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
index 7f79b25..9daf2ae 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
@@ -8,6 +8,7 @@
 #include "bindings/core/v8/ExceptionState.h"
 #include "bindings/core/v8/ScriptPromise.h"
 #include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "core/dom/DOMException.h"
 #include "core/dom/Document.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/frame/Settings.h"