| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h" | 5 #include "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h" |
| 6 | 6 |
| 7 #include "chrome/browser/local_discovery/storage/path_util.h" | 7 #include "chrome/browser/local_discovery/storage/path_util.h" |
| 8 #include "webkit/browser/fileapi/file_system_url.h" | 8 #include "webkit/browser/fileapi/file_system_url.h" |
| 9 #include "webkit/common/blob/shareable_file_reference.h" | 9 #include "webkit/common/blob/shareable_file_reference.h" |
| 10 | 10 |
| 11 namespace local_discovery { | 11 namespace local_discovery { |
| 12 | 12 |
| 13 PrivetFileSystemAsyncUtil::PrivetFileSystemAsyncUtil( | 13 PrivetFileSystemAsyncUtil::PrivetFileSystemAsyncUtil( |
| 14 content::BrowserContext* browser_context) { | 14 content::BrowserContext* browser_context) { |
| 15 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 15 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 16 operation_factory_ = new PrivetFileSystemOperationFactory(browser_context); | 16 operation_factory_ = new PrivetFileSystemOperationFactory(browser_context); |
| 17 } | 17 } |
| 18 | 18 |
| 19 PrivetFileSystemAsyncUtil::~PrivetFileSystemAsyncUtil() { | 19 PrivetFileSystemAsyncUtil::~PrivetFileSystemAsyncUtil() { |
| 20 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 20 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 21 content::BrowserThread::DeleteSoon( | 21 content::BrowserThread::DeleteSoon( |
| 22 content::BrowserThread::UI, FROM_HERE, operation_factory_); | 22 content::BrowserThread::UI, FROM_HERE, operation_factory_); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void PrivetFileSystemAsyncUtil::CreateOrOpen( | 25 void PrivetFileSystemAsyncUtil::CreateOrOpen( |
| 26 scoped_ptr<fileapi::FileSystemOperationContext> context, | 26 scoped_ptr<storage::FileSystemOperationContext> context, |
| 27 const fileapi::FileSystemURL& url, | 27 const storage::FileSystemURL& url, |
| 28 int file_flags, | 28 int file_flags, |
| 29 const CreateOrOpenCallback& callback) { | 29 const CreateOrOpenCallback& callback) { |
| 30 NOTIMPLEMENTED(); | 30 NOTIMPLEMENTED(); |
| 31 callback.Run(base::File(base::File::FILE_ERROR_INVALID_OPERATION), | 31 callback.Run(base::File(base::File::FILE_ERROR_INVALID_OPERATION), |
| 32 base::Closure()); | 32 base::Closure()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void PrivetFileSystemAsyncUtil::EnsureFileExists( | 35 void PrivetFileSystemAsyncUtil::EnsureFileExists( |
| 36 scoped_ptr<fileapi::FileSystemOperationContext> context, | 36 scoped_ptr<storage::FileSystemOperationContext> context, |
| 37 const fileapi::FileSystemURL& url, | 37 const storage::FileSystemURL& url, |
| 38 const EnsureFileExistsCallback& callback) { | 38 const EnsureFileExistsCallback& callback) { |
| 39 NOTIMPLEMENTED(); | 39 NOTIMPLEMENTED(); |
| 40 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, false); | 40 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, false); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void PrivetFileSystemAsyncUtil::CreateDirectory( | 43 void PrivetFileSystemAsyncUtil::CreateDirectory( |
| 44 scoped_ptr<fileapi::FileSystemOperationContext> context, | 44 scoped_ptr<storage::FileSystemOperationContext> context, |
| 45 const fileapi::FileSystemURL& url, | 45 const storage::FileSystemURL& url, |
| 46 bool exclusive, | 46 bool exclusive, |
| 47 bool recursive, | 47 bool recursive, |
| 48 const StatusCallback& callback) { | 48 const StatusCallback& callback) { |
| 49 NOTIMPLEMENTED(); | 49 NOTIMPLEMENTED(); |
| 50 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 50 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void PrivetFileSystemAsyncUtil::GetFileInfo( | 53 void PrivetFileSystemAsyncUtil::GetFileInfo( |
| 54 scoped_ptr<fileapi::FileSystemOperationContext> context, | 54 scoped_ptr<storage::FileSystemOperationContext> context, |
| 55 const fileapi::FileSystemURL& url, | 55 const storage::FileSystemURL& url, |
| 56 const GetFileInfoCallback& callback) { | 56 const GetFileInfoCallback& callback) { |
| 57 ParsedPrivetPath parsed_path(url.path()); | 57 ParsedPrivetPath parsed_path(url.path()); |
| 58 | 58 |
| 59 if (parsed_path.path == "/") { | 59 if (parsed_path.path == "/") { |
| 60 base::File::Info file_info; | 60 base::File::Info file_info; |
| 61 file_info.is_directory = true; | 61 file_info.is_directory = true; |
| 62 file_info.is_symbolic_link = false; | 62 file_info.is_symbolic_link = false; |
| 63 callback.Run(base::File::FILE_OK, file_info); | 63 callback.Run(base::File::FILE_OK, file_info); |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 content::BrowserThread::PostTask( | 67 content::BrowserThread::PostTask( |
| 68 content::BrowserThread::UI, | 68 content::BrowserThread::UI, |
| 69 FROM_HERE, | 69 FROM_HERE, |
| 70 base::Bind(&PrivetFileSystemOperationFactory::GetFileInfo, | 70 base::Bind(&PrivetFileSystemOperationFactory::GetFileInfo, |
| 71 operation_factory_->GetWeakPtr(), | 71 operation_factory_->GetWeakPtr(), |
| 72 url, | 72 url, |
| 73 callback)); | 73 callback)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void PrivetFileSystemAsyncUtil::ReadDirectory( | 76 void PrivetFileSystemAsyncUtil::ReadDirectory( |
| 77 scoped_ptr<fileapi::FileSystemOperationContext> context, | 77 scoped_ptr<storage::FileSystemOperationContext> context, |
| 78 const fileapi::FileSystemURL& url, | 78 const storage::FileSystemURL& url, |
| 79 const ReadDirectoryCallback& callback) { | 79 const ReadDirectoryCallback& callback) { |
| 80 content::BrowserThread::PostTask( | 80 content::BrowserThread::PostTask( |
| 81 content::BrowserThread::UI, | 81 content::BrowserThread::UI, |
| 82 FROM_HERE, | 82 FROM_HERE, |
| 83 base::Bind(&PrivetFileSystemOperationFactory::ReadDirectory, | 83 base::Bind(&PrivetFileSystemOperationFactory::ReadDirectory, |
| 84 operation_factory_->GetWeakPtr(), | 84 operation_factory_->GetWeakPtr(), |
| 85 url, | 85 url, |
| 86 callback)); | 86 callback)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 | |
| 90 void PrivetFileSystemAsyncUtil::Touch( | 89 void PrivetFileSystemAsyncUtil::Touch( |
| 91 scoped_ptr<fileapi::FileSystemOperationContext> context, | 90 scoped_ptr<storage::FileSystemOperationContext> context, |
| 92 const fileapi::FileSystemURL& url, | 91 const storage::FileSystemURL& url, |
| 93 const base::Time& last_access_time, | 92 const base::Time& last_access_time, |
| 94 const base::Time& last_modified_time, | 93 const base::Time& last_modified_time, |
| 95 const StatusCallback& callback) { | 94 const StatusCallback& callback) { |
| 96 NOTIMPLEMENTED(); | 95 NOTIMPLEMENTED(); |
| 97 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 96 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 98 } | 97 } |
| 99 | 98 |
| 100 void PrivetFileSystemAsyncUtil::Truncate( | 99 void PrivetFileSystemAsyncUtil::Truncate( |
| 101 scoped_ptr<fileapi::FileSystemOperationContext> context, | 100 scoped_ptr<storage::FileSystemOperationContext> context, |
| 102 const fileapi::FileSystemURL& url, | 101 const storage::FileSystemURL& url, |
| 103 int64 length, | 102 int64 length, |
| 104 const StatusCallback& callback) { | 103 const StatusCallback& callback) { |
| 105 NOTIMPLEMENTED(); | 104 NOTIMPLEMENTED(); |
| 106 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 105 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 107 } | 106 } |
| 108 | 107 |
| 109 void PrivetFileSystemAsyncUtil::CopyFileLocal( | 108 void PrivetFileSystemAsyncUtil::CopyFileLocal( |
| 110 scoped_ptr<fileapi::FileSystemOperationContext> context, | 109 scoped_ptr<storage::FileSystemOperationContext> context, |
| 111 const fileapi::FileSystemURL& src_url, | 110 const storage::FileSystemURL& src_url, |
| 112 const fileapi::FileSystemURL& dest_url, | 111 const storage::FileSystemURL& dest_url, |
| 113 CopyOrMoveOption option, | 112 CopyOrMoveOption option, |
| 114 const CopyFileProgressCallback& progress_callback, | 113 const CopyFileProgressCallback& progress_callback, |
| 115 const StatusCallback& callback) { | 114 const StatusCallback& callback) { |
| 116 NOTIMPLEMENTED(); | 115 NOTIMPLEMENTED(); |
| 117 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 116 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 118 } | 117 } |
| 119 | 118 |
| 120 void PrivetFileSystemAsyncUtil::MoveFileLocal( | 119 void PrivetFileSystemAsyncUtil::MoveFileLocal( |
| 121 scoped_ptr<fileapi::FileSystemOperationContext> context, | 120 scoped_ptr<storage::FileSystemOperationContext> context, |
| 122 const fileapi::FileSystemURL& src_url, | 121 const storage::FileSystemURL& src_url, |
| 123 const fileapi::FileSystemURL& dest_url, | 122 const storage::FileSystemURL& dest_url, |
| 124 CopyOrMoveOption option, | 123 CopyOrMoveOption option, |
| 125 const StatusCallback& callback) { | 124 const StatusCallback& callback) { |
| 126 NOTIMPLEMENTED(); | 125 NOTIMPLEMENTED(); |
| 127 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 126 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 128 } | 127 } |
| 129 | 128 |
| 130 void PrivetFileSystemAsyncUtil::CopyInForeignFile( | 129 void PrivetFileSystemAsyncUtil::CopyInForeignFile( |
| 131 scoped_ptr<fileapi::FileSystemOperationContext> context, | 130 scoped_ptr<storage::FileSystemOperationContext> context, |
| 132 const base::FilePath& src_file_path, | 131 const base::FilePath& src_file_path, |
| 133 const fileapi::FileSystemURL& dest_url, | 132 const storage::FileSystemURL& dest_url, |
| 134 const StatusCallback& callback) { | 133 const StatusCallback& callback) { |
| 135 NOTIMPLEMENTED(); | 134 NOTIMPLEMENTED(); |
| 136 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 135 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 137 } | 136 } |
| 138 | 137 |
| 139 void PrivetFileSystemAsyncUtil::DeleteFile( | 138 void PrivetFileSystemAsyncUtil::DeleteFile( |
| 140 scoped_ptr<fileapi::FileSystemOperationContext> context, | 139 scoped_ptr<storage::FileSystemOperationContext> context, |
| 141 const fileapi::FileSystemURL& url, | 140 const storage::FileSystemURL& url, |
| 142 const StatusCallback& callback) { | 141 const StatusCallback& callback) { |
| 143 NOTIMPLEMENTED(); | 142 NOTIMPLEMENTED(); |
| 144 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 143 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 145 } | 144 } |
| 146 | 145 |
| 147 void PrivetFileSystemAsyncUtil::DeleteDirectory( | 146 void PrivetFileSystemAsyncUtil::DeleteDirectory( |
| 148 scoped_ptr<fileapi::FileSystemOperationContext> context, | 147 scoped_ptr<storage::FileSystemOperationContext> context, |
| 149 const fileapi::FileSystemURL& url, | 148 const storage::FileSystemURL& url, |
| 150 const StatusCallback& callback) { | 149 const StatusCallback& callback) { |
| 151 NOTIMPLEMENTED(); | 150 NOTIMPLEMENTED(); |
| 152 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 151 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 153 } | 152 } |
| 154 | 153 |
| 155 void PrivetFileSystemAsyncUtil::DeleteRecursively( | 154 void PrivetFileSystemAsyncUtil::DeleteRecursively( |
| 156 scoped_ptr<fileapi::FileSystemOperationContext> context, | 155 scoped_ptr<storage::FileSystemOperationContext> context, |
| 157 const fileapi::FileSystemURL& url, | 156 const storage::FileSystemURL& url, |
| 158 const StatusCallback& callback) { | 157 const StatusCallback& callback) { |
| 159 NOTIMPLEMENTED(); | 158 NOTIMPLEMENTED(); |
| 160 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 159 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 161 } | 160 } |
| 162 | 161 |
| 163 void PrivetFileSystemAsyncUtil::CreateSnapshotFile( | 162 void PrivetFileSystemAsyncUtil::CreateSnapshotFile( |
| 164 scoped_ptr<fileapi::FileSystemOperationContext> context, | 163 scoped_ptr<storage::FileSystemOperationContext> context, |
| 165 const fileapi::FileSystemURL& url, | 164 const storage::FileSystemURL& url, |
| 166 const CreateSnapshotFileCallback& callback) { | 165 const CreateSnapshotFileCallback& callback) { |
| 167 NOTIMPLEMENTED(); | 166 NOTIMPLEMENTED(); |
| 168 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, | 167 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, |
| 169 base::File::Info(), | 168 base::File::Info(), |
| 170 base::FilePath(), | 169 base::FilePath(), |
| 171 scoped_refptr<webkit_blob::ShareableFileReference>()); | 170 scoped_refptr<storage::ShareableFileReference>()); |
| 172 } | 171 } |
| 173 | 172 |
| 174 } // namespace local_discovery | 173 } // namespace local_discovery |
| OLD | NEW |