| 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 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 5 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 const GURL& origin_url, | 112 const GURL& origin_url, |
| 113 fileapi::FileSystemType type, | 113 fileapi::FileSystemType type, |
| 114 fileapi::OpenFileSystemMode mode, | 114 fileapi::OpenFileSystemMode mode, |
| 115 const OpenFileSystemCallback& callback) { | 115 const OpenFileSystemCallback& callback) { |
| 116 // We never allow opening a new isolated FileSystem via usual OpenFileSystem. | 116 // We never allow opening a new isolated FileSystem via usual OpenFileSystem. |
| 117 base::MessageLoopProxy::current()->PostTask( | 117 base::MessageLoopProxy::current()->PostTask( |
| 118 FROM_HERE, | 118 FROM_HERE, |
| 119 base::Bind(callback, | 119 base::Bind(callback, |
| 120 GetFileSystemRootURI(origin_url, type), | 120 GetFileSystemRootURI(origin_url, type), |
| 121 GetFileSystemName(origin_url, type), | 121 GetFileSystemName(origin_url, type), |
| 122 base::PLATFORM_FILE_ERROR_SECURITY)); | 122 base::File::FILE_ERROR_SECURITY)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 fileapi::AsyncFileUtil* MediaFileSystemBackend::GetAsyncFileUtil( | 125 fileapi::AsyncFileUtil* MediaFileSystemBackend::GetAsyncFileUtil( |
| 126 fileapi::FileSystemType type) { | 126 fileapi::FileSystemType type) { |
| 127 switch (type) { | 127 switch (type) { |
| 128 case fileapi::kFileSystemTypeNativeMedia: | 128 case fileapi::kFileSystemTypeNativeMedia: |
| 129 return native_media_file_util_.get(); | 129 return native_media_file_util_.get(); |
| 130 case fileapi::kFileSystemTypeDeviceMedia: | 130 case fileapi::kFileSystemTypeDeviceMedia: |
| 131 return device_media_async_file_util_.get(); | 131 return device_media_async_file_util_.get(); |
| 132 #if defined(OS_WIN) || defined(OS_MACOSX) | 132 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 133 case fileapi::kFileSystemTypeItunes: | 133 case fileapi::kFileSystemTypeItunes: |
| 134 return itunes_file_util_.get(); | 134 return itunes_file_util_.get(); |
| 135 case fileapi::kFileSystemTypePicasa: | 135 case fileapi::kFileSystemTypePicasa: |
| 136 return picasa_file_util_.get(); | 136 return picasa_file_util_.get(); |
| 137 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 137 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 138 #if defined(OS_MACOSX) | 138 #if defined(OS_MACOSX) |
| 139 case fileapi::kFileSystemTypeIphoto: | 139 case fileapi::kFileSystemTypeIphoto: |
| 140 return iphoto_file_util_.get(); | 140 return iphoto_file_util_.get(); |
| 141 #endif // defined(OS_MACOSX) | 141 #endif // defined(OS_MACOSX) |
| 142 default: | 142 default: |
| 143 NOTREACHED(); | 143 NOTREACHED(); |
| 144 } | 144 } |
| 145 return NULL; | 145 return NULL; |
| 146 } | 146 } |
| 147 | 147 |
| 148 fileapi::CopyOrMoveFileValidatorFactory* | 148 fileapi::CopyOrMoveFileValidatorFactory* |
| 149 MediaFileSystemBackend::GetCopyOrMoveFileValidatorFactory( | 149 MediaFileSystemBackend::GetCopyOrMoveFileValidatorFactory( |
| 150 fileapi::FileSystemType type, base::PlatformFileError* error_code) { | 150 fileapi::FileSystemType type, base::File::Error* error_code) { |
| 151 DCHECK(error_code); | 151 DCHECK(error_code); |
| 152 *error_code = base::PLATFORM_FILE_OK; | 152 *error_code = base::File::FILE_OK; |
| 153 switch (type) { | 153 switch (type) { |
| 154 case fileapi::kFileSystemTypeNativeMedia: | 154 case fileapi::kFileSystemTypeNativeMedia: |
| 155 case fileapi::kFileSystemTypeDeviceMedia: | 155 case fileapi::kFileSystemTypeDeviceMedia: |
| 156 case fileapi::kFileSystemTypeIphoto: | 156 case fileapi::kFileSystemTypeIphoto: |
| 157 case fileapi::kFileSystemTypeItunes: | 157 case fileapi::kFileSystemTypeItunes: |
| 158 if (!media_copy_or_move_file_validator_factory_) { | 158 if (!media_copy_or_move_file_validator_factory_) { |
| 159 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; | 159 *error_code = base::File::FILE_ERROR_SECURITY; |
| 160 return NULL; | 160 return NULL; |
| 161 } | 161 } |
| 162 return media_copy_or_move_file_validator_factory_.get(); | 162 return media_copy_or_move_file_validator_factory_.get(); |
| 163 default: | 163 default: |
| 164 NOTREACHED(); | 164 NOTREACHED(); |
| 165 } | 165 } |
| 166 return NULL; | 166 return NULL; |
| 167 } | 167 } |
| 168 | 168 |
| 169 fileapi::FileSystemOperation* | 169 fileapi::FileSystemOperation* |
| 170 MediaFileSystemBackend::CreateFileSystemOperation( | 170 MediaFileSystemBackend::CreateFileSystemOperation( |
| 171 const FileSystemURL& url, | 171 const FileSystemURL& url, |
| 172 FileSystemContext* context, | 172 FileSystemContext* context, |
| 173 base::PlatformFileError* error_code) const { | 173 base::File::Error* error_code) const { |
| 174 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( | 174 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( |
| 175 new fileapi::FileSystemOperationContext( | 175 new fileapi::FileSystemOperationContext( |
| 176 context, media_task_runner_.get())); | 176 context, media_task_runner_.get())); |
| 177 return fileapi::FileSystemOperation::Create( | 177 return fileapi::FileSystemOperation::Create( |
| 178 url, context, operation_context.Pass()); | 178 url, context, operation_context.Pass()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 scoped_ptr<webkit_blob::FileStreamReader> | 181 scoped_ptr<webkit_blob::FileStreamReader> |
| 182 MediaFileSystemBackend::CreateFileStreamReader( | 182 MediaFileSystemBackend::CreateFileStreamReader( |
| 183 const FileSystemURL& url, | 183 const FileSystemURL& url, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 208 fileapi::FileStreamWriter::CreateForLocalFile( | 208 fileapi::FileStreamWriter::CreateForLocalFile( |
| 209 context->default_file_task_runner(), | 209 context->default_file_task_runner(), |
| 210 url.path(), offset)); | 210 url.path(), offset)); |
| 211 } | 211 } |
| 212 | 212 |
| 213 fileapi::FileSystemQuotaUtil* | 213 fileapi::FileSystemQuotaUtil* |
| 214 MediaFileSystemBackend::GetQuotaUtil() { | 214 MediaFileSystemBackend::GetQuotaUtil() { |
| 215 // No quota support. | 215 // No quota support. |
| 216 return NULL; | 216 return NULL; |
| 217 } | 217 } |
| OLD | NEW |