| OLD | NEW |
| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 { | 67 { |
| 68 return m_callbacks.release(); | 68 return m_callbacks.release(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 DEFINE_INLINE_TRACE() { } | 71 DEFINE_INLINE_TRACE() { } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 OwnPtr<AsyncFileSystemCallbacks> m_callbacks; | 74 OwnPtr<AsyncFileSystemCallbacks> m_callbacks; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 PassOwnPtrWillBeRawPtr<LocalFileSystem> LocalFileSystem::create(PassOwnPtr<FileS
ystemClient> client) | 77 RawPtr<LocalFileSystem> LocalFileSystem::create(PassOwnPtr<FileSystemClient> cli
ent) |
| 78 { | 78 { |
| 79 return adoptPtrWillBeNoop(new LocalFileSystem(client)); | 79 return new LocalFileSystem(client); |
| 80 } | 80 } |
| 81 | 81 |
| 82 LocalFileSystem::~LocalFileSystem() | 82 LocalFileSystem::~LocalFileSystem() |
| 83 { | 83 { |
| 84 } | 84 } |
| 85 | 85 |
| 86 void LocalFileSystem::resolveURL(ExecutionContext* context, const KURL& fileSyst
emURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 86 void LocalFileSystem::resolveURL(ExecutionContext* context, const KURL& fileSyst
emURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) |
| 87 { | 87 { |
| 88 RefPtrWillBeRawPtr<ExecutionContext> contextPtr(context); | 88 RawPtr<ExecutionContext> contextPtr(context); |
| 89 CallbackWrapper* wrapper = new CallbackWrapper(callbacks); | 89 CallbackWrapper* wrapper = new CallbackWrapper(callbacks); |
| 90 requestFileSystemAccessInternal(context, | 90 requestFileSystemAccessInternal(context, |
| 91 bind(&LocalFileSystem::resolveURLInternal, this, contextPtr, fileSystemU
RL, wrapper), | 91 bind(&LocalFileSystem::resolveURLInternal, this, contextPtr, fileSystemU
RL, wrapper), |
| 92 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); | 92 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void LocalFileSystem::requestFileSystem(ExecutionContext* context, FileSystemTyp
e type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 95 void LocalFileSystem::requestFileSystem(ExecutionContext* context, FileSystemTyp
e type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) |
| 96 { | 96 { |
| 97 RefPtrWillBeRawPtr<ExecutionContext> contextPtr(context); | 97 RawPtr<ExecutionContext> contextPtr(context); |
| 98 CallbackWrapper* wrapper = new CallbackWrapper(callbacks); | 98 CallbackWrapper* wrapper = new CallbackWrapper(callbacks); |
| 99 requestFileSystemAccessInternal(context, | 99 requestFileSystemAccessInternal(context, |
| 100 bind(&LocalFileSystem::fileSystemAllowedInternal, this, contextPtr, type
, wrapper), | 100 bind(&LocalFileSystem::fileSystemAllowedInternal, this, contextPtr, type
, wrapper), |
| 101 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); | 101 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void LocalFileSystem::deleteFileSystem(ExecutionContext* context, FileSystemType
type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 104 void LocalFileSystem::deleteFileSystem(ExecutionContext* context, FileSystemType
type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) |
| 105 { | 105 { |
| 106 RefPtrWillBeRawPtr<ExecutionContext> contextPtr(context); | 106 RawPtr<ExecutionContext> contextPtr(context); |
| 107 ASSERT(context); | 107 ASSERT(context); |
| 108 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument()); | 108 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument()); |
| 109 | 109 |
| 110 CallbackWrapper* wrapper = new CallbackWrapper(callbacks); | 110 CallbackWrapper* wrapper = new CallbackWrapper(callbacks); |
| 111 requestFileSystemAccessInternal(context, | 111 requestFileSystemAccessInternal(context, |
| 112 bind(&LocalFileSystem::deleteFileSystemInternal, this, contextPtr, type,
wrapper), | 112 bind(&LocalFileSystem::deleteFileSystemInternal, this, contextPtr, type,
wrapper), |
| 113 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); | 113 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 WebFileSystem* LocalFileSystem::fileSystem() const | 116 WebFileSystem* LocalFileSystem::fileSystem() const |
| (...skipping 15 matching lines...) Expand all Loading... |
| 132 (*denied)(); | 132 (*denied)(); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 (*allowed)(); | 135 (*allowed)(); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 client()->requestFileSystemAccessAsync(context, ContentSettingCallbacks::cre
ate(allowed, denied)); | 138 client()->requestFileSystemAccessAsync(context, ContentSettingCallbacks::cre
ate(allowed, denied)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void LocalFileSystem::fileSystemNotAvailable( | 141 void LocalFileSystem::fileSystemNotAvailable( |
| 142 PassRefPtrWillBeRawPtr<ExecutionContext> context, | 142 RawPtr<ExecutionContext> context, |
| 143 CallbackWrapper* callbacks) | 143 CallbackWrapper* callbacks) |
| 144 { | 144 { |
| 145 context->postTask(BLINK_FROM_HERE, createSameThreadTask(&reportFailure, call
backs->release(), FileError::ABORT_ERR)); | 145 context->postTask(BLINK_FROM_HERE, createSameThreadTask(&reportFailure, call
backs->release(), FileError::ABORT_ERR)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void LocalFileSystem::fileSystemNotAllowedInternal( | 148 void LocalFileSystem::fileSystemNotAllowedInternal( |
| 149 PassRefPtrWillBeRawPtr<ExecutionContext> context, | 149 RawPtr<ExecutionContext> context, |
| 150 CallbackWrapper* callbacks) | 150 CallbackWrapper* callbacks) |
| 151 { | 151 { |
| 152 context->postTask(BLINK_FROM_HERE, createSameThreadTask(&reportFailure, call
backs->release(), FileError::ABORT_ERR)); | 152 context->postTask(BLINK_FROM_HERE, createSameThreadTask(&reportFailure, call
backs->release(), FileError::ABORT_ERR)); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void LocalFileSystem::fileSystemAllowedInternal( | 155 void LocalFileSystem::fileSystemAllowedInternal( |
| 156 PassRefPtrWillBeRawPtr<ExecutionContext> context, | 156 RawPtr<ExecutionContext> context, |
| 157 FileSystemType type, | 157 FileSystemType type, |
| 158 CallbackWrapper* callbacks) | 158 CallbackWrapper* callbacks) |
| 159 { | 159 { |
| 160 if (!fileSystem()) { | 160 if (!fileSystem()) { |
| 161 fileSystemNotAvailable(context, callbacks); | 161 fileSystemNotAvailable(context, callbacks); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 | 164 |
| 165 KURL storagePartition = KURL(KURL(), context->getSecurityOrigin()->toString(
)); | 165 KURL storagePartition = KURL(KURL(), context->getSecurityOrigin()->toString(
)); |
| 166 fileSystem()->openFileSystem(storagePartition, static_cast<WebFileSystemType
>(type), callbacks->release()); | 166 fileSystem()->openFileSystem(storagePartition, static_cast<WebFileSystemType
>(type), callbacks->release()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void LocalFileSystem::resolveURLInternal( | 169 void LocalFileSystem::resolveURLInternal( |
| 170 PassRefPtrWillBeRawPtr<ExecutionContext> context, | 170 RawPtr<ExecutionContext> context, |
| 171 const KURL& fileSystemURL, | 171 const KURL& fileSystemURL, |
| 172 CallbackWrapper* callbacks) | 172 CallbackWrapper* callbacks) |
| 173 { | 173 { |
| 174 if (!fileSystem()) { | 174 if (!fileSystem()) { |
| 175 fileSystemNotAvailable(context, callbacks); | 175 fileSystemNotAvailable(context, callbacks); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 fileSystem()->resolveURL(fileSystemURL, callbacks->release()); | 178 fileSystem()->resolveURL(fileSystemURL, callbacks->release()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void LocalFileSystem::deleteFileSystemInternal( | 181 void LocalFileSystem::deleteFileSystemInternal( |
| 182 PassRefPtrWillBeRawPtr<ExecutionContext> context, | 182 RawPtr<ExecutionContext> context, |
| 183 FileSystemType type, | 183 FileSystemType type, |
| 184 CallbackWrapper* callbacks) | 184 CallbackWrapper* callbacks) |
| 185 { | 185 { |
| 186 if (!fileSystem()) { | 186 if (!fileSystem()) { |
| 187 fileSystemNotAvailable(context, callbacks); | 187 fileSystemNotAvailable(context, callbacks); |
| 188 return; | 188 return; |
| 189 } | 189 } |
| 190 KURL storagePartition = KURL(KURL(), context->getSecurityOrigin()->toString(
)); | 190 KURL storagePartition = KURL(KURL(), context->getSecurityOrigin()->toString(
)); |
| 191 fileSystem()->deleteFileSystem(storagePartition, static_cast<WebFileSystemTy
pe>(type), callbacks->release()); | 191 fileSystem()->deleteFileSystem(storagePartition, static_cast<WebFileSystemTy
pe>(type), callbacks->release()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 LocalFileSystem::LocalFileSystem(PassOwnPtr<FileSystemClient> client) | 194 LocalFileSystem::LocalFileSystem(PassOwnPtr<FileSystemClient> client) |
| 195 : m_client(client) | 195 : m_client(client) |
| 196 { | 196 { |
| 197 } | 197 } |
| 198 | 198 |
| 199 const char* LocalFileSystem::supplementName() | 199 const char* LocalFileSystem::supplementName() |
| 200 { | 200 { |
| 201 return "LocalFileSystem"; | 201 return "LocalFileSystem"; |
| 202 } | 202 } |
| 203 | 203 |
| 204 LocalFileSystem* LocalFileSystem::from(ExecutionContext& context) | 204 LocalFileSystem* LocalFileSystem::from(ExecutionContext& context) |
| 205 { | 205 { |
| 206 if (context.isDocument()) | 206 if (context.isDocument()) |
| 207 return static_cast<LocalFileSystem*>(WillBeHeapSupplement<LocalFrame>::f
rom(toDocument(context).frame(), supplementName())); | 207 return static_cast<LocalFileSystem*>(HeapSupplement<LocalFrame>::from(to
Document(context).frame(), supplementName())); |
| 208 | 208 |
| 209 WorkerClients* clients = toWorkerGlobalScope(context).clients(); | 209 WorkerClients* clients = toWorkerGlobalScope(context).clients(); |
| 210 ASSERT(clients); | 210 ASSERT(clients); |
| 211 return static_cast<LocalFileSystem*>(WillBeHeapSupplement<WorkerClients>::fr
om(clients, supplementName())); | 211 return static_cast<LocalFileSystem*>(HeapSupplement<WorkerClients>::from(cli
ents, supplementName())); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void provideLocalFileSystemTo(LocalFrame& frame, PassOwnPtr<FileSystemClient> cl
ient) | 214 void provideLocalFileSystemTo(LocalFrame& frame, PassOwnPtr<FileSystemClient> cl
ient) |
| 215 { | 215 { |
| 216 frame.provideSupplement(LocalFileSystem::supplementName(), LocalFileSystem::
create(client)); | 216 frame.provideSupplement(LocalFileSystem::supplementName(), LocalFileSystem::
create(client)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void provideLocalFileSystemToWorker(WorkerClients* clients, PassOwnPtr<FileSyste
mClient> client) | 219 void provideLocalFileSystemToWorker(WorkerClients* clients, PassOwnPtr<FileSyste
mClient> client) |
| 220 { | 220 { |
| 221 clients->provideSupplement(LocalFileSystem::supplementName(), LocalFileSyste
m::create(client)); | 221 clients->provideSupplement(LocalFileSystem::supplementName(), LocalFileSyste
m::create(client)); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace blink | 224 } // namespace blink |
| OLD | NEW |