OLD | NEW |
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return; | 96 return; |
97 } | 97 } |
98 | 98 |
99 FileSystemType type; | 99 FileSystemType type; |
100 String filePath; | 100 String filePath; |
101 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(comple
tedURL, type, filePath)) { | 101 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(comple
tedURL, type, filePath)) { |
102 DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create
(FileError::ENCODING_ERR)); | 102 DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create
(FileError::ENCODING_ERR)); |
103 return; | 103 return; |
104 } | 104 } |
105 | 105 |
106 WorkerLocalFileSystem::from(worker)->readFileSystem(worker, type, ResolveURI
Callbacks::create(successCallback, errorCallback, worker, type, filePath)); | 106 WorkerLocalFileSystem::from(worker)->readFileSystem(worker, completedURL, Re
solveURICallbacks::create(successCallback, errorCallback, worker, type, filePath
)); |
107 } | 107 } |
108 | 108 |
109 PassRefPtr<EntrySync> WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemS
yncURL(WorkerGlobalScope* worker, const String& url, ExceptionState& es) | 109 PassRefPtr<EntrySync> WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemS
yncURL(WorkerGlobalScope* worker, const String& url, ExceptionState& es) |
110 { | 110 { |
111 KURL completedURL = worker->completeURL(url); | 111 KURL completedURL = worker->completeURL(url); |
112 ScriptExecutionContext* secureContext = worker->scriptExecutionContext(); | 112 ScriptExecutionContext* secureContext = worker->scriptExecutionContext(); |
113 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex
t->securityOrigin()->canRequest(completedURL)) { | 113 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex
t->securityOrigin()->canRequest(completedURL)) { |
114 es.throwSecurityError(ExceptionMessages::failedToExecute("webkitResolveL
ocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", FileError::securityErrorM
essage)); | 114 es.throwSecurityError(ExceptionMessages::failedToExecute("webkitResolveL
ocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", FileError::securityErrorM
essage)); |
115 return 0; | 115 return 0; |
116 } | 116 } |
117 | 117 |
118 FileSystemType type; | 118 FileSystemType type; |
119 String filePath; | 119 String filePath; |
120 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(comple
tedURL, type, filePath)) { | 120 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(comple
tedURL, type, filePath)) { |
121 es.throwDOMException(EncodingError, ExceptionMessages::failedToExecute("
webkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", "the URL '"
+ url + "' is invalid.")); | 121 es.throwDOMException(EncodingError, ExceptionMessages::failedToExecute("
webkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", "the URL '"
+ url + "' is invalid.")); |
122 return 0; | 122 return 0; |
123 } | 123 } |
124 | 124 |
125 FileSystemSyncCallbackHelper readFileSystemHelper; | 125 FileSystemSyncCallbackHelper readFileSystemHelper; |
126 OwnPtr<FileSystemCallbacks> callbacks = FileSystemCallbacks::create(readFile
SystemHelper.successCallback(), readFileSystemHelper.errorCallback(), worker, ty
pe); | 126 OwnPtr<FileSystemCallbacks> callbacks = FileSystemCallbacks::create(readFile
SystemHelper.successCallback(), readFileSystemHelper.errorCallback(), worker, ty
pe); |
127 callbacks->setShouldBlockUntilCompletion(true); | 127 callbacks->setShouldBlockUntilCompletion(true); |
128 | 128 |
129 WorkerLocalFileSystem::from(worker)->readFileSystem(worker, type, callbacks.
release()); | 129 WorkerLocalFileSystem::from(worker)->readFileSystem(worker, completedURL, ca
llbacks.release()); |
130 RefPtr<DOMFileSystemSync> fileSystem = readFileSystemHelper.getResult(es); | 130 RefPtr<DOMFileSystemSync> fileSystem = readFileSystemHelper.getResult(es); |
131 if (!fileSystem) | 131 if (!fileSystem) |
132 return 0; | 132 return 0; |
133 | 133 |
134 RefPtr<EntrySync> entry = fileSystem->root()->getDirectory(filePath, Diction
ary(), es); | 134 RefPtr<EntrySync> entry = fileSystem->root()->getDirectory(filePath, Diction
ary(), es); |
135 if (es.code() == TypeMismatchError) { | 135 if (es.code() == TypeMismatchError) { |
136 es.clearException(); | 136 es.clearException(); |
137 return fileSystem->root()->getFile(filePath, Dictionary(), es); | 137 return fileSystem->root()->getFile(filePath, Dictionary(), es); |
138 } | 138 } |
139 | 139 |
140 return entry.release(); | 140 return entry.release(); |
141 } | 141 } |
142 | 142 |
143 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati
c_cast<int>(FileSystemTypeTemporary), enum_mismatch); | 143 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati
c_cast<int>(FileSystemTypeTemporary), enum_mismatch); |
144 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat
ic_cast<int>(FileSystemTypePersistent), enum_mismatch); | 144 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat
ic_cast<int>(FileSystemTypePersistent), enum_mismatch); |
145 | 145 |
146 } // namespace WebCore | 146 } // namespace WebCore |
OLD | NEW |