Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/fileapi/file_system_operation.h" | 5 #include "webkit/fileapi/file_system_operation.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "net/url_request/url_request_context.h" | 8 #include "net/url_request/url_request_context.h" |
| 9 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 9 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 10 #include "webkit/fileapi/file_system_context.h" | 10 #include "webkit/fileapi/file_system_context.h" |
| 11 #include "webkit/fileapi/file_system_file_util_proxy.h" | |
| 12 #include "webkit/fileapi/file_system_operation_context.h" | |
| 11 #include "webkit/fileapi/file_system_path_manager.h" | 13 #include "webkit/fileapi/file_system_path_manager.h" |
| 12 #include "webkit/fileapi/file_system_quota_manager.h" | 14 #include "webkit/fileapi/file_system_quota_manager.h" |
| 13 #include "webkit/fileapi/file_writer_delegate.h" | 15 #include "webkit/fileapi/file_writer_delegate.h" |
| 14 | 16 |
| 15 namespace fileapi { | 17 namespace fileapi { |
| 16 | 18 |
| 17 FileSystemOperation::FileSystemOperation( | 19 FileSystemOperation::FileSystemOperation( |
| 18 FileSystemCallbackDispatcher* dispatcher, | 20 FileSystemCallbackDispatcher* dispatcher, |
| 19 scoped_refptr<base::MessageLoopProxy> proxy, | 21 scoped_refptr<base::MessageLoopProxy> proxy, |
| 20 FileSystemContext* file_system_context) | 22 FileSystemContext* file_system_context) |
| 21 : proxy_(proxy), | 23 : proxy_(proxy), |
| 22 dispatcher_(dispatcher), | 24 dispatcher_(dispatcher), |
| 23 file_system_context_(file_system_context), | 25 file_system_context_(file_system_context), |
| 26 file_system_operation_context_( | |
| 27 new FileSystemOperationContext(file_system_context)), | |
| 24 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 28 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 25 DCHECK(dispatcher); | 29 DCHECK(dispatcher); |
| 26 #ifndef NDEBUG | 30 #ifndef NDEBUG |
| 27 pending_operation_ = kOperationNone; | 31 pending_operation_ = kOperationNone; |
| 28 #endif | 32 #endif |
| 29 } | 33 } |
| 30 | 34 |
| 31 FileSystemOperation::~FileSystemOperation() { | 35 FileSystemOperation::~FileSystemOperation() { |
| 32 if (file_writer_delegate_.get()) | 36 if (file_writer_delegate_.get()) |
| 33 base::FileUtilProxy::Close(proxy_, file_writer_delegate_->file(), NULL); | 37 FileSystemFileUtilProxy::Close( |
| 38 file_system_operation_context_.get(), | |
| 39 proxy_, file_writer_delegate_->file(), NULL); | |
|
Dai Mikurube (google.com)
2011/02/22 10:13:53
It's to be fixed as follows :
base::FileUtilProxy:
| |
| 34 } | 40 } |
| 35 | 41 |
| 36 void FileSystemOperation::OpenFileSystem( | 42 void FileSystemOperation::OpenFileSystem( |
| 37 const GURL& origin_url, fileapi::FileSystemType type, bool create) { | 43 const GURL& origin_url, fileapi::FileSystemType type, bool create) { |
| 38 #ifndef NDEBUG | 44 #ifndef NDEBUG |
| 39 DCHECK(kOperationNone == pending_operation_); | 45 DCHECK(kOperationNone == pending_operation_); |
| 40 pending_operation_ = static_cast<FileSystemOperation::OperationType>( | 46 pending_operation_ = static_cast<FileSystemOperation::OperationType>( |
| 41 kOperationOpenFileSystem); | 47 kOperationOpenFileSystem); |
| 42 #endif | 48 #endif |
| 43 | 49 |
| 44 DCHECK(file_system_context_.get()); | 50 DCHECK(file_system_context_.get()); |
| 45 file_system_context_->path_manager()->GetFileSystemRootPath( | 51 file_system_context_->path_manager()->GetFileSystemRootPath( |
| 46 origin_url, type, create, | 52 origin_url, type, create, |
| 47 callback_factory_.NewCallback(&FileSystemOperation::DidGetRootPath)); | 53 callback_factory_.NewCallback(&FileSystemOperation::DidGetRootPath)); |
| 48 } | 54 } |
| 49 | 55 |
| 50 void FileSystemOperation::CreateFile(const FilePath& path, | 56 void FileSystemOperation::CreateFile(const FilePath& path, |
| 51 bool exclusive) { | 57 bool exclusive) { |
| 52 #ifndef NDEBUG | 58 #ifndef NDEBUG |
| 53 DCHECK(kOperationNone == pending_operation_); | 59 DCHECK(kOperationNone == pending_operation_); |
| 54 pending_operation_ = kOperationCreateFile; | 60 pending_operation_ = kOperationCreateFile; |
| 55 #endif | 61 #endif |
| 56 | 62 |
| 57 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) { | 63 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) { |
| 58 delete this; | 64 delete this; |
| 59 return; | 65 return; |
| 60 } | 66 } |
| 61 base::FileUtilProxy::EnsureFileExists( | 67 FileSystemFileUtilProxy::EnsureFileExists( |
| 62 proxy_, path, callback_factory_.NewCallback( | 68 file_system_operation_context_.get(), |
| 63 exclusive ? &FileSystemOperation::DidEnsureFileExistsExclusive | 69 proxy_, path, callback_factory_.NewCallback( |
| 64 : &FileSystemOperation::DidEnsureFileExistsNonExclusive)); | 70 exclusive ? &FileSystemOperation::DidEnsureFileExistsExclusive |
| 71 : &FileSystemOperation::DidEnsureFileExistsNonExclusive)); | |
| 65 } | 72 } |
| 66 | 73 |
| 67 void FileSystemOperation::CreateDirectory(const FilePath& path, | 74 void FileSystemOperation::CreateDirectory(const FilePath& path, |
| 68 bool exclusive, | 75 bool exclusive, |
| 69 bool recursive) { | 76 bool unused) { |
| 70 #ifndef NDEBUG | 77 #ifndef NDEBUG |
| 71 DCHECK(kOperationNone == pending_operation_); | 78 DCHECK(kOperationNone == pending_operation_); |
| 72 pending_operation_ = kOperationCreateDirectory; | 79 pending_operation_ = kOperationCreateDirectory; |
| 73 #endif | 80 #endif |
| 74 | 81 |
| 75 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) { | 82 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) { |
| 76 delete this; | 83 delete this; |
| 77 return; | 84 return; |
| 78 } | 85 } |
| 79 base::FileUtilProxy::CreateDirectory( | 86 FileSystemFileUtilProxy::CreateDirectory( |
| 80 proxy_, path, exclusive, recursive, callback_factory_.NewCallback( | 87 file_system_operation_context_.get(), |
| 88 proxy_, path, exclusive, callback_factory_.NewCallback( | |
| 81 &FileSystemOperation::DidFinishFileOperation)); | 89 &FileSystemOperation::DidFinishFileOperation)); |
| 82 } | 90 } |
| 83 | 91 |
| 84 void FileSystemOperation::Copy(const FilePath& src_path, | 92 void FileSystemOperation::Copy(const FilePath& src_path, |
| 85 const FilePath& dest_path) { | 93 const FilePath& dest_path) { |
| 86 #ifndef NDEBUG | 94 #ifndef NDEBUG |
| 87 DCHECK(kOperationNone == pending_operation_); | 95 DCHECK(kOperationNone == pending_operation_); |
| 88 pending_operation_ = kOperationCopy; | 96 pending_operation_ = kOperationCopy; |
| 89 #endif | 97 #endif |
| 90 | 98 |
| 91 if (!VerifyFileSystemPathForRead(src_path) || | 99 if (!VerifyFileSystemPathForRead(src_path) || |
| 92 !VerifyFileSystemPathForWrite(dest_path, true /* create */, | 100 !VerifyFileSystemPathForWrite(dest_path, true /* create */, |
| 93 FileSystemQuotaManager::kUnknownSize)) { | 101 FileSystemQuotaManager::kUnknownSize)) { |
| 94 delete this; | 102 delete this; |
| 95 return; | 103 return; |
| 96 } | 104 } |
| 97 base::FileUtilProxy::Copy(proxy_, src_path, dest_path, | 105 FileSystemFileUtilProxy::Copy( |
| 98 callback_factory_.NewCallback( | 106 file_system_operation_context_.get(), |
| 107 proxy_, src_path, dest_path, callback_factory_.NewCallback( | |
| 99 &FileSystemOperation::DidFinishFileOperation)); | 108 &FileSystemOperation::DidFinishFileOperation)); |
| 100 } | 109 } |
| 101 | 110 |
| 102 void FileSystemOperation::Move(const FilePath& src_path, | 111 void FileSystemOperation::Move(const FilePath& src_path, |
| 103 const FilePath& dest_path) { | 112 const FilePath& dest_path) { |
| 104 #ifndef NDEBUG | 113 #ifndef NDEBUG |
| 105 DCHECK(kOperationNone == pending_operation_); | 114 DCHECK(kOperationNone == pending_operation_); |
| 106 pending_operation_ = kOperationMove; | 115 pending_operation_ = kOperationMove; |
| 107 #endif | 116 #endif |
| 108 | 117 |
| 109 if (!VerifyFileSystemPathForRead(src_path) || | 118 if (!VerifyFileSystemPathForRead(src_path) || |
| 110 !VerifyFileSystemPathForWrite(dest_path, true /* create */, | 119 !VerifyFileSystemPathForWrite(dest_path, true /* create */, |
| 111 FileSystemQuotaManager::kUnknownSize)) { | 120 FileSystemQuotaManager::kUnknownSize)) { |
| 112 delete this; | 121 delete this; |
| 113 return; | 122 return; |
| 114 } | 123 } |
| 115 base::FileUtilProxy::Move(proxy_, src_path, dest_path, | 124 FileSystemFileUtilProxy::Move( |
| 116 callback_factory_.NewCallback( | 125 file_system_operation_context_.get(), |
| 126 proxy_, src_path, dest_path, callback_factory_.NewCallback( | |
| 117 &FileSystemOperation::DidFinishFileOperation)); | 127 &FileSystemOperation::DidFinishFileOperation)); |
| 118 } | 128 } |
| 119 | 129 |
| 120 void FileSystemOperation::DirectoryExists(const FilePath& path) { | 130 void FileSystemOperation::DirectoryExists(const FilePath& path) { |
| 121 #ifndef NDEBUG | 131 #ifndef NDEBUG |
| 122 DCHECK(kOperationNone == pending_operation_); | 132 DCHECK(kOperationNone == pending_operation_); |
| 123 pending_operation_ = kOperationDirectoryExists; | 133 pending_operation_ = kOperationDirectoryExists; |
| 124 #endif | 134 #endif |
| 125 | 135 |
| 126 if (!VerifyFileSystemPathForRead(path)) { | 136 if (!VerifyFileSystemPathForRead(path)) { |
| 127 delete this; | 137 delete this; |
| 128 return; | 138 return; |
| 129 } | 139 } |
| 130 base::FileUtilProxy::GetFileInfo(proxy_, path, callback_factory_.NewCallback( | 140 FileSystemFileUtilProxy::GetFileInfo( |
| 131 &FileSystemOperation::DidDirectoryExists)); | 141 file_system_operation_context_.get(), |
| 142 proxy_, path, callback_factory_.NewCallback( | |
| 143 &FileSystemOperation::DidDirectoryExists)); | |
| 132 } | 144 } |
| 133 | 145 |
| 134 void FileSystemOperation::FileExists(const FilePath& path) { | 146 void FileSystemOperation::FileExists(const FilePath& path) { |
| 135 #ifndef NDEBUG | 147 #ifndef NDEBUG |
| 136 DCHECK(kOperationNone == pending_operation_); | 148 DCHECK(kOperationNone == pending_operation_); |
| 137 pending_operation_ = kOperationFileExists; | 149 pending_operation_ = kOperationFileExists; |
| 138 #endif | 150 #endif |
| 139 | 151 |
| 140 if (!VerifyFileSystemPathForRead(path)) { | 152 if (!VerifyFileSystemPathForRead(path)) { |
| 141 delete this; | 153 delete this; |
| 142 return; | 154 return; |
| 143 } | 155 } |
| 144 base::FileUtilProxy::GetFileInfo(proxy_, path, callback_factory_.NewCallback( | 156 FileSystemFileUtilProxy::GetFileInfo( |
| 145 &FileSystemOperation::DidFileExists)); | 157 file_system_operation_context_.get(), |
| 158 proxy_, path, callback_factory_.NewCallback( | |
| 159 &FileSystemOperation::DidFileExists)); | |
| 146 } | 160 } |
| 147 | 161 |
| 148 void FileSystemOperation::GetMetadata(const FilePath& path) { | 162 void FileSystemOperation::GetMetadata(const FilePath& path) { |
| 149 #ifndef NDEBUG | 163 #ifndef NDEBUG |
| 150 DCHECK(kOperationNone == pending_operation_); | 164 DCHECK(kOperationNone == pending_operation_); |
| 151 pending_operation_ = kOperationGetMetadata; | 165 pending_operation_ = kOperationGetMetadata; |
| 152 #endif | 166 #endif |
| 153 | 167 |
| 154 if (!VerifyFileSystemPathForRead(path)) { | 168 if (!VerifyFileSystemPathForRead(path)) { |
| 155 delete this; | 169 delete this; |
| 156 return; | 170 return; |
| 157 } | 171 } |
| 158 base::FileUtilProxy::GetFileInfo(proxy_, path, callback_factory_.NewCallback( | 172 FileSystemFileUtilProxy::GetFileInfo( |
| 159 &FileSystemOperation::DidGetMetadata)); | 173 file_system_operation_context_.get(), |
| 174 proxy_, path, callback_factory_.NewCallback( | |
| 175 &FileSystemOperation::DidGetMetadata)); | |
| 160 } | 176 } |
| 161 | 177 |
| 162 void FileSystemOperation::ReadDirectory(const FilePath& path) { | 178 void FileSystemOperation::ReadDirectory(const FilePath& path) { |
| 163 #ifndef NDEBUG | 179 #ifndef NDEBUG |
| 164 DCHECK(kOperationNone == pending_operation_); | 180 DCHECK(kOperationNone == pending_operation_); |
| 165 pending_operation_ = kOperationReadDirectory; | 181 pending_operation_ = kOperationReadDirectory; |
| 166 #endif | 182 #endif |
| 167 | 183 |
| 168 if (!VerifyFileSystemPathForRead(path)) { | 184 if (!VerifyFileSystemPathForRead(path)) { |
| 169 delete this; | 185 delete this; |
| 170 return; | 186 return; |
| 171 } | 187 } |
| 172 base::FileUtilProxy::ReadDirectory(proxy_, path, | 188 FileSystemFileUtilProxy::ReadDirectory( |
| 173 callback_factory_.NewCallback( | 189 file_system_operation_context_.get(), |
| 190 proxy_, path, callback_factory_.NewCallback( | |
| 174 &FileSystemOperation::DidReadDirectory)); | 191 &FileSystemOperation::DidReadDirectory)); |
| 175 } | 192 } |
| 176 | 193 |
| 177 void FileSystemOperation::Remove(const FilePath& path, bool recursive) { | 194 void FileSystemOperation::Remove(const FilePath& path, bool recursive) { |
| 178 #ifndef NDEBUG | 195 #ifndef NDEBUG |
| 179 DCHECK(kOperationNone == pending_operation_); | 196 DCHECK(kOperationNone == pending_operation_); |
| 180 pending_operation_ = kOperationRemove; | 197 pending_operation_ = kOperationRemove; |
| 181 #endif | 198 #endif |
| 182 | 199 |
| 183 if (!VerifyFileSystemPathForWrite(path, false /* create */, 0)) { | 200 if (!VerifyFileSystemPathForWrite(path, false /* create */, 0)) { |
| 184 delete this; | 201 delete this; |
| 185 return; | 202 return; |
| 186 } | 203 } |
| 187 base::FileUtilProxy::Delete(proxy_, path, recursive, | 204 FileSystemFileUtilProxy::Delete( |
| 188 callback_factory_.NewCallback( | 205 file_system_operation_context_.get(), |
| 206 proxy_, path, recursive, callback_factory_.NewCallback( | |
| 189 &FileSystemOperation::DidFinishFileOperation)); | 207 &FileSystemOperation::DidFinishFileOperation)); |
| 190 } | 208 } |
| 191 | 209 |
| 192 void FileSystemOperation::Write( | 210 void FileSystemOperation::Write( |
| 193 scoped_refptr<net::URLRequestContext> url_request_context, | 211 scoped_refptr<net::URLRequestContext> url_request_context, |
| 194 const FilePath& path, | 212 const FilePath& path, |
| 195 const GURL& blob_url, | 213 const GURL& blob_url, |
| 196 int64 offset) { | 214 int64 offset) { |
| 197 #ifndef NDEBUG | 215 #ifndef NDEBUG |
| 198 DCHECK(kOperationNone == pending_operation_); | 216 DCHECK(kOperationNone == pending_operation_); |
| 199 pending_operation_ = kOperationWrite; | 217 pending_operation_ = kOperationWrite; |
| 200 #endif | 218 #endif |
| 201 if (!VerifyFileSystemPathForWrite(path, true /* create */, | 219 if (!VerifyFileSystemPathForWrite(path, true /* create */, |
| 202 FileSystemQuotaManager::kUnknownSize)) { | 220 FileSystemQuotaManager::kUnknownSize)) { |
| 203 delete this; | 221 delete this; |
| 204 return; | 222 return; |
| 205 } | 223 } |
| 206 DCHECK(blob_url.is_valid()); | 224 DCHECK(blob_url.is_valid()); |
| 207 file_writer_delegate_.reset(new FileWriterDelegate(this, offset)); | 225 file_writer_delegate_.reset(new FileWriterDelegate(this, offset)); |
| 208 blob_request_.reset( | 226 blob_request_.reset( |
| 209 new net::URLRequest(blob_url, file_writer_delegate_.get())); | 227 new net::URLRequest(blob_url, file_writer_delegate_.get())); |
| 210 blob_request_->set_context(url_request_context); | 228 blob_request_->set_context(url_request_context); |
| 211 base::FileUtilProxy::CreateOrOpen( | 229 FileSystemFileUtilProxy::CreateOrOpen( |
| 230 file_system_operation_context_.get(), | |
| 212 proxy_, | 231 proxy_, |
| 213 path, | 232 path, |
| 214 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | | 233 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | |
| 215 base::PLATFORM_FILE_ASYNC, | 234 base::PLATFORM_FILE_ASYNC, |
| 216 callback_factory_.NewCallback( | 235 callback_factory_.NewCallback( |
| 217 &FileSystemOperation::OnFileOpenedForWrite)); | 236 &FileSystemOperation::OnFileOpenedForWrite)); |
| 218 } | 237 } |
| 219 | 238 |
| 220 void FileSystemOperation::Truncate(const FilePath& path, int64 length) { | 239 void FileSystemOperation::Truncate(const FilePath& path, int64 length) { |
| 221 #ifndef NDEBUG | 240 #ifndef NDEBUG |
| 222 DCHECK(kOperationNone == pending_operation_); | 241 DCHECK(kOperationNone == pending_operation_); |
| 223 pending_operation_ = kOperationTruncate; | 242 pending_operation_ = kOperationTruncate; |
| 224 #endif | 243 #endif |
| 225 if (!VerifyFileSystemPathForWrite(path, false /* create */, 0)) { | 244 if (!VerifyFileSystemPathForWrite(path, false /* create */, 0)) { |
| 226 delete this; | 245 delete this; |
| 227 return; | 246 return; |
| 228 } | 247 } |
| 229 base::FileUtilProxy::Truncate(proxy_, path, length, | 248 FileSystemFileUtilProxy::Truncate( |
| 230 callback_factory_.NewCallback( | 249 file_system_operation_context_.get(), |
| 250 proxy_, path, length, callback_factory_.NewCallback( | |
| 231 &FileSystemOperation::DidFinishFileOperation)); | 251 &FileSystemOperation::DidFinishFileOperation)); |
| 232 } | 252 } |
| 233 | 253 |
| 234 void FileSystemOperation::TouchFile(const FilePath& path, | 254 void FileSystemOperation::TouchFile(const FilePath& path, |
| 235 const base::Time& last_access_time, | 255 const base::Time& last_access_time, |
| 236 const base::Time& last_modified_time) { | 256 const base::Time& last_modified_time) { |
| 237 #ifndef NDEBUG | 257 #ifndef NDEBUG |
| 238 DCHECK(kOperationNone == pending_operation_); | 258 DCHECK(kOperationNone == pending_operation_); |
| 239 pending_operation_ = kOperationTouchFile; | 259 pending_operation_ = kOperationTouchFile; |
| 240 #endif | 260 #endif |
| 241 | 261 |
| 242 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) { | 262 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) { |
| 243 delete this; | 263 delete this; |
| 244 return; | 264 return; |
| 245 } | 265 } |
| 246 base::FileUtilProxy::Touch( | 266 FileSystemFileUtilProxy::Touch( |
| 267 file_system_operation_context_.get(), | |
| 247 proxy_, path, last_access_time, last_modified_time, | 268 proxy_, path, last_access_time, last_modified_time, |
| 248 callback_factory_.NewCallback(&FileSystemOperation::DidTouchFile)); | 269 callback_factory_.NewCallback(&FileSystemOperation::DidTouchFile)); |
| 249 } | 270 } |
| 250 | 271 |
| 251 // We can only get here on a write or truncate that's not yet completed. | 272 // We can only get here on a write or truncate that's not yet completed. |
| 252 // We don't support cancelling any other operation at this time. | 273 // We don't support cancelling any other operation at this time. |
| 253 void FileSystemOperation::Cancel(FileSystemOperation* cancel_operation_ptr) { | 274 void FileSystemOperation::Cancel(FileSystemOperation* cancel_operation_ptr) { |
| 254 scoped_ptr<FileSystemOperation> cancel_operation(cancel_operation_ptr); | 275 scoped_ptr<FileSystemOperation> cancel_operation(cancel_operation_ptr); |
| 255 if (file_writer_delegate_.get()) { | 276 if (file_writer_delegate_.get()) { |
| 256 #ifndef NDEBUG | 277 #ifndef NDEBUG |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 | 422 |
| 402 bool FileSystemOperation::VerifyFileSystemPathForRead( | 423 bool FileSystemOperation::VerifyFileSystemPathForRead( |
| 403 const FilePath& path) { | 424 const FilePath& path) { |
| 404 // If we have no context, we just allow any operations. | 425 // If we have no context, we just allow any operations. |
| 405 if (!file_system_context_.get()) | 426 if (!file_system_context_.get()) |
| 406 return true; | 427 return true; |
| 407 | 428 |
| 408 // We may want do more checks, but for now it just checks if the given | 429 // We may want do more checks, but for now it just checks if the given |
| 409 // |path| is under the valid FileSystem root path for this host context. | 430 // |path| is under the valid FileSystem root path for this host context. |
| 410 if (!file_system_context_->path_manager()->CrackFileSystemPath( | 431 if (!file_system_context_->path_manager()->CrackFileSystemPath( |
| 411 path, NULL, NULL, NULL)) { | 432 path, NULL, NULL, NULL, NULL)) { |
| 412 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 433 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
| 413 return false; | 434 return false; |
| 414 } | 435 } |
| 415 return true; | 436 return true; |
| 416 } | 437 } |
| 417 | 438 |
| 418 bool FileSystemOperation::VerifyFileSystemPathForWrite( | 439 bool FileSystemOperation::VerifyFileSystemPathForWrite( |
| 419 const FilePath& path, bool create, int64 growth) { | 440 const FilePath& path, bool create, int64 growth) { |
| 420 GURL origin_url; | 441 GURL origin_url; |
| 421 FilePath virtual_path; | 442 FilePath virtual_path; |
| 422 | 443 |
| 423 // If we have no context, we just allow any operations. | 444 // If we have no context, we just allow any operations. |
| 424 if (!file_system_context_.get()) | 445 if (!file_system_context_.get()) |
| 425 return true; | 446 return true; |
| 426 | 447 |
| 427 if (!file_system_context_->path_manager()->CrackFileSystemPath( | 448 if (!file_system_context_->path_manager()->CrackFileSystemPath( |
| 428 path, &origin_url, NULL, &virtual_path)) { | 449 path, &origin_url, NULL, NULL, &virtual_path)) { |
| 429 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 450 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
| 430 return false; | 451 return false; |
| 431 } | 452 } |
| 432 // Any write access is disallowed on the root path. | 453 // Any write access is disallowed on the root path. |
| 433 if (virtual_path.value().length() == 0 || | 454 if (virtual_path.value().length() == 0 || |
| 434 virtual_path.DirName().value() == virtual_path.value()) { | 455 virtual_path.DirName().value() == virtual_path.value()) { |
| 435 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 456 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
| 436 return false; | 457 return false; |
| 437 } | 458 } |
| 438 if (create && file_system_context_->path_manager()->IsRestrictedFileName( | 459 if (create && file_system_context_->path_manager()->IsRestrictedFileName( |
| 439 path.BaseName())) { | 460 path.BaseName())) { |
| 440 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 461 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
| 441 return false; | 462 return false; |
| 442 } | 463 } |
| 443 // TODO(kinuko): For operations with kUnknownSize we'll eventually | 464 // TODO(kinuko): For operations with kUnknownSize we'll eventually |
| 444 // need to resolve what amount of size it's going to write. | 465 // need to resolve what amount of size it's going to write. |
| 445 if (!file_system_context_->quota_manager()->CheckOriginQuota( | 466 if (!file_system_context_->quota_manager()->CheckOriginQuota( |
| 446 origin_url, growth)) { | 467 origin_url, growth)) { |
| 447 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); | 468 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); |
| 448 return false; | 469 return false; |
| 449 } | 470 } |
| 450 return true; | 471 return true; |
| 451 } | 472 } |
| 452 | 473 |
| 453 } // namespace fileapi | 474 } // namespace fileapi |
| OLD | NEW |