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

Side by Side Diff: Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp

Issue 99083002: WIP: Migrate generated bindings to new ExceptionState constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 7 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 10 matching lines...) Expand all
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * 25 *
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "modules/filesystem/WorkerGlobalScopeFileSystem.h" 29 #include "modules/filesystem/WorkerGlobalScopeFileSystem.h"
30 30
31 #include "bindings/v8/ExceptionMessages.h"
32 #include "bindings/v8/ExceptionState.h" 31 #include "bindings/v8/ExceptionState.h"
33 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
34 #include "core/fileapi/FileError.h" 33 #include "core/fileapi/FileError.h"
35 #include "core/workers/WorkerGlobalScope.h" 34 #include "core/workers/WorkerGlobalScope.h"
36 #include "modules/filesystem/DOMFileSystemBase.h" 35 #include "modules/filesystem/DOMFileSystemBase.h"
37 #include "modules/filesystem/DirectoryEntrySync.h" 36 #include "modules/filesystem/DirectoryEntrySync.h"
38 #include "modules/filesystem/ErrorCallback.h" 37 #include "modules/filesystem/ErrorCallback.h"
39 #include "modules/filesystem/FileEntrySync.h" 38 #include "modules/filesystem/FileEntrySync.h"
40 #include "modules/filesystem/FileSystemCallback.h" 39 #include "modules/filesystem/FileSystemCallback.h"
41 #include "modules/filesystem/FileSystemCallbacks.h" 40 #include "modules/filesystem/FileSystemCallbacks.h"
(...skipping 18 matching lines...) Expand all
60 return; 59 return;
61 } 60 }
62 61
63 LocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemType, siz e, FileSystemCallbacks::create(successCallback, errorCallback, worker, fileSyste mType)); 62 LocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemType, siz e, FileSystemCallbacks::create(successCallback, errorCallback, worker, fileSyste mType));
64 } 63 }
65 64
66 PassRefPtr<DOMFileSystemSync> WorkerGlobalScopeFileSystem::webkitRequestFileSyst emSync(WorkerGlobalScope* worker, int type, long long size, ExceptionState& exce ptionState) 65 PassRefPtr<DOMFileSystemSync> WorkerGlobalScopeFileSystem::webkitRequestFileSyst emSync(WorkerGlobalScope* worker, int type, long long size, ExceptionState& exce ptionState)
67 { 66 {
68 ExecutionContext* secureContext = worker->executionContext(); 67 ExecutionContext* secureContext = worker->executionContext();
69 if (!secureContext->securityOrigin()->canAccessFileSystem()) { 68 if (!secureContext->securityOrigin()->canAccessFileSystem()) {
70 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("we bkitRequestFileSystemSync", "WorkerGlobalScopeFileSystem", FileError::securityEr rorMessage)); 69 exceptionState.throwSecurityError(FileError::securityErrorMessage);
71 return 0; 70 return 0;
72 } 71 }
73 72
74 FileSystemType fileSystemType = static_cast<FileSystemType>(type); 73 FileSystemType fileSystemType = static_cast<FileSystemType>(type);
75 if (!DOMFileSystemBase::isValidType(fileSystemType)) { 74 if (!DOMFileSystemBase::isValidType(fileSystemType)) {
76 exceptionState.throwDOMException(InvalidModificationError, ExceptionMess ages::failedToExecute("webkitRequestFileSystemSync", "WorkerGlobalScopeFileSyste m", "the type must be TEMPORARY or PERSISTENT.")); 75 exceptionState.throwDOMException(InvalidModificationError, "the type mus t be TEMPORARY or PERSISTENT.");
77 return 0; 76 return 0;
78 } 77 }
79 78
80 FileSystemSyncCallbackHelper helper; 79 FileSystemSyncCallbackHelper helper;
81 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(hel per.successCallback(), helper.errorCallback(), worker, fileSystemType); 80 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(hel per.successCallback(), helper.errorCallback(), worker, fileSystemType);
82 callbacks->setShouldBlockUntilCompletion(true); 81 callbacks->setShouldBlockUntilCompletion(true);
83 82
84 LocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemType, siz e, callbacks.release()); 83 LocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemType, siz e, callbacks.release());
85 return helper.getResult(exceptionState); 84 return helper.getResult(exceptionState);
86 } 85 }
(...skipping 13 matching lines...) Expand all
100 } 99 }
101 100
102 LocalFileSystem::from(worker)->resolveURL(worker, completedURL, ResolveURICa llbacks::create(successCallback, errorCallback, worker)); 101 LocalFileSystem::from(worker)->resolveURL(worker, completedURL, ResolveURICa llbacks::create(successCallback, errorCallback, worker));
103 } 102 }
104 103
105 PassRefPtr<EntrySync> WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemS yncURL(WorkerGlobalScope* worker, const String& url, ExceptionState& exceptionSt ate) 104 PassRefPtr<EntrySync> WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemS yncURL(WorkerGlobalScope* worker, const String& url, ExceptionState& exceptionSt ate)
106 { 105 {
107 KURL completedURL = worker->completeURL(url); 106 KURL completedURL = worker->completeURL(url);
108 ExecutionContext* secureContext = worker->executionContext(); 107 ExecutionContext* secureContext = worker->executionContext();
109 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex t->securityOrigin()->canRequest(completedURL)) { 108 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex t->securityOrigin()->canRequest(completedURL)) {
110 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("we bkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", FileError::se curityErrorMessage)); 109 exceptionState.throwSecurityError(FileError::securityErrorMessage);
111 return 0; 110 return 0;
112 } 111 }
113 112
114 if (!completedURL.isValid()) { 113 if (!completedURL.isValid()) {
115 exceptionState.throwDOMException(EncodingError, ExceptionMessages::faile dToExecute("webkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", "the URL '" + url + "' is invalid.")); 114 exceptionState.throwDOMException(EncodingError, "the URL '" + url + "' i s invalid.");
116 return 0; 115 return 0;
117 } 116 }
118 117
119 EntrySyncCallbackHelper resolveURLHelper; 118 EntrySyncCallbackHelper resolveURLHelper;
120 OwnPtr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::create(res olveURLHelper.successCallback(), resolveURLHelper.errorCallback(), worker); 119 OwnPtr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::create(res olveURLHelper.successCallback(), resolveURLHelper.errorCallback(), worker);
121 callbacks->setShouldBlockUntilCompletion(true); 120 callbacks->setShouldBlockUntilCompletion(true);
122 121
123 LocalFileSystem::from(worker)->resolveURL(worker, completedURL, callbacks.re lease()); 122 LocalFileSystem::from(worker)->resolveURL(worker, completedURL, callbacks.re lease());
124 123
125 RefPtr<EntrySync> entry = resolveURLHelper.getResult(exceptionState); 124 RefPtr<EntrySync> entry = resolveURLHelper.getResult(exceptionState);
126 if (!entry) 125 if (!entry)
127 return 0; 126 return 0;
128 return entry.release(); 127 return entry.release();
129 } 128 }
130 129
131 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati c_cast<int>(FileSystemTypeTemporary), enum_mismatch); 130 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati c_cast<int>(FileSystemTypeTemporary), enum_mismatch);
132 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat ic_cast<int>(FileSystemTypePersistent), enum_mismatch); 131 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat ic_cast<int>(FileSystemTypePersistent), enum_mismatch);
133 132
134 } // namespace WebCore 133 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/filesystem/FileWriterSync.cpp ('k') | Source/modules/imagebitmap/ImageBitmapFactories.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698