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 "storage/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 scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | 73 virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader( |
75 const fileapi::FileSystemURL& url, | 74 const storage::FileSystemURL& url, |
76 int64 offset, | 75 int64 offset, |
77 const base::Time& expected_modification_time, | 76 const base::Time& expected_modification_time, |
78 fileapi::FileSystemContext* context) const OVERRIDE; | 77 storage::FileSystemContext* context) const OVERRIDE; |
79 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter( | 78 virtual scoped_ptr<storage::FileStreamWriter> CreateFileStreamWriter( |
80 const fileapi::FileSystemURL& url, | 79 const storage::FileSystemURL& url, |
81 int64 offset, | 80 int64 offset, |
82 fileapi::FileSystemContext* context) const OVERRIDE; | 81 storage::FileSystemContext* context) const OVERRIDE; |
83 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | 82 virtual storage::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
84 | 83 |
85 private: | 84 private: |
86 // Store the profile path. We need this to create temporary snapshot files. | 85 // Store the profile path. We need this to create temporary snapshot files. |
87 const base::FilePath profile_path_; | 86 const base::FilePath profile_path_; |
88 | 87 |
89 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; | 88 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; |
90 | 89 |
91 scoped_ptr<MediaPathFilter> media_path_filter_; | 90 scoped_ptr<MediaPathFilter> media_path_filter_; |
92 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> | 91 scoped_ptr<storage::CopyOrMoveFileValidatorFactory> |
93 media_copy_or_move_file_validator_factory_; | 92 media_copy_or_move_file_validator_factory_; |
94 | 93 |
95 scoped_ptr<fileapi::AsyncFileUtil> native_media_file_util_; | 94 scoped_ptr<storage::AsyncFileUtil> native_media_file_util_; |
96 scoped_ptr<DeviceMediaAsyncFileUtil> device_media_async_file_util_; | 95 scoped_ptr<DeviceMediaAsyncFileUtil> device_media_async_file_util_; |
97 #if defined(OS_WIN) || defined(OS_MACOSX) | 96 #if defined(OS_WIN) || defined(OS_MACOSX) |
98 scoped_ptr<fileapi::AsyncFileUtil> picasa_file_util_; | 97 scoped_ptr<storage::AsyncFileUtil> picasa_file_util_; |
99 scoped_ptr<fileapi::AsyncFileUtil> itunes_file_util_; | 98 scoped_ptr<storage::AsyncFileUtil> itunes_file_util_; |
100 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 99 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
101 #if defined(OS_MACOSX) | 100 #if defined(OS_MACOSX) |
102 scoped_ptr<fileapi::AsyncFileUtil> iphoto_file_util_; | 101 scoped_ptr<storage::AsyncFileUtil> iphoto_file_util_; |
103 #endif // defined(OS_MACOSX) | 102 #endif // defined(OS_MACOSX) |
104 | 103 |
105 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemBackend); | 104 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemBackend); |
106 }; | 105 }; |
107 | 106 |
108 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ | 107 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_SYSTEM_BACKEND_H_ |
OLD | NEW |