| 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 23 matching lines...) Expand all Loading... |
| 34 #include "modules/filesystem/DOMFileSystemBase.h" | 34 #include "modules/filesystem/DOMFileSystemBase.h" |
| 35 #include "modules/filesystem/DirectoryEntrySync.h" | 35 #include "modules/filesystem/DirectoryEntrySync.h" |
| 36 #include "modules/filesystem/ErrorCallback.h" | 36 #include "modules/filesystem/ErrorCallback.h" |
| 37 #include "modules/filesystem/FileEntrySync.h" | 37 #include "modules/filesystem/FileEntrySync.h" |
| 38 #include "modules/filesystem/FileSystemCallback.h" | 38 #include "modules/filesystem/FileSystemCallback.h" |
| 39 #include "modules/filesystem/FileSystemCallbacks.h" | 39 #include "modules/filesystem/FileSystemCallbacks.h" |
| 40 #include "modules/filesystem/LocalFileSystem.h" | 40 #include "modules/filesystem/LocalFileSystem.h" |
| 41 #include "modules/filesystem/SyncCallbackHelper.h" | 41 #include "modules/filesystem/SyncCallbackHelper.h" |
| 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> | |
| 45 | 44 |
| 46 namespace blink { | 45 namespace blink { |
| 47 | 46 |
| 48 void WorkerGlobalScopeFileSystem::webkitRequestFileSystem(WorkerGlobalScope& wor
ker, int type, long long size, FileSystemCallback* successCallback, ErrorCallbac
k* errorCallback) | 47 void WorkerGlobalScopeFileSystem::webkitRequestFileSystem(WorkerGlobalScope& wor
ker, int type, long long size, FileSystemCallback* successCallback, ErrorCallbac
k* errorCallback) |
| 49 { | 48 { |
| 50 ExecutionContext* secureContext = worker.getExecutionContext(); | 49 ExecutionContext* secureContext = worker.getExecutionContext(); |
| 51 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) { | 50 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) { |
| 52 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::SECURITY_ERR)); | 51 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::SECURITY_ERR)); |
| 53 return; | 52 return; |
| 54 } | 53 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 70 return 0; | 69 return 0; |
| 71 } | 70 } |
| 72 | 71 |
| 73 FileSystemType fileSystemType = static_cast<FileSystemType>(type); | 72 FileSystemType fileSystemType = static_cast<FileSystemType>(type); |
| 74 if (!DOMFileSystemBase::isValidType(fileSystemType)) { | 73 if (!DOMFileSystemBase::isValidType(fileSystemType)) { |
| 75 exceptionState.throwDOMException(InvalidModificationError, "the type mus
t be TEMPORARY or PERSISTENT."); | 74 exceptionState.throwDOMException(InvalidModificationError, "the type mus
t be TEMPORARY or PERSISTENT."); |
| 76 return 0; | 75 return 0; |
| 77 } | 76 } |
| 78 | 77 |
| 79 FileSystemSyncCallbackHelper* helper = FileSystemSyncCallbackHelper::create(
); | 78 FileSystemSyncCallbackHelper* helper = FileSystemSyncCallbackHelper::create(
); |
| 80 std::unique_ptr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::c
reate(helper->getSuccessCallback(), helper->getErrorCallback(), &worker, fileSys
temType); | 79 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(hel
per->getSuccessCallback(), helper->getErrorCallback(), &worker, fileSystemType); |
| 81 callbacks->setShouldBlockUntilCompletion(true); | 80 callbacks->setShouldBlockUntilCompletion(true); |
| 82 | 81 |
| 83 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si
ze, std::move(callbacks)); | 82 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si
ze, std::move(callbacks)); |
| 84 return helper->getResult(exceptionState); | 83 return helper->getResult(exceptionState); |
| 85 } | 84 } |
| 86 | 85 |
| 87 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc
ope& worker, const String& url, EntryCallback* successCallback, ErrorCallback* e
rrorCallback) | 86 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc
ope& worker, const String& url, EntryCallback* successCallback, ErrorCallback* e
rrorCallback) |
| 88 { | 87 { |
| 89 KURL completedURL = worker.completeURL(url); | 88 KURL completedURL = worker.completeURL(url); |
| 90 ExecutionContext* secureContext = worker.getExecutionContext(); | 89 ExecutionContext* secureContext = worker.getExecutionContext(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 109 exceptionState.throwSecurityError(FileError::securityErrorMessage); | 108 exceptionState.throwSecurityError(FileError::securityErrorMessage); |
| 110 return 0; | 109 return 0; |
| 111 } | 110 } |
| 112 | 111 |
| 113 if (!completedURL.isValid()) { | 112 if (!completedURL.isValid()) { |
| 114 exceptionState.throwDOMException(EncodingError, "the URL '" + url + "' i
s invalid."); | 113 exceptionState.throwDOMException(EncodingError, "the URL '" + url + "' i
s invalid."); |
| 115 return 0; | 114 return 0; |
| 116 } | 115 } |
| 117 | 116 |
| 118 EntrySyncCallbackHelper* resolveURLHelper = EntrySyncCallbackHelper::create(
); | 117 EntrySyncCallbackHelper* resolveURLHelper = EntrySyncCallbackHelper::create(
); |
| 119 std::unique_ptr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::c
reate(resolveURLHelper->getSuccessCallback(), resolveURLHelper->getErrorCallback
(), &worker); | 118 OwnPtr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::create(res
olveURLHelper->getSuccessCallback(), resolveURLHelper->getErrorCallback(), &work
er); |
| 120 callbacks->setShouldBlockUntilCompletion(true); | 119 callbacks->setShouldBlockUntilCompletion(true); |
| 121 | 120 |
| 122 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, std::move(c
allbacks)); | 121 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, std::move(c
allbacks)); |
| 123 | 122 |
| 124 return resolveURLHelper->getResult(exceptionState); | 123 return resolveURLHelper->getResult(exceptionState); |
| 125 } | 124 } |
| 126 | 125 |
| 127 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == static
_cast<int>(FileSystemTypeTemporary), "WorkerGlobalScopeFileSystem::TEMPORARY sho
uld match FileSystemTypeTemporary"); | 126 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"); | 127 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stati
c_cast<int>(FileSystemTypePersistent), "WorkerGlobalScopeFileSystem::PERSISTENT
should match FileSystemTypePersistent"); |
| 129 | 128 |
| 130 } // namespace blink | 129 } // namespace blink |
| OLD | NEW |