OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 14 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
15 #include "webkit/browser/fileapi/file_system_backend.h" | 15 #include "webkit/browser/fileapi/file_system_backend.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class SequencedTaskRunner; | 18 class SequencedTaskRunner; |
19 } | 19 } |
20 | 20 |
21 namespace fileapi { | 21 namespace storage { |
22 class FileSystemURL; | 22 class FileSystemURL; |
23 } | 23 } |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 class URLRequest; | 26 class URLRequest; |
27 } | 27 } |
28 | 28 |
29 class MediaPathFilter; | 29 class MediaPathFilter; |
30 class DeviceMediaAsyncFileUtil; | 30 class DeviceMediaAsyncFileUtil; |
31 | 31 |
32 class MediaFileSystemBackend : public fileapi::FileSystemBackend { | 32 class MediaFileSystemBackend : public storage::FileSystemBackend { |
33 public: | 33 public: |
34 static const char kMediaTaskRunnerName[]; | 34 static const char kMediaTaskRunnerName[]; |
35 | 35 |
36 MediaFileSystemBackend( | 36 MediaFileSystemBackend( |
37 const base::FilePath& profile_path, | 37 const base::FilePath& profile_path, |
38 base::SequencedTaskRunner* media_task_runner); | 38 base::SequencedTaskRunner* media_task_runner); |
39 virtual ~MediaFileSystemBackend(); | 39 virtual ~MediaFileSystemBackend(); |
40 | 40 |
41 static bool CurrentlyOnMediaTaskRunnerThread(); | 41 static bool CurrentlyOnMediaTaskRunnerThread(); |
42 static scoped_refptr<base::SequencedTaskRunner> MediaTaskRunner(); | 42 static scoped_refptr<base::SequencedTaskRunner> MediaTaskRunner(); |
43 | 43 |
44 // Construct the mount point for the gallery specified by |pref_id| in | 44 // Construct the mount point for the gallery specified by |pref_id| in |
45 // the profile located in |profile_path|. | 45 // the profile located in |profile_path|. |
46 static std::string ConstructMountName(const base::FilePath& profile_path, | 46 static std::string ConstructMountName(const base::FilePath& profile_path, |
47 const std::string& extension_id, | 47 const std::string& extension_id, |
48 MediaGalleryPrefId pref_id); | 48 MediaGalleryPrefId pref_id); |
49 | 49 |
50 static bool AttemptAutoMountForURLRequest( | 50 static bool AttemptAutoMountForURLRequest( |
51 const net::URLRequest* url_request, | 51 const net::URLRequest* url_request, |
52 const fileapi::FileSystemURL& filesystem_url, | 52 const storage::FileSystemURL& filesystem_url, |
53 const std::string& storage_domain, | 53 const std::string& storage_domain, |
54 const base::Callback<void(base::File::Error result)>& callback); | 54 const base::Callback<void(base::File::Error result)>& callback); |
55 | 55 |
56 // FileSystemBackend implementation. | 56 // FileSystemBackend implementation. |
57 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE; | 57 virtual bool CanHandleType(storage::FileSystemType type) const OVERRIDE; |
58 virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE; | 58 virtual void Initialize(storage::FileSystemContext* context) OVERRIDE; |
59 virtual void ResolveURL(const fileapi::FileSystemURL& url, | 59 virtual void ResolveURL(const storage::FileSystemURL& url, |
60 fileapi::OpenFileSystemMode mode, | 60 storage::OpenFileSystemMode mode, |
61 const OpenFileSystemCallback& callback) OVERRIDE; | 61 const OpenFileSystemCallback& callback) OVERRIDE; |
62 virtual fileapi::AsyncFileUtil* GetAsyncFileUtil( | 62 virtual storage::AsyncFileUtil* GetAsyncFileUtil( |
63 fileapi::FileSystemType type) OVERRIDE; | 63 storage::FileSystemType type) OVERRIDE; |
64 virtual fileapi::CopyOrMoveFileValidatorFactory* | 64 virtual storage::CopyOrMoveFileValidatorFactory* |
65 GetCopyOrMoveFileValidatorFactory( | 65 GetCopyOrMoveFileValidatorFactory(storage::FileSystemType type, |
66 fileapi::FileSystemType type, | 66 base::File::Error* error_code) OVERRIDE; |
67 base::File::Error* error_code) OVERRIDE; | 67 virtual storage::FileSystemOperation* CreateFileSystemOperation( |
68 virtual fileapi::FileSystemOperation* CreateFileSystemOperation( | 68 const storage::FileSystemURL& url, |
69 const fileapi::FileSystemURL& url, | 69 storage::FileSystemContext* context, |
70 fileapi::FileSystemContext* context, | |
71 base::File::Error* error_code) const OVERRIDE; | 70 base::File::Error* error_code) const OVERRIDE; |
72 virtual bool SupportsStreaming( | 71 virtual bool SupportsStreaming( |
73 const fileapi::FileSystemURL& url) const OVERRIDE; | 72 const storage::FileSystemURL& url) const OVERRIDE; |
74 virtual bool HasInplaceCopyImplementation( | 73 virtual bool HasInplaceCopyImplementation( |
75 fileapi::FileSystemType type) const OVERRIDE; | 74 storage::FileSystemType type) const OVERRIDE; |
76 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | 75 virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader( |
77 const fileapi::FileSystemURL& url, | 76 const storage::FileSystemURL& url, |
78 int64 offset, | 77 int64 offset, |
79 const base::Time& expected_modification_time, | 78 const base::Time& expected_modification_time, |
80 fileapi::FileSystemContext* context) const OVERRIDE; | 79 storage::FileSystemContext* context) const OVERRIDE; |
81 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter( | 80 virtual scoped_ptr<storage::FileStreamWriter> CreateFileStreamWriter( |
82 const fileapi::FileSystemURL& url, | 81 const storage::FileSystemURL& url, |
83 int64 offset, | 82 int64 offset, |
84 fileapi::FileSystemContext* context) const OVERRIDE; | 83 storage::FileSystemContext* context) const OVERRIDE; |
85 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | 84 virtual storage::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
86 | 85 |
87 private: | 86 private: |
88 // Store the profile path. We need this to create temporary snapshot files. | 87 // Store the profile path. We need this to create temporary snapshot files. |
89 const base::FilePath profile_path_; | 88 const base::FilePath profile_path_; |
90 | 89 |
91 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; | 90 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; |
92 | 91 |
93 scoped_ptr<MediaPathFilter> media_path_filter_; | 92 scoped_ptr<MediaPathFilter> media_path_filter_; |
94 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> | 93 scoped_ptr<storage::CopyOrMoveFileValidatorFactory> |
95 media_copy_or_move_file_validator_factory_; | 94 media_copy_or_move_file_validator_factory_; |
96 | 95 |
97 scoped_ptr<fileapi::AsyncFileUtil> native_media_file_util_; | 96 scoped_ptr<storage::AsyncFileUtil> native_media_file_util_; |
98 scoped_ptr<DeviceMediaAsyncFileUtil> device_media_async_file_util_; | 97 scoped_ptr<DeviceMediaAsyncFileUtil> device_media_async_file_util_; |
99 #if defined(OS_WIN) || defined(OS_MACOSX) | 98 #if defined(OS_WIN) || defined(OS_MACOSX) |
100 scoped_ptr<fileapi::AsyncFileUtil> picasa_file_util_; | 99 scoped_ptr<storage::AsyncFileUtil> picasa_file_util_; |
101 scoped_ptr<fileapi::AsyncFileUtil> itunes_file_util_; | 100 scoped_ptr<storage::AsyncFileUtil> itunes_file_util_; |
102 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 101 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
103 #if defined(OS_MACOSX) | 102 #if defined(OS_MACOSX) |
104 scoped_ptr<fileapi::AsyncFileUtil> iphoto_file_util_; | 103 scoped_ptr<storage::AsyncFileUtil> iphoto_file_util_; |
105 #endif // defined(OS_MACOSX) | 104 #endif // defined(OS_MACOSX) |
106 | 105 |
107 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemBackend); | 106 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemBackend); |
108 }; | 107 }; |
109 | 108 |
110 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ | 109 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ |
OLD | NEW |