Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: webkit/browser/fileapi/file_system_operation_impl.cc

Issue 23135019: Make SyncableFileSystemOperation not inherit from FileSystemOperationImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/fileapi/file_system_operation_impl.h" 5 #include "webkit/browser/fileapi/file_system_operation_impl.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/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 DCHECK_EQ(kOperationWrite, pending_operation_); 230 DCHECK_EQ(kOperationWrite, pending_operation_);
231 // This will call DidWrite() with ABORT status code. 231 // This will call DidWrite() with ABORT status code.
232 file_writer_delegate_->Cancel(); 232 file_writer_delegate_->Cancel();
233 } else { 233 } else {
234 // For truncate we have no way to cancel the inflight operation (for now). 234 // For truncate we have no way to cancel the inflight operation (for now).
235 // Let it just run and dispatch cancel callback later. 235 // Let it just run and dispatch cancel callback later.
236 DCHECK_EQ(kOperationTruncate, pending_operation_); 236 DCHECK_EQ(kOperationTruncate, pending_operation_);
237 } 237 }
238 } 238 }
239 239
240 FileSystemOperationImpl* FileSystemOperationImpl::AsFileSystemOperationImpl() {
241 return this;
242 }
243
244 base::PlatformFileError FileSystemOperationImpl::SyncGetPlatformPath(
245 const FileSystemURL& url,
246 base::FilePath* platform_path) {
247 DCHECK(SetPendingOperationType(kOperationGetLocalPath));
248 FileSystemFileUtil* file_util = file_system_context()->GetFileUtil(
249 url.type());
250 if (!file_util)
251 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
252 file_util->GetLocalFilePath(operation_context_.get(), url, platform_path);
253 return base::PLATFORM_FILE_OK;
254 }
255
256 void FileSystemOperationImpl::CreateSnapshotFile( 240 void FileSystemOperationImpl::CreateSnapshotFile(
257 const FileSystemURL& url, 241 const FileSystemURL& url,
258 const SnapshotFileCallback& callback) { 242 const SnapshotFileCallback& callback) {
259 DCHECK(SetPendingOperationType(kOperationCreateSnapshotFile)); 243 DCHECK(SetPendingOperationType(kOperationCreateSnapshotFile));
260 async_file_util_->CreateSnapshotFile( 244 async_file_util_->CreateSnapshotFile(
261 operation_context_.Pass(), url, callback); 245 operation_context_.Pass(), url, callback);
262 } 246 }
263 247
264 void FileSystemOperationImpl::CopyInForeignFile( 248 void FileSystemOperationImpl::CopyInForeignFile(
265 const base::FilePath& src_local_disk_file_path, 249 const base::FilePath& src_local_disk_file_path,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 const StatusCallback& callback) { 297 const StatusCallback& callback) {
314 DCHECK(SetPendingOperationType(kOperationMove)); 298 DCHECK(SetPendingOperationType(kOperationMove));
315 DCHECK(src_url.IsInSameFileSystem(dest_url)); 299 DCHECK(src_url.IsInSameFileSystem(dest_url));
316 GetUsageAndQuotaThenRunTask( 300 GetUsageAndQuotaThenRunTask(
317 dest_url, 301 dest_url,
318 base::Bind(&FileSystemOperationImpl::DoMoveFileLocal, 302 base::Bind(&FileSystemOperationImpl::DoMoveFileLocal,
319 AsWeakPtr(), src_url, dest_url, callback), 303 AsWeakPtr(), src_url, dest_url, callback),
320 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED)); 304 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED));
321 } 305 }
322 306
307 base::PlatformFileError FileSystemOperationImpl::SyncGetPlatformPath(
308 const FileSystemURL& url,
309 base::FilePath* platform_path) {
310 DCHECK(SetPendingOperationType(kOperationGetLocalPath));
311 FileSystemFileUtil* file_util = file_system_context()->GetFileUtil(
312 url.type());
313 if (!file_util)
314 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
315 file_util->GetLocalFilePath(operation_context_.get(), url, platform_path);
316 return base::PLATFORM_FILE_OK;
317 }
318
323 void FileSystemOperationImpl::GetUsageAndQuotaThenRunTask( 319 void FileSystemOperationImpl::GetUsageAndQuotaThenRunTask(
324 const FileSystemURL& url, 320 const FileSystemURL& url,
325 const base::Closure& task, 321 const base::Closure& task,
326 const base::Closure& error_callback) { 322 const base::Closure& error_callback) {
327 quota::QuotaManagerProxy* quota_manager_proxy = 323 quota::QuotaManagerProxy* quota_manager_proxy =
328 file_system_context()->quota_manager_proxy(); 324 file_system_context()->quota_manager_proxy();
329 if (!quota_manager_proxy || 325 if (!quota_manager_proxy ||
330 !file_system_context()->GetQuotaUtil(url.type())) { 326 !file_system_context()->GetQuotaUtil(url.type())) {
331 // If we don't have the quota manager or the requested filesystem type 327 // If we don't have the quota manager or the requested filesystem type
332 // does not support quota, we should be able to let it go. 328 // does not support quota, we should be able to let it go.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 526 }
531 527
532 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { 528 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) {
533 if (pending_operation_ != kOperationNone) 529 if (pending_operation_ != kOperationNone)
534 return false; 530 return false;
535 pending_operation_ = type; 531 pending_operation_ = type;
536 return true; 532 return true;
537 } 533 }
538 534
539 } // namespace fileapi 535 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_system_operation_impl.h ('k') | webkit/browser/fileapi/file_system_operation_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698