| 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 "base/platform_file.h" | 7 #include "base/platform_file.h" |
| 8 #include "base/stl_util.h" |
| 8 #include "webkit/browser/fileapi/file_system_url.h" | 9 #include "webkit/browser/fileapi/file_system_url.h" |
| 9 #include "webkit/common/blob/shareable_file_reference.h" | 10 #include "webkit/common/blob/shareable_file_reference.h" |
| 10 | 11 |
| 11 namespace local_discovery { | 12 namespace local_discovery { |
| 12 | 13 |
| 14 PrivetFileSystemAsyncUtil::PrivetFileSystemAsyncUtil( |
| 15 content::BrowserContext* browser_context) |
| 16 : browser_context_(browser_context) { |
| 17 } |
| 18 |
| 19 PrivetFileSystemAsyncUtil::~PrivetFileSystemAsyncUtil() { |
| 20 } |
| 21 |
| 13 void PrivetFileSystemAsyncUtil::CreateOrOpen( | 22 void PrivetFileSystemAsyncUtil::CreateOrOpen( |
| 14 scoped_ptr<fileapi::FileSystemOperationContext> context, | 23 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 15 const fileapi::FileSystemURL& url, | 24 const fileapi::FileSystemURL& url, |
| 16 int file_flags, | 25 int file_flags, |
| 17 const CreateOrOpenCallback& callback) { | 26 const CreateOrOpenCallback& callback) { |
| 18 NOTIMPLEMENTED(); | 27 NOTIMPLEMENTED(); |
| 19 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, | 28 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, |
| 20 base::PassPlatformFile(NULL), | 29 base::PassPlatformFile(NULL), |
| 21 base::Closure()); | 30 base::Closure()); |
| 22 } | 31 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 file_info.is_directory = true; | 58 file_info.is_directory = true; |
| 50 file_info.is_symbolic_link = false; | 59 file_info.is_symbolic_link = false; |
| 51 | 60 |
| 52 callback.Run(base::File::FILE_OK, file_info); | 61 callback.Run(base::File::FILE_OK, file_info); |
| 53 } | 62 } |
| 54 | 63 |
| 55 void PrivetFileSystemAsyncUtil::ReadDirectory( | 64 void PrivetFileSystemAsyncUtil::ReadDirectory( |
| 56 scoped_ptr<fileapi::FileSystemOperationContext> context, | 65 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 57 const fileapi::FileSystemURL& url, | 66 const fileapi::FileSystemURL& url, |
| 58 const ReadDirectoryCallback& callback) { | 67 const ReadDirectoryCallback& callback) { |
| 59 EntryList entry_list; | 68 PrivetFileSystemAsyncOperation* operation = new PrivetFileSystemListOperation( |
| 69 url.path(), |
| 70 browser_context_, |
| 71 this, |
| 72 callback); |
| 73 async_operations_.insert(operation); |
| 74 operation->Start(); |
| 75 } |
| 60 | 76 |
| 61 fileapi::DirectoryEntry entry("Random file", | |
| 62 fileapi::DirectoryEntry::FILE, | |
| 63 3000, | |
| 64 base::Time()); | |
| 65 entry_list.push_back(entry); | |
| 66 | |
| 67 callback.Run(base::File::FILE_OK, entry_list, false); | |
| 68 } | |
| 69 | 77 |
| 70 void PrivetFileSystemAsyncUtil::Touch( | 78 void PrivetFileSystemAsyncUtil::Touch( |
| 71 scoped_ptr<fileapi::FileSystemOperationContext> context, | 79 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 72 const fileapi::FileSystemURL& url, | 80 const fileapi::FileSystemURL& url, |
| 73 const base::Time& last_access_time, | 81 const base::Time& last_access_time, |
| 74 const base::Time& last_modified_time, | 82 const base::Time& last_modified_time, |
| 75 const StatusCallback& callback) { | 83 const StatusCallback& callback) { |
| 76 NOTIMPLEMENTED(); | 84 NOTIMPLEMENTED(); |
| 77 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 85 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 78 } | 86 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 scoped_ptr<fileapi::FileSystemOperationContext> context, | 152 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 145 const fileapi::FileSystemURL& url, | 153 const fileapi::FileSystemURL& url, |
| 146 const CreateSnapshotFileCallback& callback) { | 154 const CreateSnapshotFileCallback& callback) { |
| 147 NOTIMPLEMENTED(); | 155 NOTIMPLEMENTED(); |
| 148 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, | 156 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, |
| 149 base::File::Info(), | 157 base::File::Info(), |
| 150 base::FilePath(), | 158 base::FilePath(), |
| 151 scoped_refptr<webkit_blob::ShareableFileReference>()); | 159 scoped_refptr<webkit_blob::ShareableFileReference>()); |
| 152 } | 160 } |
| 153 | 161 |
| 162 void PrivetFileSystemAsyncUtil::RemoveOperation( |
| 163 PrivetFileSystemAsyncOperation* operation) { |
| 164 async_operations_.erase(operation); |
| 165 delete operation; |
| 166 } |
| 167 |
| 168 void PrivetFileSystemAsyncUtil::RemoveAllOperations() { |
| 169 STLDeleteElements(&async_operations_); |
| 170 } |
| 171 |
| 154 } // namespace local_discovery | 172 } // namespace local_discovery |
| OLD | NEW |