Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ |
| 6 | #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 7 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 8 | #include "base/memory/ref_counted.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 9 | #include "base/memory/scoped_ptr.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 10 | #include "webkit/browser/fileapi/file_system_backend.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 11 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 12 | namespace base { |
| 13 | class SequencedTaskRunner; |
| 14 | } |
| 15 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 16 | namespace fileapi { |
| 17 | class AsyncFileUtilAdapter; |
| 18 | } |
| 19 | |
| 20 | namespace chrome { |
| 21 | |
| 22 | class MediaPathFilter; |
| 23 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 24 | class DeviceMediaAsyncFileUtil; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 25 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 26 | class MediaFileSystemBackend : public fileapi::FileSystemBackend { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 27 | public: |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 28 | static const char kMediaTaskRunnerName[]; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 29 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 30 | MediaFileSystemBackend( |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 31 | const base::FilePath& profile_path, |
| 32 | base::SequencedTaskRunner* media_task_runner); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 33 | virtual ~MediaFileSystemBackend(); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 34 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 35 | static bool CurrentlyOnMediaTaskRunnerThread(); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 36 | static scoped_refptr<base::SequencedTaskRunner> MediaTaskRunner(); |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 37 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 38 | // FileSystemBackend implementation. |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 39 | virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE; |
Ben Murdoch | bbcdd45 | 2013-07-25 10:06:34 +0100 | [diff] [blame] | 40 | virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE; |
| 41 | virtual void OpenFileSystem( |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 42 | const GURL& origin_url, |
| 43 | fileapi::FileSystemType type, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 44 | fileapi::OpenFileSystemMode mode, |
Ben Murdoch | bbcdd45 | 2013-07-25 10:06:34 +0100 | [diff] [blame] | 45 | const OpenFileSystemCallback& callback) OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 46 | virtual fileapi::FileSystemFileUtil* GetFileUtil( |
| 47 | fileapi::FileSystemType type) OVERRIDE; |
| 48 | virtual fileapi::AsyncFileUtil* GetAsyncFileUtil( |
| 49 | fileapi::FileSystemType type) OVERRIDE; |
| 50 | virtual fileapi::CopyOrMoveFileValidatorFactory* |
| 51 | GetCopyOrMoveFileValidatorFactory( |
| 52 | fileapi::FileSystemType type, |
| 53 | base::PlatformFileError* error_code) OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 54 | virtual fileapi::FileSystemOperation* CreateFileSystemOperation( |
| 55 | const fileapi::FileSystemURL& url, |
| 56 | fileapi::FileSystemContext* context, |
| 57 | base::PlatformFileError* error_code) const OVERRIDE; |
| 58 | virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( |
| 59 | const fileapi::FileSystemURL& url, |
| 60 | int64 offset, |
| 61 | const base::Time& expected_modification_time, |
| 62 | fileapi::FileSystemContext* context) const OVERRIDE; |
| 63 | virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter( |
| 64 | const fileapi::FileSystemURL& url, |
| 65 | int64 offset, |
| 66 | fileapi::FileSystemContext* context) const OVERRIDE; |
| 67 | virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 68 | |
| 69 | private: |
| 70 | // Store the profile path. We need this to create temporary snapshot files. |
| 71 | const base::FilePath profile_path_; |
| 72 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 73 | scoped_refptr<base::SequencedTaskRunner> media_task_runner_; |
| 74 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 75 | scoped_ptr<MediaPathFilter> media_path_filter_; |
| 76 | scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> |
| 77 | media_copy_or_move_file_validator_factory_; |
| 78 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 79 | scoped_ptr<fileapi::AsyncFileUtil> native_media_file_util_; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 80 | scoped_ptr<DeviceMediaAsyncFileUtil> device_media_async_file_util_; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 81 | #if defined(OS_WIN) || defined(OS_MACOSX) |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 82 | scoped_ptr<fileapi::AsyncFileUtil> picasa_file_util_; |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 83 | scoped_ptr<fileapi::AsyncFileUtil> itunes_file_util_; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 84 | #endif // defined(OS_WIN) || defined(OS_MACOSX) |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 85 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 86 | DISALLOW_COPY_AND_ASSIGN(MediaFileSystemBackend); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | } // namespace chrome |
| 90 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 91 | #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ |