| OLD | NEW |
| 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 "content/public/test/test_file_system_backend.h" | 5 #include "content/public/test/test_file_system_backend.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 class TestFileUtil : public fileapi::LocalFileUtil { | 36 class TestFileUtil : public fileapi::LocalFileUtil { |
| 37 public: | 37 public: |
| 38 explicit TestFileUtil(const base::FilePath& base_path) | 38 explicit TestFileUtil(const base::FilePath& base_path) |
| 39 : base_path_(base_path) {} | 39 : base_path_(base_path) {} |
| 40 virtual ~TestFileUtil() {} | 40 virtual ~TestFileUtil() {} |
| 41 | 41 |
| 42 // LocalFileUtil overrides. | 42 // LocalFileUtil overrides. |
| 43 virtual base::PlatformFileError GetLocalFilePath( | 43 virtual base::File::Error GetLocalFilePath( |
| 44 FileSystemOperationContext* context, | 44 FileSystemOperationContext* context, |
| 45 const FileSystemURL& file_system_url, | 45 const FileSystemURL& file_system_url, |
| 46 base::FilePath* local_file_path) OVERRIDE { | 46 base::FilePath* local_file_path) OVERRIDE { |
| 47 *local_file_path = base_path_.Append(file_system_url.path()); | 47 *local_file_path = base_path_.Append(file_system_url.path()); |
| 48 return base::PLATFORM_FILE_OK; | 48 return base::File::FILE_OK; |
| 49 } | 49 } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 base::FilePath base_path_; | 52 base::FilePath base_path_; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 // This only supports single origin. | 57 // This only supports single origin. |
| 58 class TestFileSystemBackend::QuotaUtil | 58 class TestFileSystemBackend::QuotaUtil |
| 59 : public fileapi::FileSystemQuotaUtil, | 59 : public fileapi::FileSystemQuotaUtil, |
| 60 public fileapi::FileUpdateObserver { | 60 public fileapi::FileUpdateObserver { |
| 61 public: | 61 public: |
| 62 explicit QuotaUtil(base::SequencedTaskRunner* task_runner) | 62 explicit QuotaUtil(base::SequencedTaskRunner* task_runner) |
| 63 : usage_(0), | 63 : usage_(0), |
| 64 task_runner_(task_runner) { | 64 task_runner_(task_runner) { |
| 65 update_observers_ = update_observers_.AddObserver(this, task_runner_.get()); | 65 update_observers_ = update_observers_.AddObserver(this, task_runner_.get()); |
| 66 } | 66 } |
| 67 virtual ~QuotaUtil() {} | 67 virtual ~QuotaUtil() {} |
| 68 | 68 |
| 69 // FileSystemQuotaUtil overrides. | 69 // FileSystemQuotaUtil overrides. |
| 70 virtual base::PlatformFileError DeleteOriginDataOnFileTaskRunner( | 70 virtual base::File::Error DeleteOriginDataOnFileTaskRunner( |
| 71 FileSystemContext* context, | 71 FileSystemContext* context, |
| 72 quota::QuotaManagerProxy* proxy, | 72 quota::QuotaManagerProxy* proxy, |
| 73 const GURL& origin_url, | 73 const GURL& origin_url, |
| 74 FileSystemType type) OVERRIDE { | 74 FileSystemType type) OVERRIDE { |
| 75 NOTREACHED(); | 75 NOTREACHED(); |
| 76 return base::PLATFORM_FILE_OK; | 76 return base::File::FILE_OK; |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual scoped_refptr<fileapi::QuotaReservation> | 79 virtual scoped_refptr<fileapi::QuotaReservation> |
| 80 CreateQuotaReservationOnFileTaskRunner( | 80 CreateQuotaReservationOnFileTaskRunner( |
| 81 const GURL& origin_url, | 81 const GURL& origin_url, |
| 82 FileSystemType type) OVERRIDE { | 82 FileSystemType type) OVERRIDE { |
| 83 NOTREACHED(); | 83 NOTREACHED(); |
| 84 return scoped_refptr<fileapi::QuotaReservation>(); | 84 return scoped_refptr<fileapi::QuotaReservation>(); |
| 85 } | 85 } |
| 86 | 86 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 void TestFileSystemBackend::Initialize(FileSystemContext* context) { | 179 void TestFileSystemBackend::Initialize(FileSystemContext* context) { |
| 180 } | 180 } |
| 181 | 181 |
| 182 void TestFileSystemBackend::OpenFileSystem( | 182 void TestFileSystemBackend::OpenFileSystem( |
| 183 const GURL& origin_url, | 183 const GURL& origin_url, |
| 184 FileSystemType type, | 184 FileSystemType type, |
| 185 fileapi::OpenFileSystemMode mode, | 185 fileapi::OpenFileSystemMode mode, |
| 186 const OpenFileSystemCallback& callback) { | 186 const OpenFileSystemCallback& callback) { |
| 187 callback.Run(GetFileSystemRootURI(origin_url, type), | 187 callback.Run(GetFileSystemRootURI(origin_url, type), |
| 188 GetFileSystemName(origin_url, type), | 188 GetFileSystemName(origin_url, type), |
| 189 base::PLATFORM_FILE_OK); | 189 base::File::FILE_OK); |
| 190 } | 190 } |
| 191 | 191 |
| 192 fileapi::AsyncFileUtil* TestFileSystemBackend::GetAsyncFileUtil( | 192 fileapi::AsyncFileUtil* TestFileSystemBackend::GetAsyncFileUtil( |
| 193 FileSystemType type) { | 193 FileSystemType type) { |
| 194 return file_util_.get(); | 194 return file_util_.get(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 fileapi::CopyOrMoveFileValidatorFactory* | 197 fileapi::CopyOrMoveFileValidatorFactory* |
| 198 TestFileSystemBackend::GetCopyOrMoveFileValidatorFactory( | 198 TestFileSystemBackend::GetCopyOrMoveFileValidatorFactory( |
| 199 FileSystemType type, base::PlatformFileError* error_code) { | 199 FileSystemType type, base::File::Error* error_code) { |
| 200 DCHECK(error_code); | 200 DCHECK(error_code); |
| 201 *error_code = base::PLATFORM_FILE_OK; | 201 *error_code = base::File::FILE_OK; |
| 202 if (require_copy_or_move_validator_) { | 202 if (require_copy_or_move_validator_) { |
| 203 if (!copy_or_move_file_validator_factory_) | 203 if (!copy_or_move_file_validator_factory_) |
| 204 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; | 204 *error_code = base::File::FILE_ERROR_SECURITY; |
| 205 return copy_or_move_file_validator_factory_.get(); | 205 return copy_or_move_file_validator_factory_.get(); |
| 206 } | 206 } |
| 207 return NULL; | 207 return NULL; |
| 208 } | 208 } |
| 209 | 209 |
| 210 void TestFileSystemBackend::InitializeCopyOrMoveFileValidatorFactory( | 210 void TestFileSystemBackend::InitializeCopyOrMoveFileValidatorFactory( |
| 211 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) { | 211 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) { |
| 212 if (!copy_or_move_file_validator_factory_) | 212 if (!copy_or_move_file_validator_factory_) |
| 213 copy_or_move_file_validator_factory_ = factory.Pass(); | 213 copy_or_move_file_validator_factory_ = factory.Pass(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 FileSystemOperation* TestFileSystemBackend::CreateFileSystemOperation( | 216 FileSystemOperation* TestFileSystemBackend::CreateFileSystemOperation( |
| 217 const FileSystemURL& url, | 217 const FileSystemURL& url, |
| 218 FileSystemContext* context, | 218 FileSystemContext* context, |
| 219 base::PlatformFileError* error_code) const { | 219 base::File::Error* error_code) const { |
| 220 scoped_ptr<FileSystemOperationContext> operation_context( | 220 scoped_ptr<FileSystemOperationContext> operation_context( |
| 221 new FileSystemOperationContext(context)); | 221 new FileSystemOperationContext(context)); |
| 222 operation_context->set_update_observers(*GetUpdateObservers(url.type())); | 222 operation_context->set_update_observers(*GetUpdateObservers(url.type())); |
| 223 operation_context->set_change_observers( | 223 operation_context->set_change_observers( |
| 224 *quota_util_->GetChangeObservers(url.type())); | 224 *quota_util_->GetChangeObservers(url.type())); |
| 225 return FileSystemOperation::Create(url, context, operation_context.Pass()); | 225 return FileSystemOperation::Create(url, context, operation_context.Pass()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 scoped_ptr<webkit_blob::FileStreamReader> | 228 scoped_ptr<webkit_blob::FileStreamReader> |
| 229 TestFileSystemBackend::CreateFileStreamReader( | 229 TestFileSystemBackend::CreateFileStreamReader( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 255 return quota_util_->GetUpdateObservers(type); | 255 return quota_util_->GetUpdateObservers(type); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void TestFileSystemBackend::AddFileChangeObserver( | 258 void TestFileSystemBackend::AddFileChangeObserver( |
| 259 fileapi::FileChangeObserver* observer) { | 259 fileapi::FileChangeObserver* observer) { |
| 260 quota_util_->AddFileChangeObserver( | 260 quota_util_->AddFileChangeObserver( |
| 261 fileapi::kFileSystemTypeTest, observer, quota_util_->task_runner()); | 261 fileapi::kFileSystemTypeTest, observer, quota_util_->task_runner()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace content | 264 } // namespace content |
| OLD | NEW |