| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/async_file_util_adapter.h" | 5 #include "webkit/browser/fileapi/async_file_util_adapter.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "base/task_runner_util.h" | 11 #include "base/task_runner_util.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "webkit/browser/fileapi/file_system_context.h" | 13 #include "webkit/browser/fileapi/file_system_context.h" |
| 14 #include "webkit/browser/fileapi/file_system_file_util.h" | 14 #include "webkit/browser/fileapi/file_system_file_util.h" |
| 15 #include "webkit/browser/fileapi/file_system_operation_context.h" | 15 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 16 #include "webkit/browser/fileapi/file_system_url.h" | 16 #include "webkit/browser/fileapi/file_system_url.h" |
| 17 #include "webkit/common/blob/shareable_file_reference.h" | 17 #include "webkit/common/blob/shareable_file_reference.h" |
| 18 #include "webkit/common/fileapi/file_system_util.h" | 18 #include "webkit/common/fileapi/file_system_util.h" |
| 19 | 19 |
| 20 using base::Bind; | 20 using base::Bind; |
| 21 using base::Callback; | 21 using base::Callback; |
| 22 using base::Owned; | 22 using base::Owned; |
| 23 using base::Unretained; | 23 using base::Unretained; |
| 24 using webkit_blob::ShareableFileReference; | 24 using storage::ShareableFileReference; |
| 25 | 25 |
| 26 namespace fileapi { | 26 namespace storage { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class EnsureFileExistsHelper { | 30 class EnsureFileExistsHelper { |
| 31 public: | 31 public: |
| 32 EnsureFileExistsHelper() : error_(base::File::FILE_OK), created_(false) {} | 32 EnsureFileExistsHelper() : error_(base::File::FILE_OK), created_(false) {} |
| 33 | 33 |
| 34 void RunWork(FileSystemFileUtil* file_util, | 34 void RunWork(FileSystemFileUtil* file_util, |
| 35 FileSystemOperationContext* context, | 35 FileSystemOperationContext* context, |
| 36 const FileSystemURL& url) { | 36 const FileSystemURL& url) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 void ReplySnapshotFile( | 72 void ReplySnapshotFile( |
| 73 const AsyncFileUtil::CreateSnapshotFileCallback& callback) { | 73 const AsyncFileUtil::CreateSnapshotFileCallback& callback) { |
| 74 callback.Run(error_, file_info_, platform_path_, | 74 callback.Run(error_, file_info_, platform_path_, |
| 75 ShareableFileReference::GetOrCreate(scoped_file_.Pass())); | 75 ShareableFileReference::GetOrCreate(scoped_file_.Pass())); |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 base::File::Error error_; | 79 base::File::Error error_; |
| 80 base::File::Info file_info_; | 80 base::File::Info file_info_; |
| 81 base::FilePath platform_path_; | 81 base::FilePath platform_path_; |
| 82 webkit_blob::ScopedFile scoped_file_; | 82 storage::ScopedFile scoped_file_; |
| 83 DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper); | 83 DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 void ReadDirectoryHelper(FileSystemFileUtil* file_util, | 86 void ReadDirectoryHelper(FileSystemFileUtil* file_util, |
| 87 FileSystemOperationContext* context, | 87 FileSystemOperationContext* context, |
| 88 const FileSystemURL& url, | 88 const FileSystemURL& url, |
| 89 base::SingleThreadTaskRunner* origin_loop, | 89 base::SingleThreadTaskRunner* origin_loop, |
| 90 const AsyncFileUtil::ReadDirectoryCallback& callback) { | 90 const AsyncFileUtil::ReadDirectoryCallback& callback) { |
| 91 base::File::Info file_info; | 91 base::File::Info file_info; |
| 92 base::FilePath platform_path; | 92 base::FilePath platform_path; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 FileSystemOperationContext* context_ptr = context.release(); | 342 FileSystemOperationContext* context_ptr = context.release(); |
| 343 GetFileInfoHelper* helper = new GetFileInfoHelper; | 343 GetFileInfoHelper* helper = new GetFileInfoHelper; |
| 344 const bool success = context_ptr->task_runner()->PostTaskAndReply( | 344 const bool success = context_ptr->task_runner()->PostTaskAndReply( |
| 345 FROM_HERE, | 345 FROM_HERE, |
| 346 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), | 346 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), |
| 347 sync_file_util_.get(), base::Owned(context_ptr), url), | 347 sync_file_util_.get(), base::Owned(context_ptr), url), |
| 348 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); | 348 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); |
| 349 DCHECK(success); | 349 DCHECK(success); |
| 350 } | 350 } |
| 351 | 351 |
| 352 } // namespace fileapi | 352 } // namespace storage |
| OLD | NEW |