| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/local_file_system_operation.h" | 5 #include "webkit/fileapi/local_file_system_operation.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "net/base/escape.h" | 11 #include "net/base/escape.h" |
| 12 #include "net/url_request/url_request_context.h" | 12 #include "net/url_request/url_request_context.h" |
| 13 #include "webkit/blob/shareable_file_reference.h" | 13 #include "webkit/blob/shareable_file_reference.h" |
| 14 #include "webkit/fileapi/cross_operation_delegate.h" |
| 14 #include "webkit/fileapi/file_observers.h" | 15 #include "webkit/fileapi/file_observers.h" |
| 15 #include "webkit/fileapi/file_system_context.h" | 16 #include "webkit/fileapi/file_system_context.h" |
| 16 #include "webkit/fileapi/file_system_file_util_proxy.h" | 17 #include "webkit/fileapi/file_system_file_util_proxy.h" |
| 17 #include "webkit/fileapi/file_system_mount_point_provider.h" | 18 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 18 #include "webkit/fileapi/file_system_task_runners.h" | 19 #include "webkit/fileapi/file_system_task_runners.h" |
| 19 #include "webkit/fileapi/file_system_types.h" | 20 #include "webkit/fileapi/file_system_types.h" |
| 20 #include "webkit/fileapi/file_system_url.h" | 21 #include "webkit/fileapi/file_system_url.h" |
| 21 #include "webkit/fileapi/file_system_util.h" | 22 #include "webkit/fileapi/file_system_util.h" |
| 22 #include "webkit/fileapi/file_writer_delegate.h" | 23 #include "webkit/fileapi/file_writer_delegate.h" |
| 23 #include "webkit/fileapi/remove_operation_delegate.h" | 24 #include "webkit/fileapi/remove_operation_delegate.h" |
| 24 #include "webkit/fileapi/sandbox_file_stream_writer.h" | 25 #include "webkit/fileapi/sandbox_file_stream_writer.h" |
| 25 #include "webkit/quota/quota_manager.h" | 26 #include "webkit/quota/quota_manager.h" |
| 26 #include "webkit/quota/quota_types.h" | 27 #include "webkit/quota/quota_types.h" |
| 27 | 28 |
| 28 using webkit_blob::ShareableFileReference; | 29 using webkit_blob::ShareableFileReference; |
| 29 | 30 |
| 30 namespace fileapi { | 31 namespace fileapi { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 bool IsMediaFileSystemType(FileSystemType type) { | 35 bool IsMediaFileSystemType(FileSystemType type) { |
| 35 return type == kFileSystemTypeNativeMedia || | 36 return type == kFileSystemTypeNativeMedia || |
| 36 type == kFileSystemTypeDeviceMedia; | 37 type == kFileSystemTypeDeviceMedia; |
| 37 } | 38 } |
| 38 | 39 |
| 39 bool IsCrossOperationAllowed(FileSystemType src_type, | |
| 40 FileSystemType dest_type) { | |
| 41 // If two types are supposed to run on different task runners we should not | |
| 42 // allow cross FileUtil operations at this layer. | |
| 43 return IsMediaFileSystemType(src_type) == IsMediaFileSystemType(dest_type); | |
| 44 } | |
| 45 | |
| 46 } // namespace | 40 } // namespace |
| 47 | 41 |
| 48 // LocalFileSystemOperation::ScopedUpdateNotifier ----------------------------- | 42 // LocalFileSystemOperation::ScopedUpdateNotifier ----------------------------- |
| 49 | 43 |
| 50 class LocalFileSystemOperation::ScopedUpdateNotifier { | 44 class LocalFileSystemOperation::ScopedUpdateNotifier { |
| 51 public: | 45 public: |
| 52 ScopedUpdateNotifier(FileSystemOperationContext* operation_context, | 46 ScopedUpdateNotifier(FileSystemOperationContext* operation_context, |
| 53 const FileSystemURL& url); | 47 const FileSystemURL& url); |
| 54 ~ScopedUpdateNotifier(); | 48 ~ScopedUpdateNotifier(); |
| 55 | 49 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 77 // LocalFileSystemOperation --------------------------------------------------- | 71 // LocalFileSystemOperation --------------------------------------------------- |
| 78 | 72 |
| 79 LocalFileSystemOperation::~LocalFileSystemOperation() { | 73 LocalFileSystemOperation::~LocalFileSystemOperation() { |
| 80 } | 74 } |
| 81 | 75 |
| 82 void LocalFileSystemOperation::CreateFile(const FileSystemURL& url, | 76 void LocalFileSystemOperation::CreateFile(const FileSystemURL& url, |
| 83 bool exclusive, | 77 bool exclusive, |
| 84 const StatusCallback& callback) { | 78 const StatusCallback& callback) { |
| 85 DCHECK(SetPendingOperationType(kOperationCreateFile)); | 79 DCHECK(SetPendingOperationType(kOperationCreateFile)); |
| 86 | 80 |
| 87 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_CREATE); | 81 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_CREATE); |
| 88 if (result != base::PLATFORM_FILE_OK) { | 82 if (result != base::PLATFORM_FILE_OK) { |
| 89 callback.Run(result); | 83 callback.Run(result); |
| 90 delete this; | 84 delete this; |
| 91 return; | 85 return; |
| 92 } | 86 } |
| 93 | 87 |
| 94 GetUsageAndQuotaThenRunTask( | 88 GetUsageAndQuotaThenRunTask( |
| 95 url, | 89 url, |
| 96 base::Bind(&LocalFileSystemOperation::DoCreateFile, | 90 base::Bind(&LocalFileSystemOperation::DoCreateFile, |
| 97 base::Unretained(this), url, callback, exclusive), | 91 base::Unretained(this), url, callback, exclusive), |
| 98 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 92 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
| 99 } | 93 } |
| 100 | 94 |
| 101 void LocalFileSystemOperation::CreateDirectory(const FileSystemURL& url, | 95 void LocalFileSystemOperation::CreateDirectory(const FileSystemURL& url, |
| 102 bool exclusive, | 96 bool exclusive, |
| 103 bool recursive, | 97 bool recursive, |
| 104 const StatusCallback& callback) { | 98 const StatusCallback& callback) { |
| 105 DCHECK(SetPendingOperationType(kOperationCreateDirectory)); | 99 DCHECK(SetPendingOperationType(kOperationCreateDirectory)); |
| 106 | 100 |
| 107 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_CREATE); | 101 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_CREATE); |
| 108 if (result != base::PLATFORM_FILE_OK) { | 102 if (result != base::PLATFORM_FILE_OK) { |
| 109 callback.Run(result); | 103 callback.Run(result); |
| 110 delete this; | 104 delete this; |
| 111 return; | 105 return; |
| 112 } | 106 } |
| 113 GetUsageAndQuotaThenRunTask( | 107 GetUsageAndQuotaThenRunTask( |
| 114 url, | 108 url, |
| 115 base::Bind(&LocalFileSystemOperation::DoCreateDirectory, | 109 base::Bind(&LocalFileSystemOperation::DoCreateDirectory, |
| 116 base::Unretained(this), url, callback, exclusive, recursive), | 110 base::Unretained(this), url, callback, exclusive, recursive), |
| 117 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 111 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
| 118 } | 112 } |
| 119 | 113 |
| 120 void LocalFileSystemOperation::Copy(const FileSystemURL& src_url, | 114 void LocalFileSystemOperation::Copy(const FileSystemURL& src_url, |
| 121 const FileSystemURL& dest_url, | 115 const FileSystemURL& dest_url, |
| 122 const StatusCallback& callback) { | 116 const StatusCallback& callback) { |
| 123 DCHECK(SetPendingOperationType(kOperationCopy)); | 117 DCHECK(SetPendingOperationType(kOperationCopy)); |
| 124 is_cross_operation_ = (src_url.type() != dest_url.type()); | |
| 125 | 118 |
| 126 base::PlatformFileError result = SetUp(src_url, &src_util_, SETUP_FOR_READ); | 119 base::PlatformFileError result = SetUp( |
| 127 if (result == base::PLATFORM_FILE_OK) | 120 dest_url, &file_util_, SETUP_FOR_WRITE); |
| 128 result = SetUp(dest_url, &dest_util_, SETUP_FOR_CREATE); | |
| 129 if (result == base::PLATFORM_FILE_OK) { | |
| 130 if (!IsCrossOperationAllowed(src_url.type(), dest_url.type())) | |
| 131 result = base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | |
| 132 } | |
| 133 if (result != base::PLATFORM_FILE_OK) { | 121 if (result != base::PLATFORM_FILE_OK) { |
| 134 callback.Run(result); | 122 callback.Run(result); |
| 135 delete this; | 123 delete this; |
| 136 return; | 124 return; |
| 137 } | 125 } |
| 138 | 126 |
| 139 GetUsageAndQuotaThenRunTask( | 127 DCHECK(!recursive_operation_delegate_); |
| 140 dest_url, | 128 recursive_operation_delegate_.reset( |
| 141 base::Bind(&LocalFileSystemOperation::DoCopy, | 129 new CrossOperationDelegate(this, src_url, dest_url, |
| 142 base::Unretained(this), src_url, dest_url, callback), | 130 CrossOperationDelegate::OPERATION_COPY, |
| 143 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 131 callback)); |
| 132 recursive_operation_delegate_->RunRecursively(); |
| 144 } | 133 } |
| 145 | 134 |
| 146 void LocalFileSystemOperation::Move(const FileSystemURL& src_url, | 135 void LocalFileSystemOperation::Move(const FileSystemURL& src_url, |
| 147 const FileSystemURL& dest_url, | 136 const FileSystemURL& dest_url, |
| 148 const StatusCallback& callback) { | 137 const StatusCallback& callback) { |
| 149 DCHECK(SetPendingOperationType(kOperationMove)); | 138 DCHECK(SetPendingOperationType(kOperationMove)); |
| 150 is_cross_operation_ = (src_url.type() != dest_url.type()); | |
| 151 | 139 |
| 152 scoped_ptr<LocalFileSystemOperation> deleter(this); | 140 base::PlatformFileError result = SetUp( |
| 153 | 141 src_url, &file_util_, SETUP_FOR_WRITE); |
| 154 // Temporarily disables cross-filesystem move. | 142 if (result != base::PLATFORM_FILE_OK) { |
| 155 // TODO(kinuko,tzik,kinaba): This special handling must be removed once | 143 callback.Run(result); |
| 156 // we support saner cross-filesystem operation. | 144 delete this; |
| 157 // (See http://crbug.com/130055) | |
| 158 if (is_cross_operation_) { | |
| 159 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | |
| 160 return; | 145 return; |
| 161 } | 146 } |
| 162 | 147 |
| 163 base::PlatformFileError result = SetUp(src_url, &src_util_, SETUP_FOR_WRITE); | 148 DCHECK(!recursive_operation_delegate_); |
| 164 if (result == base::PLATFORM_FILE_OK) | 149 recursive_operation_delegate_.reset( |
| 165 result = SetUp(dest_url, &dest_util_, SETUP_FOR_CREATE); | 150 new CrossOperationDelegate(this, src_url, dest_url, |
| 166 if (result == base::PLATFORM_FILE_OK) { | 151 CrossOperationDelegate::OPERATION_MOVE, |
| 167 if (!IsCrossOperationAllowed(src_url.type(), dest_url.type())) | 152 callback)); |
| 168 result = base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | 153 recursive_operation_delegate_->RunRecursively(); |
| 169 } | |
| 170 if (result != base::PLATFORM_FILE_OK) { | |
| 171 callback.Run(result); | |
| 172 return; | |
| 173 } | |
| 174 | |
| 175 GetUsageAndQuotaThenRunTask( | |
| 176 dest_url, | |
| 177 base::Bind(&LocalFileSystemOperation::DoMove, | |
| 178 base::Unretained(deleter.release()), | |
| 179 src_url, dest_url, callback), | |
| 180 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | |
| 181 } | 154 } |
| 182 | 155 |
| 183 void LocalFileSystemOperation::DirectoryExists(const FileSystemURL& url, | 156 void LocalFileSystemOperation::DirectoryExists(const FileSystemURL& url, |
| 184 const StatusCallback& callback) { | 157 const StatusCallback& callback) { |
| 185 DCHECK(SetPendingOperationType(kOperationDirectoryExists)); | 158 DCHECK(SetPendingOperationType(kOperationDirectoryExists)); |
| 186 | 159 |
| 187 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_READ); | 160 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_READ); |
| 188 if (result != base::PLATFORM_FILE_OK) { | 161 if (result != base::PLATFORM_FILE_OK) { |
| 189 callback.Run(result); | 162 callback.Run(result); |
| 190 delete this; | 163 delete this; |
| 191 return; | 164 return; |
| 192 } | 165 } |
| 193 | 166 |
| 194 FileSystemFileUtilProxy::GetFileInfo( | 167 FileSystemFileUtilProxy::GetFileInfo( |
| 195 operation_context(), src_util_, url, | 168 operation_context(), file_util_, url, |
| 196 base::Bind(&LocalFileSystemOperation::DidDirectoryExists, | 169 base::Bind(&LocalFileSystemOperation::DidDirectoryExists, |
| 197 base::Owned(this), callback)); | 170 base::Owned(this), callback)); |
| 198 } | 171 } |
| 199 | 172 |
| 200 void LocalFileSystemOperation::FileExists(const FileSystemURL& url, | 173 void LocalFileSystemOperation::FileExists(const FileSystemURL& url, |
| 201 const StatusCallback& callback) { | 174 const StatusCallback& callback) { |
| 202 DCHECK(SetPendingOperationType(kOperationFileExists)); | 175 DCHECK(SetPendingOperationType(kOperationFileExists)); |
| 203 | 176 |
| 204 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_READ); | 177 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_READ); |
| 205 if (result != base::PLATFORM_FILE_OK) { | 178 if (result != base::PLATFORM_FILE_OK) { |
| 206 callback.Run(result); | 179 callback.Run(result); |
| 207 delete this; | 180 delete this; |
| 208 return; | 181 return; |
| 209 } | 182 } |
| 210 | 183 |
| 211 FileSystemFileUtilProxy::GetFileInfo( | 184 FileSystemFileUtilProxy::GetFileInfo( |
| 212 operation_context(), src_util_, url, | 185 operation_context(), file_util_, url, |
| 213 base::Bind(&LocalFileSystemOperation::DidFileExists, | 186 base::Bind(&LocalFileSystemOperation::DidFileExists, |
| 214 base::Owned(this), callback)); | 187 base::Owned(this), callback)); |
| 215 } | 188 } |
| 216 | 189 |
| 217 void LocalFileSystemOperation::GetMetadata( | 190 void LocalFileSystemOperation::GetMetadata( |
| 218 const FileSystemURL& url, const GetMetadataCallback& callback) { | 191 const FileSystemURL& url, const GetMetadataCallback& callback) { |
| 219 DCHECK(SetPendingOperationType(kOperationGetMetadata)); | 192 DCHECK(SetPendingOperationType(kOperationGetMetadata)); |
| 220 | 193 |
| 221 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_READ); | 194 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_READ); |
| 222 if (result != base::PLATFORM_FILE_OK) { | 195 if (result != base::PLATFORM_FILE_OK) { |
| 223 callback.Run(result, base::PlatformFileInfo(), FilePath()); | 196 callback.Run(result, base::PlatformFileInfo(), FilePath()); |
| 224 delete this; | 197 delete this; |
| 225 return; | 198 return; |
| 226 } | 199 } |
| 227 | 200 |
| 228 FileSystemFileUtilProxy::GetFileInfo( | 201 FileSystemFileUtilProxy::GetFileInfo( |
| 229 operation_context(), src_util_, url, | 202 operation_context(), file_util_, url, |
| 230 base::Bind(&LocalFileSystemOperation::DidGetMetadata, | 203 base::Bind(&LocalFileSystemOperation::DidGetMetadata, |
| 231 base::Owned(this), callback)); | 204 base::Owned(this), callback)); |
| 232 } | 205 } |
| 233 | 206 |
| 234 void LocalFileSystemOperation::ReadDirectory( | 207 void LocalFileSystemOperation::ReadDirectory( |
| 235 const FileSystemURL& url, const ReadDirectoryCallback& callback) { | 208 const FileSystemURL& url, const ReadDirectoryCallback& callback) { |
| 236 DCHECK(SetPendingOperationType(kOperationReadDirectory)); | 209 DCHECK(SetPendingOperationType(kOperationReadDirectory)); |
| 237 | 210 |
| 238 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_READ); | 211 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_READ); |
| 239 if (result != base::PLATFORM_FILE_OK) { | 212 if (result != base::PLATFORM_FILE_OK) { |
| 240 callback.Run(result, std::vector<base::FileUtilProxy::Entry>(), false); | 213 callback.Run(result, std::vector<base::FileUtilProxy::Entry>(), false); |
| 241 delete this; | 214 delete this; |
| 242 return; | 215 return; |
| 243 } | 216 } |
| 244 | 217 |
| 245 FileSystemFileUtilProxy::ReadDirectory( | 218 FileSystemFileUtilProxy::ReadDirectory( |
| 246 operation_context(), src_util_, url, | 219 operation_context(), file_util_, url, |
| 247 base::Bind(&LocalFileSystemOperation::DidReadDirectory, | 220 base::Bind(&LocalFileSystemOperation::DidReadDirectory, |
| 248 base::Owned(this), callback)); | 221 base::Owned(this), callback)); |
| 249 } | 222 } |
| 250 | 223 |
| 251 void LocalFileSystemOperation::Remove(const FileSystemURL& url, | 224 void LocalFileSystemOperation::Remove(const FileSystemURL& url, |
| 252 bool recursive, | 225 bool recursive, |
| 253 const StatusCallback& callback) { | 226 const StatusCallback& callback) { |
| 254 DCHECK(SetPendingOperationType(kOperationRemove)); | 227 DCHECK(SetPendingOperationType(kOperationRemove)); |
| 255 DCHECK(!remove_operation_delegate_); | 228 DCHECK(!recursive_operation_delegate_); |
| 256 remove_operation_delegate_.reset(new RemoveOperationDelegate(this, callback)); | 229 recursive_operation_delegate_.reset( |
| 230 new RemoveOperationDelegate(this, url, callback)); |
| 257 if (recursive) | 231 if (recursive) |
| 258 remove_operation_delegate_->RunRecursively(url); | 232 recursive_operation_delegate_->RunRecursively(); |
| 259 else | 233 else |
| 260 remove_operation_delegate_->Run(url); | 234 recursive_operation_delegate_->Run(); |
| 261 } | 235 } |
| 262 | 236 |
| 263 void LocalFileSystemOperation::Write( | 237 void LocalFileSystemOperation::Write( |
| 264 const net::URLRequestContext* url_request_context, | 238 const net::URLRequestContext* url_request_context, |
| 265 const FileSystemURL& url, | 239 const FileSystemURL& url, |
| 266 const GURL& blob_url, | 240 const GURL& blob_url, |
| 267 int64 offset, | 241 int64 offset, |
| 268 const WriteCallback& callback) { | 242 const WriteCallback& callback) { |
| 269 GetWriteClosure(url_request_context, url, blob_url, offset, callback).Run(); | 243 GetWriteClosure(url_request_context, url, blob_url, offset, callback).Run(); |
| 270 } | 244 } |
| 271 | 245 |
| 272 void LocalFileSystemOperation::Truncate(const FileSystemURL& url, int64 length, | 246 void LocalFileSystemOperation::Truncate(const FileSystemURL& url, int64 length, |
| 273 const StatusCallback& callback) { | 247 const StatusCallback& callback) { |
| 274 DCHECK(SetPendingOperationType(kOperationTruncate)); | 248 DCHECK(SetPendingOperationType(kOperationTruncate)); |
| 275 | 249 |
| 276 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_WRITE); | 250 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_WRITE); |
| 277 if (result != base::PLATFORM_FILE_OK) { | 251 if (result != base::PLATFORM_FILE_OK) { |
| 278 callback.Run(result); | 252 callback.Run(result); |
| 279 delete this; | 253 delete this; |
| 280 return; | 254 return; |
| 281 } | 255 } |
| 282 GetUsageAndQuotaThenRunTask( | 256 GetUsageAndQuotaThenRunTask( |
| 283 url, | 257 url, |
| 284 base::Bind(&LocalFileSystemOperation::DoTruncate, | 258 base::Bind(&LocalFileSystemOperation::DoTruncate, |
| 285 base::Unretained(this), url, callback, length), | 259 base::Unretained(this), url, callback, length), |
| 286 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 260 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
| 287 } | 261 } |
| 288 | 262 |
| 289 void LocalFileSystemOperation::TouchFile(const FileSystemURL& url, | 263 void LocalFileSystemOperation::TouchFile(const FileSystemURL& url, |
| 290 const base::Time& last_access_time, | 264 const base::Time& last_access_time, |
| 291 const base::Time& last_modified_time, | 265 const base::Time& last_modified_time, |
| 292 const StatusCallback& callback) { | 266 const StatusCallback& callback) { |
| 293 DCHECK(SetPendingOperationType(kOperationTouchFile)); | 267 DCHECK(SetPendingOperationType(kOperationTouchFile)); |
| 294 | 268 |
| 295 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_WRITE); | 269 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_WRITE); |
| 296 if (result != base::PLATFORM_FILE_OK) { | 270 if (result != base::PLATFORM_FILE_OK) { |
| 297 callback.Run(result); | 271 callback.Run(result); |
| 298 delete this; | 272 delete this; |
| 299 return; | 273 return; |
| 300 } | 274 } |
| 301 | 275 |
| 302 FileSystemFileUtilProxy::Touch( | 276 FileSystemFileUtilProxy::Touch( |
| 303 operation_context(), src_util_, url, | 277 operation_context(), file_util_, url, |
| 304 last_access_time, last_modified_time, | 278 last_access_time, last_modified_time, |
| 305 base::Bind(&LocalFileSystemOperation::DidTouchFile, | 279 base::Bind(&LocalFileSystemOperation::DidTouchFile, |
| 306 base::Owned(this), callback)); | 280 base::Owned(this), callback)); |
| 307 } | 281 } |
| 308 | 282 |
| 309 void LocalFileSystemOperation::OpenFile(const FileSystemURL& url, | 283 void LocalFileSystemOperation::OpenFile(const FileSystemURL& url, |
| 310 int file_flags, | 284 int file_flags, |
| 311 base::ProcessHandle peer_handle, | 285 base::ProcessHandle peer_handle, |
| 312 const OpenFileCallback& callback) { | 286 const OpenFileCallback& callback) { |
| 313 DCHECK(SetPendingOperationType(kOperationOpenFile)); | 287 DCHECK(SetPendingOperationType(kOperationOpenFile)); |
| 314 scoped_ptr<LocalFileSystemOperation> deleter(this); | 288 scoped_ptr<LocalFileSystemOperation> deleter(this); |
| 315 | 289 |
| 316 peer_handle_ = peer_handle; | 290 peer_handle_ = peer_handle; |
| 317 | 291 |
| 318 if (file_flags & ( | 292 if (file_flags & ( |
| 319 (base::PLATFORM_FILE_ENUMERATE | base::PLATFORM_FILE_TEMPORARY | | 293 (base::PLATFORM_FILE_ENUMERATE | base::PLATFORM_FILE_TEMPORARY | |
| 320 base::PLATFORM_FILE_HIDDEN))) { | 294 base::PLATFORM_FILE_HIDDEN))) { |
| 321 callback.Run(base::PLATFORM_FILE_ERROR_FAILED, | 295 callback.Run(base::PLATFORM_FILE_ERROR_FAILED, |
| 322 base::PlatformFile(), base::ProcessHandle()); | 296 base::PlatformFile(), base::ProcessHandle()); |
| 323 return; | 297 return; |
| 324 } | 298 } |
| 325 if (file_flags & | 299 if (file_flags & |
| 326 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS | | 300 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS | |
| 327 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED | | 301 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED | |
| 328 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | | 302 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | |
| 329 base::PLATFORM_FILE_DELETE_ON_CLOSE | | 303 base::PLATFORM_FILE_DELETE_ON_CLOSE | |
| 330 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) { | 304 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) { |
| 331 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_CREATE); | 305 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_CREATE); |
| 332 if (result != base::PLATFORM_FILE_OK) { | 306 if (result != base::PLATFORM_FILE_OK) { |
| 333 callback.Run(result, base::PlatformFile(), base::ProcessHandle()); | 307 callback.Run(result, base::PlatformFile(), base::ProcessHandle()); |
| 334 return; | 308 return; |
| 335 } | 309 } |
| 336 } else { | 310 } else { |
| 337 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_READ); | 311 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_READ); |
| 338 if (result != base::PLATFORM_FILE_OK) { | 312 if (result != base::PLATFORM_FILE_OK) { |
| 339 callback.Run(result, base::PlatformFile(), base::ProcessHandle()); | 313 callback.Run(result, base::PlatformFile(), base::ProcessHandle()); |
| 340 return; | 314 return; |
| 341 } | 315 } |
| 342 } | 316 } |
| 343 GetUsageAndQuotaThenRunTask( | 317 GetUsageAndQuotaThenRunTask( |
| 344 url, | 318 url, |
| 345 base::Bind(&LocalFileSystemOperation::DoOpenFile, | 319 base::Bind(&LocalFileSystemOperation::DoOpenFile, |
| 346 base::Unretained(deleter.release()), | 320 base::Unretained(deleter.release()), |
| 347 url, callback, file_flags), | 321 url, callback, file_flags), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 365 |
| 392 LocalFileSystemOperation* | 366 LocalFileSystemOperation* |
| 393 LocalFileSystemOperation::AsLocalFileSystemOperation() { | 367 LocalFileSystemOperation::AsLocalFileSystemOperation() { |
| 394 return this; | 368 return this; |
| 395 } | 369 } |
| 396 | 370 |
| 397 void LocalFileSystemOperation::SyncGetPlatformPath(const FileSystemURL& url, | 371 void LocalFileSystemOperation::SyncGetPlatformPath(const FileSystemURL& url, |
| 398 FilePath* platform_path) { | 372 FilePath* platform_path) { |
| 399 DCHECK(SetPendingOperationType(kOperationGetLocalPath)); | 373 DCHECK(SetPendingOperationType(kOperationGetLocalPath)); |
| 400 | 374 |
| 401 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_READ); | 375 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_READ); |
| 402 if (result != base::PLATFORM_FILE_OK) { | 376 if (result != base::PLATFORM_FILE_OK) { |
| 403 delete this; | 377 delete this; |
| 404 return; | 378 return; |
| 405 } | 379 } |
| 406 | 380 |
| 407 src_util_->GetLocalFilePath(operation_context(), url, platform_path); | 381 file_util_->GetLocalFilePath(operation_context(), url, platform_path); |
| 408 | 382 |
| 409 delete this; | 383 delete this; |
| 410 } | 384 } |
| 411 | 385 |
| 412 void LocalFileSystemOperation::CreateSnapshotFile( | 386 void LocalFileSystemOperation::CreateSnapshotFile( |
| 413 const FileSystemURL& url, | 387 const FileSystemURL& url, |
| 414 const SnapshotFileCallback& callback) { | 388 const SnapshotFileCallback& callback) { |
| 415 DCHECK(SetPendingOperationType(kOperationCreateSnapshotFile)); | 389 DCHECK(SetPendingOperationType(kOperationCreateSnapshotFile)); |
| 416 | 390 |
| 417 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_READ); | 391 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_READ); |
| 418 if (result != base::PLATFORM_FILE_OK) { | 392 if (result != base::PLATFORM_FILE_OK) { |
| 419 callback.Run(result, base::PlatformFileInfo(), FilePath(), NULL); | 393 callback.Run(result, base::PlatformFileInfo(), FilePath(), NULL); |
| 420 delete this; | 394 delete this; |
| 421 return; | 395 return; |
| 422 } | 396 } |
| 423 | 397 |
| 424 FileSystemFileUtilProxy::CreateSnapshotFile( | 398 FileSystemFileUtilProxy::CreateSnapshotFile( |
| 425 operation_context(), src_util_, url, | 399 operation_context(), file_util_, url, |
| 426 base::Bind(&LocalFileSystemOperation::DidCreateSnapshotFile, | 400 base::Bind(&LocalFileSystemOperation::DidCreateSnapshotFile, |
| 427 base::Owned(this), callback)); | 401 base::Owned(this), callback)); |
| 428 } | 402 } |
| 429 | 403 |
| 430 void LocalFileSystemOperation::CopyInForeignFile( | 404 void LocalFileSystemOperation::CopyInForeignFile( |
| 431 const FilePath& src_local_disk_file_path, | 405 const FilePath& src_local_disk_file_path, |
| 432 const FileSystemURL& dest_url, | 406 const FileSystemURL& dest_url, |
| 433 const StatusCallback& callback) { | 407 const StatusCallback& callback) { |
| 434 DCHECK(SetPendingOperationType(kOperationCopyInForeignFile)); | 408 DCHECK(SetPendingOperationType(kOperationCopyInForeignFile)); |
| 435 | 409 |
| 436 base::PlatformFileError result = SetUp( | 410 base::PlatformFileError result = SetUp( |
| 437 dest_url, &dest_util_, SETUP_FOR_CREATE); | 411 dest_url, &file_util_, SETUP_FOR_CREATE); |
| 438 if (result != base::PLATFORM_FILE_OK) { | 412 if (result != base::PLATFORM_FILE_OK) { |
| 439 callback.Run(result); | 413 callback.Run(result); |
| 440 delete this; | 414 delete this; |
| 441 return; | 415 return; |
| 442 } | 416 } |
| 443 | 417 |
| 444 GetUsageAndQuotaThenRunTask( | 418 GetUsageAndQuotaThenRunTask( |
| 445 dest_url, | 419 dest_url, |
| 446 base::Bind(&LocalFileSystemOperation::DoCopyInForeignFile, | 420 base::Bind(&LocalFileSystemOperation::DoCopyInForeignFile, |
| 447 base::Unretained(this), src_local_disk_file_path, dest_url, | 421 base::Unretained(this), src_local_disk_file_path, dest_url, |
| 448 callback), | 422 callback), |
| 449 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); | 423 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
| 450 } | 424 } |
| 451 | 425 |
| 452 void LocalFileSystemOperation::RemoveFile( | 426 void LocalFileSystemOperation::RemoveFile( |
| 453 const FileSystemURL& url, | 427 const FileSystemURL& url, |
| 454 const StatusCallback& callback) { | 428 const StatusCallback& callback) { |
| 455 DCHECK(SetPendingOperationType(kOperationRemove)); | 429 DCHECK(SetPendingOperationType(kOperationRemove)); |
| 456 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_WRITE); | 430 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_WRITE); |
| 457 if (result != base::PLATFORM_FILE_OK) { | 431 if (result != base::PLATFORM_FILE_OK) { |
| 458 callback.Run(result); | 432 callback.Run(result); |
| 459 delete this; | 433 delete this; |
| 460 return; | 434 return; |
| 461 } | 435 } |
| 462 | 436 |
| 463 FileSystemFileUtilProxy::DeleteFile( | 437 FileSystemFileUtilProxy::DeleteFile( |
| 464 operation_context(), src_util_, url, | 438 operation_context(), file_util_, url, |
| 465 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, | 439 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, |
| 466 base::Owned(this), callback)); | 440 base::Owned(this), callback)); |
| 467 } | 441 } |
| 468 | 442 |
| 469 void LocalFileSystemOperation::RemoveDirectory( | 443 void LocalFileSystemOperation::RemoveDirectory( |
| 470 const FileSystemURL& url, | 444 const FileSystemURL& url, |
| 471 const StatusCallback& callback) { | 445 const StatusCallback& callback) { |
| 472 DCHECK(SetPendingOperationType(kOperationRemove)); | 446 DCHECK(SetPendingOperationType(kOperationRemove)); |
| 473 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_WRITE); | 447 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_WRITE); |
| 474 if (result != base::PLATFORM_FILE_OK) { | 448 if (result != base::PLATFORM_FILE_OK) { |
| 475 callback.Run(result); | 449 callback.Run(result); |
| 476 delete this; | 450 delete this; |
| 477 return; | 451 return; |
| 478 } | 452 } |
| 479 | 453 |
| 480 FileSystemFileUtilProxy::DeleteDirectory( | 454 FileSystemFileUtilProxy::DeleteDirectory( |
| 481 operation_context(), src_util_, url, | 455 operation_context(), file_util_, url, |
| 482 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, | 456 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, |
| 483 base::Owned(this), callback)); | 457 base::Owned(this), callback)); |
| 484 } | 458 } |
| 485 | 459 |
| 460 void LocalFileSystemOperation::CopyFileLocal( |
| 461 const FileSystemURL& src_url, |
| 462 const FileSystemURL& dest_url, |
| 463 const StatusCallback& callback) { |
| 464 DCHECK(SetPendingOperationType(kOperationCopy)); |
| 465 DCHECK_EQ(src_url.origin(), dest_url.origin()); |
| 466 DCHECK_EQ(src_url.type(), dest_url.type()); |
| 467 |
| 468 base::PlatformFileError result = SetUp(src_url, &file_util_, SETUP_FOR_READ); |
| 469 if (result == base::PLATFORM_FILE_OK) |
| 470 result = SetUp(dest_url, &file_util_, SETUP_FOR_CREATE); |
| 471 if (result != base::PLATFORM_FILE_OK) { |
| 472 callback.Run(result); |
| 473 delete this; |
| 474 return; |
| 475 } |
| 476 |
| 477 // Record read access for src_url. |
| 478 operation_context()->access_observers()->Notify( |
| 479 &FileAccessObserver::OnAccess, MakeTuple(src_url)); |
| 480 // Record update access for dest_url. |
| 481 scoped_update_notifiers_.push_back(new ScopedUpdateNotifier( |
| 482 operation_context(), dest_url)); |
| 483 |
| 484 GetUsageAndQuotaThenRunTask( |
| 485 dest_url, |
| 486 base::Bind(&LocalFileSystemOperation::DoCopyFileLocal, |
| 487 base::Unretained(this), src_url, dest_url, callback), |
| 488 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
| 489 } |
| 490 |
| 491 void LocalFileSystemOperation::MoveFileLocal( |
| 492 const FileSystemURL& src_url, |
| 493 const FileSystemURL& dest_url, |
| 494 const StatusCallback& callback) { |
| 495 DCHECK(SetPendingOperationType(kOperationMove)); |
| 496 DCHECK_EQ(src_url.origin(), dest_url.origin()); |
| 497 DCHECK_EQ(src_url.type(), dest_url.type()); |
| 498 |
| 499 base::PlatformFileError result = SetUp(src_url, &file_util_, SETUP_FOR_WRITE); |
| 500 if (result == base::PLATFORM_FILE_OK) |
| 501 result = SetUp(dest_url, &file_util_, SETUP_FOR_CREATE); |
| 502 if (result != base::PLATFORM_FILE_OK) { |
| 503 callback.Run(result); |
| 504 delete this; |
| 505 return; |
| 506 } |
| 507 |
| 508 // Record update access for dest_url. |
| 509 scoped_update_notifiers_.push_back(new ScopedUpdateNotifier( |
| 510 operation_context(), dest_url)); |
| 511 |
| 512 GetUsageAndQuotaThenRunTask( |
| 513 dest_url, |
| 514 base::Bind(&LocalFileSystemOperation::DoMoveFileLocal, |
| 515 base::Unretained(this), src_url, dest_url, callback), |
| 516 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); |
| 517 } |
| 518 |
| 486 LocalFileSystemOperation::LocalFileSystemOperation( | 519 LocalFileSystemOperation::LocalFileSystemOperation( |
| 487 FileSystemContext* file_system_context, | 520 FileSystemContext* file_system_context, |
| 488 scoped_ptr<FileSystemOperationContext> operation_context) | 521 scoped_ptr<FileSystemOperationContext> operation_context) |
| 489 : file_system_context_(file_system_context), | 522 : file_system_context_(file_system_context), |
| 490 operation_context_(operation_context.Pass()), | 523 operation_context_(operation_context.Pass()), |
| 491 src_util_(NULL), | 524 file_util_(NULL), |
| 492 dest_util_(NULL), | |
| 493 overriding_operation_context_(NULL), | 525 overriding_operation_context_(NULL), |
| 494 is_cross_operation_(false), | |
| 495 peer_handle_(base::kNullProcessHandle), | 526 peer_handle_(base::kNullProcessHandle), |
| 496 pending_operation_(kOperationNone), | 527 pending_operation_(kOperationNone), |
| 497 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 528 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 498 DCHECK(operation_context_.get()); | 529 DCHECK(operation_context_.get()); |
| 499 } | 530 } |
| 500 | 531 |
| 501 void LocalFileSystemOperation::GetUsageAndQuotaThenRunTask( | 532 void LocalFileSystemOperation::GetUsageAndQuotaThenRunTask( |
| 502 const FileSystemURL& url, | 533 const FileSystemURL& url, |
| 503 const base::Closure& task, | 534 const base::Closure& task, |
| 504 const base::Closure& error_callback) { | 535 const base::Closure& error_callback) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 569 } |
| 539 | 570 |
| 540 base::Closure LocalFileSystemOperation::GetWriteClosure( | 571 base::Closure LocalFileSystemOperation::GetWriteClosure( |
| 541 const net::URLRequestContext* url_request_context, | 572 const net::URLRequestContext* url_request_context, |
| 542 const FileSystemURL& url, | 573 const FileSystemURL& url, |
| 543 const GURL& blob_url, | 574 const GURL& blob_url, |
| 544 int64 offset, | 575 int64 offset, |
| 545 const WriteCallback& callback) { | 576 const WriteCallback& callback) { |
| 546 DCHECK(SetPendingOperationType(kOperationWrite)); | 577 DCHECK(SetPendingOperationType(kOperationWrite)); |
| 547 | 578 |
| 548 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_WRITE); | 579 base::PlatformFileError result = SetUp(url, &file_util_, SETUP_FOR_WRITE); |
| 549 if (result != base::PLATFORM_FILE_OK) { | 580 if (result != base::PLATFORM_FILE_OK) { |
| 550 return base::Bind(&LocalFileSystemOperation::DidFailWrite, | 581 return base::Bind(&LocalFileSystemOperation::DidFailWrite, |
| 551 base::Owned(this), callback, result); | 582 base::Owned(this), callback, result); |
| 552 } | 583 } |
| 553 | 584 |
| 554 FileSystemMountPointProvider* provider = file_system_context()-> | 585 FileSystemMountPointProvider* provider = file_system_context()-> |
| 555 GetMountPointProvider(url.type()); | 586 GetMountPointProvider(url.type()); |
| 556 DCHECK(provider); | 587 DCHECK(provider); |
| 557 scoped_ptr<FileStreamWriter> writer(provider->CreateFileStreamWriter( | 588 scoped_ptr<FileStreamWriter> writer(provider->CreateFileStreamWriter( |
| 558 url, offset, file_system_context())); | 589 url, offset, file_system_context())); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 584 base::PlatformFileError result) { | 615 base::PlatformFileError result) { |
| 585 callback.Run(result, 0, false); | 616 callback.Run(result, 0, false); |
| 586 } | 617 } |
| 587 | 618 |
| 588 void LocalFileSystemOperation::DoCreateFile( | 619 void LocalFileSystemOperation::DoCreateFile( |
| 589 const FileSystemURL& url, | 620 const FileSystemURL& url, |
| 590 const StatusCallback& callback, | 621 const StatusCallback& callback, |
| 591 bool exclusive) { | 622 bool exclusive) { |
| 592 FileSystemFileUtilProxy::EnsureFileExists( | 623 FileSystemFileUtilProxy::EnsureFileExists( |
| 593 operation_context(), | 624 operation_context(), |
| 594 src_util_, url, | 625 file_util_, url, |
| 595 base::Bind( | 626 base::Bind( |
| 596 exclusive ? | 627 exclusive ? |
| 597 &LocalFileSystemOperation::DidEnsureFileExistsExclusive : | 628 &LocalFileSystemOperation::DidEnsureFileExistsExclusive : |
| 598 &LocalFileSystemOperation::DidEnsureFileExistsNonExclusive, | 629 &LocalFileSystemOperation::DidEnsureFileExistsNonExclusive, |
| 599 base::Owned(this), callback)); | 630 base::Owned(this), callback)); |
| 600 } | 631 } |
| 601 | 632 |
| 602 void LocalFileSystemOperation::DoCreateDirectory( | 633 void LocalFileSystemOperation::DoCreateDirectory( |
| 603 const FileSystemURL& url, | 634 const FileSystemURL& url, |
| 604 const StatusCallback& callback, | 635 const StatusCallback& callback, |
| 605 bool exclusive, bool recursive) { | 636 bool exclusive, bool recursive) { |
| 606 FileSystemFileUtilProxy::CreateDirectory( | 637 FileSystemFileUtilProxy::CreateDirectory( |
| 607 operation_context(), | 638 operation_context(), |
| 608 src_util_, url, exclusive, recursive, | 639 file_util_, url, exclusive, recursive, |
| 609 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, | 640 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, |
| 610 base::Owned(this), callback)); | 641 base::Owned(this), callback)); |
| 611 } | 642 } |
| 612 | 643 |
| 613 void LocalFileSystemOperation::DoCopy(const FileSystemURL& src_url, | 644 void LocalFileSystemOperation::DoCopyFileLocal( |
| 614 const FileSystemURL& dest_url, | 645 const FileSystemURL& src_url, |
| 615 const StatusCallback& callback) { | 646 const FileSystemURL& dest_url, |
| 616 FileSystemFileUtilProxy::Copy( | 647 const StatusCallback& callback) { |
| 648 FileSystemFileUtilProxy::CopyFileLocal( |
| 617 operation_context(), | 649 operation_context(), |
| 618 src_util_, dest_util_, | 650 file_util_, src_url, dest_url, |
| 619 src_url, dest_url, | 651 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, |
| 652 base::Owned(this), callback)); |
| 653 } |
| 654 |
| 655 void LocalFileSystemOperation::DoMoveFileLocal( |
| 656 const FileSystemURL& src_url, |
| 657 const FileSystemURL& dest_url, |
| 658 const StatusCallback& callback) { |
| 659 FileSystemFileUtilProxy::MoveFileLocal( |
| 660 operation_context(), |
| 661 file_util_, src_url, dest_url, |
| 620 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, | 662 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, |
| 621 base::Owned(this), callback)); | 663 base::Owned(this), callback)); |
| 622 } | 664 } |
| 623 | 665 |
| 624 void LocalFileSystemOperation::DoCopyInForeignFile( | 666 void LocalFileSystemOperation::DoCopyInForeignFile( |
| 625 const FilePath& src_local_disk_file_path, | 667 const FilePath& src_local_disk_file_path, |
| 626 const FileSystemURL& dest_url, | 668 const FileSystemURL& dest_url, |
| 627 const StatusCallback& callback) { | 669 const StatusCallback& callback) { |
| 628 FileSystemFileUtilProxy::CopyInForeignFile( | 670 FileSystemFileUtilProxy::CopyInForeignFile( |
| 629 operation_context(), | 671 operation_context(), |
| 630 dest_util_, | 672 file_util_, src_local_disk_file_path, dest_url, |
| 631 src_local_disk_file_path, dest_url, | |
| 632 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, | 673 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, |
| 633 base::Owned(this), callback)); | 674 base::Owned(this), callback)); |
| 634 } | 675 } |
| 635 | |
| 636 void LocalFileSystemOperation::DoMove(const FileSystemURL& src_url, | |
| 637 const FileSystemURL& dest_url, | |
| 638 const StatusCallback& callback) { | |
| 639 FileSystemFileUtilProxy::Move( | |
| 640 operation_context(), | |
| 641 src_util_, dest_util_, | |
| 642 src_url, dest_url, | |
| 643 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, | |
| 644 base::Owned(this), callback)); | |
| 645 } | |
| 646 | 676 |
| 647 void LocalFileSystemOperation::DoTruncate(const FileSystemURL& url, | 677 void LocalFileSystemOperation::DoTruncate(const FileSystemURL& url, |
| 648 const StatusCallback& callback, | 678 const StatusCallback& callback, |
| 649 int64 length) { | 679 int64 length) { |
| 650 FileSystemFileUtilProxy::Truncate( | 680 FileSystemFileUtilProxy::Truncate( |
| 651 operation_context(), src_util_, url, length, | 681 operation_context(), file_util_, url, length, |
| 652 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, | 682 base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, |
| 653 base::Owned(this), callback)); | 683 base::Owned(this), callback)); |
| 654 } | 684 } |
| 655 | 685 |
| 656 void LocalFileSystemOperation::DoOpenFile(const FileSystemURL& url, | 686 void LocalFileSystemOperation::DoOpenFile(const FileSystemURL& url, |
| 657 const OpenFileCallback& callback, | 687 const OpenFileCallback& callback, |
| 658 int file_flags) { | 688 int file_flags) { |
| 659 FileSystemFileUtilProxy::CreateOrOpen( | 689 FileSystemFileUtilProxy::CreateOrOpen( |
| 660 operation_context(), src_util_, url, file_flags, | 690 operation_context(), file_util_, url, file_flags, |
| 661 base::Bind(&LocalFileSystemOperation::DidOpenFile, | 691 base::Bind(&LocalFileSystemOperation::DidOpenFile, |
| 662 base::Owned(this), callback)); | 692 base::Owned(this), callback)); |
| 663 } | 693 } |
| 664 | 694 |
| 665 void LocalFileSystemOperation::DidEnsureFileExistsExclusive( | 695 void LocalFileSystemOperation::DidEnsureFileExistsExclusive( |
| 666 const StatusCallback& callback, | 696 const StatusCallback& callback, |
| 667 base::PlatformFileError rv, bool created) { | 697 base::PlatformFileError rv, bool created) { |
| 668 if (rv == base::PLATFORM_FILE_OK && !created) { | 698 if (rv == base::PLATFORM_FILE_OK && !created) { |
| 669 callback.Run(base::PLATFORM_FILE_ERROR_EXISTS); | 699 callback.Run(base::PLATFORM_FILE_ERROR_EXISTS); |
| 670 } else { | 700 } else { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 // operation context is overridden from another operation) we skip | 835 // operation context is overridden from another operation) we skip |
| 806 // some duplicated security checks. | 836 // some duplicated security checks. |
| 807 if (overriding_operation_context_) | 837 if (overriding_operation_context_) |
| 808 return base::PLATFORM_FILE_OK; | 838 return base::PLATFORM_FILE_OK; |
| 809 | 839 |
| 810 if (!file_system_context()->GetMountPointProvider( | 840 if (!file_system_context()->GetMountPointProvider( |
| 811 url.type())->IsAccessAllowed(url)) | 841 url.type())->IsAccessAllowed(url)) |
| 812 return base::PLATFORM_FILE_ERROR_SECURITY; | 842 return base::PLATFORM_FILE_ERROR_SECURITY; |
| 813 | 843 |
| 814 if (mode == SETUP_FOR_READ) { | 844 if (mode == SETUP_FOR_READ) { |
| 815 // TODO(kinuko): This doesn't work well for cross-filesystem operation | 845 operation_context()->access_observers()->Notify( |
| 816 // in the current architecture since the operation context (thus the | 846 &FileAccessObserver::OnAccess, MakeTuple(url)); |
| 817 // observers) is configured for the destination URL while this method | |
| 818 // could be called for both src and dest URL. | |
| 819 if (!is_cross_operation_) { | |
| 820 operation_context()->access_observers()->Notify( | |
| 821 &FileAccessObserver::OnAccess, MakeTuple(url)); | |
| 822 } | |
| 823 return base::PLATFORM_FILE_OK; | 847 return base::PLATFORM_FILE_OK; |
| 824 } | 848 } |
| 825 | 849 |
| 826 DCHECK(mode == SETUP_FOR_WRITE || mode == SETUP_FOR_CREATE); | 850 DCHECK(mode == SETUP_FOR_WRITE || mode == SETUP_FOR_CREATE); |
| 827 | 851 |
| 828 scoped_update_notifiers_.push_back(new ScopedUpdateNotifier( | 852 scoped_update_notifiers_.push_back(new ScopedUpdateNotifier( |
| 829 operation_context(), url)); | 853 operation_context(), url)); |
| 830 | 854 |
| 831 // Any write access is disallowed on the root path. | 855 // Any write access is disallowed on the root path. |
| 832 if (url.path().value().length() == 0 || | 856 if (url.path().value().length() == 0 || |
| (...skipping 13 matching lines...) Expand all Loading... |
| 846 } | 870 } |
| 847 | 871 |
| 848 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { | 872 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { |
| 849 if (pending_operation_ != kOperationNone) | 873 if (pending_operation_ != kOperationNone) |
| 850 return false; | 874 return false; |
| 851 pending_operation_ = type; | 875 pending_operation_ = type; |
| 852 return true; | 876 return true; |
| 853 } | 877 } |
| 854 | 878 |
| 855 } // namespace fileapi | 879 } // namespace fileapi |
| OLD | NEW |