| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/local_discovery/storage/privet_filesystem_backend.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h" | |
| 10 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h" | |
| 11 #include "webkit/browser/fileapi/file_system_operation.h" | |
| 12 #include "webkit/browser/fileapi/file_system_url.h" | |
| 13 | |
| 14 namespace local_discovery { | |
| 15 | |
| 16 PrivetFileSystemBackend::PrivetFileSystemBackend( | |
| 17 storage::ExternalMountPoints* mount_points, | |
| 18 content::BrowserContext* browser_context) | |
| 19 : mount_points_(mount_points), | |
| 20 async_util_(new PrivetFileSystemAsyncUtil(browser_context)) { | |
| 21 } | |
| 22 | |
| 23 PrivetFileSystemBackend::~PrivetFileSystemBackend() { | |
| 24 } | |
| 25 | |
| 26 bool PrivetFileSystemBackend::CanHandleType( | |
| 27 storage::FileSystemType type) const { | |
| 28 return (type == storage::kFileSystemTypeCloudDevice); | |
| 29 } | |
| 30 | |
| 31 void PrivetFileSystemBackend::Initialize(storage::FileSystemContext* context) { | |
| 32 mount_points_->RegisterFileSystem("privet", | |
| 33 storage::kFileSystemTypeCloudDevice, | |
| 34 storage::FileSystemMountOption(), | |
| 35 base::FilePath(kPrivetFilePath)); | |
| 36 } | |
| 37 | |
| 38 void PrivetFileSystemBackend::ResolveURL( | |
| 39 const storage::FileSystemURL& url, | |
| 40 storage::OpenFileSystemMode mode, | |
| 41 const OpenFileSystemCallback& callback) { | |
| 42 // TODO(noamsml): Provide a proper root url and a proper name. | |
| 43 GURL root_url = GURL( | |
| 44 storage::GetExternalFileSystemRootURIString(url.origin(), std::string())); | |
| 45 callback.Run(root_url, std::string(), base::File::FILE_OK); | |
| 46 } | |
| 47 | |
| 48 storage::FileSystemQuotaUtil* PrivetFileSystemBackend::GetQuotaUtil() { | |
| 49 // No quota support. | |
| 50 return NULL; | |
| 51 } | |
| 52 | |
| 53 storage::AsyncFileUtil* PrivetFileSystemBackend::GetAsyncFileUtil( | |
| 54 storage::FileSystemType type) { | |
| 55 return async_util_.get(); | |
| 56 } | |
| 57 | |
| 58 storage::WatcherManager* PrivetFileSystemBackend::GetWatcherManager( | |
| 59 storage::FileSystemType type) { | |
| 60 return NULL; | |
| 61 } | |
| 62 | |
| 63 storage::CopyOrMoveFileValidatorFactory* | |
| 64 PrivetFileSystemBackend::GetCopyOrMoveFileValidatorFactory( | |
| 65 storage::FileSystemType type, | |
| 66 base::File::Error* error_code) { | |
| 67 DCHECK(error_code); | |
| 68 *error_code = base::File::FILE_OK; | |
| 69 return NULL; | |
| 70 } | |
| 71 | |
| 72 storage::FileSystemOperation* | |
| 73 PrivetFileSystemBackend::CreateFileSystemOperation( | |
| 74 const storage::FileSystemURL& url, | |
| 75 storage::FileSystemContext* context, | |
| 76 base::File::Error* error_code) const { | |
| 77 return storage::FileSystemOperation::Create( | |
| 78 url, | |
| 79 context, | |
| 80 make_scoped_ptr(new storage::FileSystemOperationContext(context))); | |
| 81 } | |
| 82 | |
| 83 bool PrivetFileSystemBackend::SupportsStreaming( | |
| 84 const storage::FileSystemURL& url) const { | |
| 85 return false; | |
| 86 } | |
| 87 | |
| 88 bool PrivetFileSystemBackend::HasInplaceCopyImplementation( | |
| 89 storage::FileSystemType type) const { | |
| 90 return true; | |
| 91 } | |
| 92 | |
| 93 scoped_ptr<storage::FileStreamReader> | |
| 94 PrivetFileSystemBackend::CreateFileStreamReader( | |
| 95 const storage::FileSystemURL& url, | |
| 96 int64 offset, | |
| 97 const base::Time& expected_modification_time, | |
| 98 storage::FileSystemContext* context) const { | |
| 99 return scoped_ptr<storage::FileStreamReader>(); | |
| 100 } | |
| 101 | |
| 102 scoped_ptr<storage::FileStreamWriter> | |
| 103 PrivetFileSystemBackend::CreateFileStreamWriter( | |
| 104 const storage::FileSystemURL& url, | |
| 105 int64 offset, | |
| 106 storage::FileSystemContext* context) const { | |
| 107 return scoped_ptr<storage::FileStreamWriter>(); | |
| 108 } | |
| 109 | |
| 110 } // namespace local_discovery | |
| OLD | NEW |