| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/fileapi/media/native_media_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" |
| 6 | 6 |
| 7 #include "chrome/browser/media_galleries/fileapi/filtering_file_enumerator.h" |
| 8 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p
rovider.h" |
| 9 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 7 #include "webkit/fileapi/file_system_operation_context.h" | 10 #include "webkit/fileapi/file_system_operation_context.h" |
| 8 #include "webkit/fileapi/media/filtering_file_enumerator.h" | |
| 9 #include "webkit/fileapi/media/media_file_system_mount_point_provider.h" | |
| 10 #include "webkit/fileapi/media/media_path_filter.h" | |
| 11 #include "webkit/fileapi/native_file_util.h" | 11 #include "webkit/fileapi/native_file_util.h" |
| 12 | 12 |
| 13 using base::PlatformFile; | 13 using base::PlatformFile; |
| 14 using base::PlatformFileError; | 14 using base::PlatformFileError; |
| 15 using base::PlatformFileInfo; | 15 using base::PlatformFileInfo; |
| 16 using fileapi::FileSystemOperationContext; |
| 17 using fileapi::FileSystemURL; |
| 18 using fileapi::NativeFileUtil; |
| 16 | 19 |
| 17 namespace fileapi { | 20 namespace chrome { |
| 18 | 21 |
| 19 namespace { | 22 namespace { |
| 20 | 23 |
| 21 MediaPathFilter* GetMediaPathFilter(FileSystemOperationContext* context) { | 24 MediaPathFilter* GetMediaPathFilter(FileSystemOperationContext* context) { |
| 22 return context->GetUserValue<MediaPathFilter*>( | 25 return context->GetUserValue<MediaPathFilter*>( |
| 23 MediaFileSystemMountPointProvider::kMediaPathFilterKey); | 26 MediaFileSystemMountPointProvider::kMediaPathFilterKey); |
| 24 } | 27 } |
| 25 | 28 |
| 26 } // namespace | 29 } // namespace |
| 27 | 30 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 41 PlatformFileError NativeMediaFileUtil::EnsureFileExists( | 44 PlatformFileError NativeMediaFileUtil::EnsureFileExists( |
| 42 FileSystemOperationContext* context, | 45 FileSystemOperationContext* context, |
| 43 const FileSystemURL& url, bool* created) { | 46 const FileSystemURL& url, bool* created) { |
| 44 base::FilePath file_path; | 47 base::FilePath file_path; |
| 45 PlatformFileError error = GetFilteredLocalFilePath(context, url, &file_path); | 48 PlatformFileError error = GetFilteredLocalFilePath(context, url, &file_path); |
| 46 if (error != base::PLATFORM_FILE_OK) | 49 if (error != base::PLATFORM_FILE_OK) |
| 47 return error; | 50 return error; |
| 48 return NativeFileUtil::EnsureFileExists(file_path, created); | 51 return NativeFileUtil::EnsureFileExists(file_path, created); |
| 49 } | 52 } |
| 50 | 53 |
| 51 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 54 scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator> |
| 52 NativeMediaFileUtil::CreateFileEnumerator( | 55 NativeMediaFileUtil::CreateFileEnumerator( |
| 53 FileSystemOperationContext* context, | 56 FileSystemOperationContext* context, |
| 54 const FileSystemURL& root_url) { | 57 const FileSystemURL& root_url) { |
| 55 DCHECK(context); | 58 DCHECK(context); |
| 56 return make_scoped_ptr(new FilteringFileEnumerator( | 59 return make_scoped_ptr(new FilteringFileEnumerator( |
| 57 IsolatedFileUtil::CreateFileEnumerator(context, root_url), | 60 IsolatedFileUtil::CreateFileEnumerator(context, root_url), |
| 58 GetMediaPathFilter(context))) | 61 GetMediaPathFilter(context))) |
| 59 .PassAs<FileSystemFileUtil::AbstractFileEnumerator>(); | 62 .PassAs<FileSystemFileUtil::AbstractFileEnumerator>(); |
| 60 } | 63 } |
| 61 | 64 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 219 |
| 217 if (!file_info.is_directory && | 220 if (!file_info.is_directory && |
| 218 !GetMediaPathFilter(context)->Match(file_path)) { | 221 !GetMediaPathFilter(context)->Match(file_path)) { |
| 219 return failure_error; | 222 return failure_error; |
| 220 } | 223 } |
| 221 | 224 |
| 222 *local_file_path = file_path; | 225 *local_file_path = file_path; |
| 223 return base::PLATFORM_FILE_OK; | 226 return base::PLATFORM_FILE_OK; |
| 224 } | 227 } |
| 225 | 228 |
| 226 } // namespace fileapi | 229 } // namespace chrome |
| OLD | NEW |