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

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

Issue 2040563002: Remove FileError interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fe-dep
Patch Set: handleEvent -> invoke and other review nits Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "platform/FileSystemType.h" 42 #include "platform/FileSystemType.h"
43 #include "platform/weborigin/SecurityOrigin.h" 43 #include "platform/weborigin/SecurityOrigin.h"
44 #include <memory> 44 #include <memory>
45 45
46 namespace blink { 46 namespace blink {
47 47
48 void WorkerGlobalScopeFileSystem::webkitRequestFileSystem(WorkerGlobalScope& wor ker, int type, long long size, FileSystemCallback* successCallback, ErrorCallbac k* errorCallback) 48 void WorkerGlobalScopeFileSystem::webkitRequestFileSystem(WorkerGlobalScope& wor ker, int type, long long size, FileSystemCallback* successCallback, ErrorCallbac k* errorCallback)
49 { 49 {
50 ExecutionContext* secureContext = worker.getExecutionContext(); 50 ExecutionContext* secureContext = worker.getExecutionContext();
51 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) { 51 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) {
52 DOMFileSystem::reportError(&worker, errorCallback, FileError::create(Fil eError::SECURITY_ERR)); 52 DOMFileSystem::reportError(&worker, ScriptErrorCallback::wrap(errorCallb ack), FileError::SECURITY_ERR);
53 return; 53 return;
54 } 54 }
55 55
56 FileSystemType fileSystemType = static_cast<FileSystemType>(type); 56 FileSystemType fileSystemType = static_cast<FileSystemType>(type);
57 if (!DOMFileSystemBase::isValidType(fileSystemType)) { 57 if (!DOMFileSystemBase::isValidType(fileSystemType)) {
58 DOMFileSystem::reportError(&worker, errorCallback, FileError::create(Fil eError::INVALID_MODIFICATION_ERR)); 58 DOMFileSystem::reportError(&worker, ScriptErrorCallback::wrap(errorCallb ack), FileError::INVALID_MODIFICATION_ERR);
59 return; 59 return;
60 } 60 }
61 61
62 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si ze, FileSystemCallbacks::create(successCallback, errorCallback, &worker, fileSys temType)); 62 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si ze, FileSystemCallbacks::create(successCallback, ScriptErrorCallback::wrap(error Callback), &worker, fileSystemType));
63 } 63 }
64 64
65 DOMFileSystemSync* WorkerGlobalScopeFileSystem::webkitRequestFileSystemSync(Work erGlobalScope& worker, int type, long long size, ExceptionState& exceptionState) 65 DOMFileSystemSync* WorkerGlobalScopeFileSystem::webkitRequestFileSystemSync(Work erGlobalScope& worker, int type, long long size, ExceptionState& exceptionState)
66 { 66 {
67 ExecutionContext* secureContext = worker.getExecutionContext(); 67 ExecutionContext* secureContext = worker.getExecutionContext();
68 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) { 68 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) {
69 exceptionState.throwSecurityError(FileError::securityErrorMessage); 69 exceptionState.throwSecurityError(FileError::securityErrorMessage);
70 return 0; 70 return 0;
71 } 71 }
72 72
73 FileSystemType fileSystemType = static_cast<FileSystemType>(type); 73 FileSystemType fileSystemType = static_cast<FileSystemType>(type);
74 if (!DOMFileSystemBase::isValidType(fileSystemType)) { 74 if (!DOMFileSystemBase::isValidType(fileSystemType)) {
75 exceptionState.throwDOMException(InvalidModificationError, "the type mus t be TEMPORARY or PERSISTENT."); 75 exceptionState.throwDOMException(InvalidModificationError, "the type mus t be TEMPORARY or PERSISTENT.");
76 return 0; 76 return 0;
77 } 77 }
78 78
79 FileSystemSyncCallbackHelper* helper = FileSystemSyncCallbackHelper::create( ); 79 FileSystemSyncCallbackHelper* helper = FileSystemSyncCallbackHelper::create( );
80 std::unique_ptr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::c reate(helper->getSuccessCallback(), helper->getErrorCallback(), &worker, fileSys temType); 80 std::unique_ptr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::c reate(helper->getSuccessCallback(), helper->getErrorCallback(), &worker, fileSys temType);
81 callbacks->setShouldBlockUntilCompletion(true); 81 callbacks->setShouldBlockUntilCompletion(true);
82 82
83 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si ze, std::move(callbacks)); 83 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si ze, std::move(callbacks));
84 return helper->getResult(exceptionState); 84 return helper->getResult(exceptionState);
85 } 85 }
86 86
87 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc ope& worker, const String& url, EntryCallback* successCallback, ErrorCallback* e rrorCallback) 87 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc ope& worker, const String& url, EntryCallback* successCallback, ErrorCallback* e rrorCallback)
88 { 88 {
89 KURL completedURL = worker.completeURL(url); 89 KURL completedURL = worker.completeURL(url);
90 ExecutionContext* secureContext = worker.getExecutionContext(); 90 ExecutionContext* secureContext = worker.getExecutionContext();
91 if (!secureContext->getSecurityOrigin()->canAccessFileSystem() || !secureCon text->getSecurityOrigin()->canRequest(completedURL)) { 91 if (!secureContext->getSecurityOrigin()->canAccessFileSystem() || !secureCon text->getSecurityOrigin()->canRequest(completedURL)) {
92 DOMFileSystem::reportError(&worker, errorCallback, FileError::create(Fil eError::SECURITY_ERR)); 92 DOMFileSystem::reportError(&worker, ScriptErrorCallback::wrap(errorCallb ack), FileError::SECURITY_ERR);
93 return; 93 return;
94 } 94 }
95 95
96 if (!completedURL.isValid()) { 96 if (!completedURL.isValid()) {
97 DOMFileSystem::reportError(&worker, errorCallback, FileError::create(Fil eError::ENCODING_ERR)); 97 DOMFileSystem::reportError(&worker, ScriptErrorCallback::wrap(errorCallb ack), FileError::ENCODING_ERR);
98 return; 98 return;
99 } 99 }
100 100
101 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, ResolveURIC allbacks::create(successCallback, errorCallback, &worker)); 101 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, ResolveURIC allbacks::create(successCallback, ScriptErrorCallback::wrap(errorCallback), &wor ker));
102 } 102 }
103 103
104 EntrySync* WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemSyncURL(Work erGlobalScope& worker, const String& url, ExceptionState& exceptionState) 104 EntrySync* WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemSyncURL(Work erGlobalScope& worker, const String& url, ExceptionState& exceptionState)
105 { 105 {
106 KURL completedURL = worker.completeURL(url); 106 KURL completedURL = worker.completeURL(url);
107 ExecutionContext* secureContext = worker.getExecutionContext(); 107 ExecutionContext* secureContext = worker.getExecutionContext();
108 if (!secureContext->getSecurityOrigin()->canAccessFileSystem() || !secureCon text->getSecurityOrigin()->canRequest(completedURL)) { 108 if (!secureContext->getSecurityOrigin()->canAccessFileSystem() || !secureCon text->getSecurityOrigin()->canRequest(completedURL)) {
109 exceptionState.throwSecurityError(FileError::securityErrorMessage); 109 exceptionState.throwSecurityError(FileError::securityErrorMessage);
110 return 0; 110 return 0;
111 } 111 }
112 112
113 if (!completedURL.isValid()) { 113 if (!completedURL.isValid()) {
114 exceptionState.throwDOMException(EncodingError, "the URL '" + url + "' i s invalid."); 114 exceptionState.throwDOMException(EncodingError, "the URL '" + url + "' i s invalid.");
115 return 0; 115 return 0;
116 } 116 }
117 117
118 EntrySyncCallbackHelper* resolveURLHelper = EntrySyncCallbackHelper::create( ); 118 EntrySyncCallbackHelper* resolveURLHelper = EntrySyncCallbackHelper::create( );
119 std::unique_ptr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::c reate(resolveURLHelper->getSuccessCallback(), resolveURLHelper->getErrorCallback (), &worker); 119 std::unique_ptr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::c reate(resolveURLHelper->getSuccessCallback(), resolveURLHelper->getErrorCallback (), &worker);
120 callbacks->setShouldBlockUntilCompletion(true); 120 callbacks->setShouldBlockUntilCompletion(true);
121 121
122 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, std::move(c allbacks)); 122 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, std::move(c allbacks));
123 123
124 return resolveURLHelper->getResult(exceptionState); 124 return resolveURLHelper->getResult(exceptionState);
125 } 125 }
126 126
127 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == static _cast<int>(FileSystemTypeTemporary), "WorkerGlobalScopeFileSystem::TEMPORARY sho uld match FileSystemTypeTemporary"); 127 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == static _cast<int>(FileSystemTypeTemporary), "WorkerGlobalScopeFileSystem::TEMPORARY sho uld match FileSystemTypeTemporary");
128 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stati c_cast<int>(FileSystemTypePersistent), "WorkerGlobalScopeFileSystem::PERSISTENT should match FileSystemTypePersistent"); 128 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stati c_cast<int>(FileSystemTypePersistent), "WorkerGlobalScopeFileSystem::PERSISTENT should match FileSystemTypePersistent");
129 129
130 } // namespace blink 130 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698