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

Side by Side Diff: Source/core/fileapi/FileError.cpp

Issue 22831019: Deprecate FileError in FileAPI (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: win test expectation fix (temporary) Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/fileapi/FileError.h ('k') | Source/core/fileapi/FileError.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 30 matching lines...) Expand all
41 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."; 41 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.";
42 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."; 42 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.";
43 const char FileError::notFoundErrorMessage[] = "A requested file or directory co uld not be found at the time an operation was processed."; 43 const char FileError::notFoundErrorMessage[] = "A requested file or directory co uld not be found at the time an operation was processed.";
44 const char FileError::notReadableErrorMessage[] = "The requested file could not be read, typically due to permission problems that have occurred after a referen ce to a file was acquired."; 44 const char FileError::notReadableErrorMessage[] = "The requested file could not be read, typically due to permission problems that have occurred after a referen ce to a file was acquired.";
45 const char FileError::pathExistsErrorMessage[] = "An attempt was made to create a file or directory where an element already exists."; 45 const char FileError::pathExistsErrorMessage[] = "An attempt was made to create a file or directory where an element already exists.";
46 const char FileError::quotaExceededErrorMessage[] = "The operation failed becaus e it would cause the application to exceed its storage quota."; 46 const char FileError::quotaExceededErrorMessage[] = "The operation failed becaus e it would cause the application to exceed its storage quota.";
47 const char FileError::securityErrorMessage[] = "It was determined that certain f iles are unsafe for access within a Web application, or that too many calls are being made on file resources."; 47 const char FileError::securityErrorMessage[] = "It was determined that certain f iles are unsafe for access within a Web application, or that too many calls are being made on file resources.";
48 const char FileError::syntaxErrorMessage[] = "An invalid or unsupported argument was given, like an invalid line ending specifier."; 48 const char FileError::syntaxErrorMessage[] = "An invalid or unsupported argument was given, like an invalid line ending specifier.";
49 const char FileError::typeMismatchErrorMessage[] = "The path supplied exists, bu t was not an entry of requested type."; 49 const char FileError::typeMismatchErrorMessage[] = "The path supplied exists, bu t was not an entry of requested type.";
50 50
51 namespace {
52
53 ExceptionCode errorCodeToExceptionCode(FileError::ErrorCode code)
54 {
55 switch (code) {
56 case FileError::OK:
57 return 0;
58 case FileError::NOT_FOUND_ERR:
59 return NotFoundError;
60 case FileError::SECURITY_ERR:
61 return SecurityError;
62 case FileError::ABORT_ERR:
63 return AbortError;
64 case FileError::NOT_READABLE_ERR:
65 return NotReadableError;
66 case FileError::ENCODING_ERR:
67 return EncodingError;
68 case FileError::NO_MODIFICATION_ALLOWED_ERR:
69 return NoModificationAllowedError;
70 case FileError::INVALID_STATE_ERR:
71 return InvalidStateError;
72 case FileError::SYNTAX_ERR:
73 return SyntaxError;
74 case FileError::INVALID_MODIFICATION_ERR:
75 return InvalidModificationError;
76 case FileError::QUOTA_EXCEEDED_ERR:
77 return QuotaExceededError;
78 case FileError::TYPE_MISMATCH_ERR:
79 return TypeMismatchError;
80 case FileError::PATH_EXISTS_ERR:
81 return PathExistsError;
82 default:
83 ASSERT_NOT_REACHED();
84 return code;
85 }
86 }
87
88 const char* errorCodeToMessage(FileError::ErrorCode code)
89 {
90 // Note that some of these do not set message. If message is 0 then the defa ult message is used.
91 switch (code) {
92 case FileError::OK:
93 return 0;
94 case FileError::SECURITY_ERR:
95 return FileError::securityErrorMessage;
96 case FileError::NOT_FOUND_ERR:
97 return FileError::notFoundErrorMessage;
98 case FileError::ABORT_ERR:
99 return FileError::abortErrorMessage;
100 case FileError::NOT_READABLE_ERR:
101 return FileError::notReadableErrorMessage;
102 case FileError::ENCODING_ERR:
103 return FileError::encodingErrorMessage;
104 case FileError::NO_MODIFICATION_ALLOWED_ERR:
105 return FileError::noModificationAllowedErrorMessage;
106 case FileError::INVALID_STATE_ERR:
107 return FileError::invalidStateErrorMessage;
108 case FileError::SYNTAX_ERR:
109 return FileError::syntaxErrorMessage;
110 case FileError::INVALID_MODIFICATION_ERR:
111 return 0;
112 case FileError::QUOTA_EXCEEDED_ERR:
113 return FileError::quotaExceededErrorMessage;
114 case FileError::TYPE_MISMATCH_ERR:
115 return 0;
116 case FileError::PATH_EXISTS_ERR:
117 return FileError::pathExistsErrorMessage;
118 default:
119 ASSERT_NOT_REACHED();
120 return 0;
121 }
122 }
123
124 } // namespace
125
51 void FileError::throwDOMException(ExceptionState& es, ErrorCode code) 126 void FileError::throwDOMException(ExceptionState& es, ErrorCode code)
52 { 127 {
53 if (code == FileError::OK) 128 if (code == FileError::OK)
54 return; 129 return;
55 130
56 ExceptionCode ec;
57 const char* message = 0;
58
59 // Note that some of these do not set message. If message is 0 then the defa ult message is used.
60 switch (code) {
61 case FileError::NOT_FOUND_ERR:
62 ec = NotFoundError;
63 message = FileError::notFoundErrorMessage;
64 break;
65 case FileError::ABORT_ERR:
66 ec = AbortError;
67 message = FileError::abortErrorMessage;
68 break;
69 case FileError::NOT_READABLE_ERR:
70 ec = NotReadableError;
71 message = FileError::notReadableErrorMessage;
72 break;
73 case FileError::ENCODING_ERR:
74 ec = EncodingError;
75 message = FileError::encodingErrorMessage;
76 break;
77 case FileError::NO_MODIFICATION_ALLOWED_ERR:
78 ec = NoModificationAllowedError;
79 message = FileError::noModificationAllowedErrorMessage;
80 break;
81 case FileError::INVALID_STATE_ERR:
82 ec = InvalidStateError;
83 message = FileError::invalidStateErrorMessage;
84 break;
85 case FileError::SYNTAX_ERR:
86 ec = SyntaxError;
87 message = FileError::syntaxErrorMessage;
88 break;
89 case FileError::INVALID_MODIFICATION_ERR:
90 ec = InvalidModificationError;
91 break;
92 case FileError::QUOTA_EXCEEDED_ERR:
93 ec = QuotaExceededError;
94 message = FileError::quotaExceededErrorMessage;
95 break;
96 case FileError::TYPE_MISMATCH_ERR:
97 ec = TypeMismatchError;
98 break;
99 case FileError::PATH_EXISTS_ERR:
100 ec = PathExistsError;
101 message = FileError::pathExistsErrorMessage;
102 break;
103 // SecurityError is special-cased, as we want to route those exceptions thro ugh ExceptionState::throwSecurityError. 131 // SecurityError is special-cased, as we want to route those exceptions thro ugh ExceptionState::throwSecurityError.
104 case FileError::SECURITY_ERR: 132 if (code == FileError::SECURITY_ERR) {
105 es.throwSecurityError(FileError::securityErrorMessage); 133 es.throwSecurityError(FileError::securityErrorMessage);
106 return; 134 return;
107 default:
108 ASSERT_NOT_REACHED();
109 return;
110 } 135 }
111 136
112 es.throwDOMException(ec, message); 137 es.throwDOMException(errorCodeToExceptionCode(code), errorCodeToMessage(code ));
138 }
139
140 FileError::FileError(ErrorCode code)
141 : DOMError(DOMException::getErrorName(errorCodeToExceptionCode(code)), error CodeToMessage(code))
142 , m_code(code)
143 {
144 ScriptWrappable::init(this);
113 } 145 }
114 146
115 } // namespace WebCore 147 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/fileapi/FileError.h ('k') | Source/core/fileapi/FileError.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698