| Index: chrome/browser/media_galleries/fileapi/native_media_file_util.cc
|
| diff --git a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc
|
| index 38612399dde91e67f4be34b28a82ffe75dca177c..503fdbbbbdc1a50c6cbe7cd0fe971bd7df1924f3 100644
|
| --- a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc
|
| +++ b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc
|
| @@ -98,6 +98,40 @@ NativeMediaFileUtil::NativeMediaFileUtil() : weak_factory_(this) {
|
| NativeMediaFileUtil::~NativeMediaFileUtil() {
|
| }
|
|
|
| +// static
|
| +base::PlatformFileError NativeMediaFileUtil::IsMediaFile(
|
| + const base::FilePath& path) {
|
| + base::PlatformFile file_handle;
|
| + const int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
|
| + base::PlatformFileError error =
|
| + fileapi::NativeFileUtil::CreateOrOpen(path, flags, &file_handle, NULL);
|
| + if (error != base::PLATFORM_FILE_OK)
|
| + return error;
|
| +
|
| + ScopedPlatformFile scoped_platform_file(&file_handle);
|
| + char buffer[net::kMaxBytesToSniff];
|
| +
|
| + // Read as much as net::SniffMimeTypeFromLocalData() will bother looking at.
|
| + int64 len =
|
| + base::ReadPlatformFile(file_handle, 0, buffer, net::kMaxBytesToSniff);
|
| + if (len < 0)
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| + if (len == 0)
|
| + return base::PLATFORM_FILE_ERROR_SECURITY;
|
| +
|
| + std::string mime_type;
|
| + if (!net::SniffMimeTypeFromLocalData(buffer, len, &mime_type))
|
| + return base::PLATFORM_FILE_ERROR_SECURITY;
|
| +
|
| + if (StartsWithASCII(mime_type, "image/", true) ||
|
| + StartsWithASCII(mime_type, "audio/", true) ||
|
| + StartsWithASCII(mime_type, "video/", true) ||
|
| + mime_type == "application/x-shockwave-flash") {
|
| + return base::PLATFORM_FILE_OK;
|
| + }
|
| + return base::PLATFORM_FILE_ERROR_SECURITY;
|
| +}
|
| +
|
| bool NativeMediaFileUtil::CreateOrOpen(
|
| fileapi::FileSystemOperationContext* context,
|
| const fileapi::FileSystemURL& url,
|
| @@ -134,8 +168,8 @@ bool NativeMediaFileUtil::CreateDirectory(
|
| return context->task_runner()->PostTask(
|
| FROM_HERE,
|
| base::Bind(&NativeMediaFileUtil::CreateDirectoryOnTaskRunnerThread,
|
| - weak_factory_.GetWeakPtr(), context, url, exclusive,
|
| - recursive, callback));
|
| + weak_factory_.GetWeakPtr(), context, url, exclusive, recursive,
|
| + callback));
|
| }
|
|
|
| bool NativeMediaFileUtil::GetFileInfo(
|
| @@ -255,88 +289,133 @@ bool NativeMediaFileUtil::CreateSnapshotFile(
|
| weak_factory_.GetWeakPtr(), context, url, callback));
|
| }
|
|
|
| -base::PlatformFileError NativeMediaFileUtil::CreateDirectorySync(
|
| +void NativeMediaFileUtil::CreateDirectoryOnTaskRunnerThread(
|
| fileapi::FileSystemOperationContext* context,
|
| const fileapi::FileSystemURL& url,
|
| bool exclusive,
|
| - bool recursive) {
|
| - base::FilePath file_path;
|
| - base::PlatformFileError error = GetLocalFilePath(context, url, &file_path);
|
| - if (error != base::PLATFORM_FILE_OK)
|
| - return error;
|
| - return fileapi::NativeFileUtil::CreateDirectory(file_path, exclusive,
|
| - recursive);
|
| + bool recursive,
|
| + const StatusCallback& callback) {
|
| + DCHECK(IsOnTaskRunnerThread(context));
|
| + base::PlatformFileError error =
|
| + CreateDirectorySync(context, url, exclusive, recursive);
|
| + if (callback.is_null())
|
| + return;
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback, error));
|
| }
|
|
|
| -base::PlatformFileError NativeMediaFileUtil::GetLocalFilePath(
|
| +void NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(
|
| fileapi::FileSystemOperationContext* context,
|
| const fileapi::FileSystemURL& url,
|
| - base::FilePath* local_file_path) {
|
| - DCHECK(local_file_path);
|
| - DCHECK(url.is_valid());
|
| - if (url.path().empty()) {
|
| - // Root direcory case, which should not be accessed.
|
| - return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
|
| - }
|
| - *local_file_path = url.path();
|
| - return base::PLATFORM_FILE_OK;
|
| -}
|
| -
|
| -base::PlatformFileError NativeMediaFileUtil::ReadDirectorySync(
|
| - fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& url,
|
| - EntryList* file_list) {
|
| + const GetFileInfoCallback& callback) {
|
| DCHECK(IsOnTaskRunnerThread(context));
|
| - DCHECK(file_list);
|
| - DCHECK(file_list->empty());
|
| base::PlatformFileInfo file_info;
|
| base::FilePath platform_path;
|
| - base::PlatformFileError error = GetFileInfoSync(context, url, &file_info,
|
| - &platform_path);
|
| -
|
| - if (error != base::PLATFORM_FILE_OK)
|
| - return error;
|
| -
|
| - if (!file_info.is_directory)
|
| - return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
|
| -
|
| - file_util::FileEnumerator file_enum(
|
| - platform_path,
|
| - false /* recursive */,
|
| - file_util::FileEnumerator::FILES |
|
| - file_util::FileEnumerator::DIRECTORIES);
|
| - file_util::FileEnumerator::FindInfo file_util_info;
|
| -#if defined(OS_WIN)
|
| - memset(&file_util_info, 0, sizeof(file_util_info));
|
| -#endif // defined(OS_WIN)
|
| + base::PlatformFileError error =
|
| + GetFileInfoSync(context, url, &file_info, &platform_path);
|
| + if (callback.is_null())
|
| + return;
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback, error, file_info, platform_path));
|
| +}
|
|
|
| - for (base::FilePath platform_path = file_enum.Next();
|
| - !platform_path.empty();
|
| - platform_path = file_enum.Next()) {
|
| - // Skip symlinks.
|
| - if (file_util::IsLink(platform_path))
|
| - continue;
|
| +void NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(
|
| + fileapi::FileSystemOperationContext* context,
|
| + const fileapi::FileSystemURL& url,
|
| + const ReadDirectoryCallback& callback) {
|
| + DCHECK(IsOnTaskRunnerThread(context));
|
| + EntryList entry_list;
|
| + base::PlatformFileError error =
|
| + ReadDirectorySync(context, url, &entry_list);
|
| + if (callback.is_null())
|
| + return;
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback, error, entry_list, false /* has_more */));
|
| +}
|
|
|
| - file_enum.GetFindInfo(&file_util_info);
|
| +void NativeMediaFileUtil::CopyOrMoveFileLocalOnTaskRunnerThread(
|
| + fileapi::FileSystemOperationContext* context,
|
| + const fileapi::FileSystemURL& src_url,
|
| + const fileapi::FileSystemURL& dest_url,
|
| + bool copy,
|
| + const StatusCallback& callback) {
|
| + DCHECK(IsOnTaskRunnerThread(context));
|
| + base::PlatformFileError error =
|
| + CopyOrMoveFileSync(context, src_url, dest_url, copy);
|
| + if (callback.is_null())
|
| + return;
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback, error));
|
| +}
|
|
|
| - // NativeMediaFileUtil skip criteria.
|
| - if (ShouldSkip(platform_path))
|
| - continue;
|
| - if (!file_util::FileEnumerator::IsDirectory(file_util_info) &&
|
| - !GetMediaPathFilter(context)->Match(platform_path))
|
| - continue;
|
| +void NativeMediaFileUtil::CopyInForeignFileOnTaskRunnerThread(
|
| + fileapi::FileSystemOperationContext* context,
|
| + const base::FilePath& src_file_path,
|
| + const fileapi::FileSystemURL& dest_url,
|
| + const StatusCallback& callback) {
|
| + DCHECK(IsOnTaskRunnerThread(context));
|
| + base::PlatformFileError error =
|
| + CopyInForeignFileSync(context, src_file_path, dest_url);
|
| + if (callback.is_null())
|
| + return;
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback, error));
|
| +}
|
|
|
| - fileapi::DirectoryEntry entry;
|
| - entry.is_directory = file_util::FileEnumerator::IsDirectory(file_util_info);
|
| - entry.name = platform_path.BaseName().value();
|
| - entry.size = file_util::FileEnumerator::GetFilesize(file_util_info);
|
| - entry.last_modified_time =
|
| - file_util::FileEnumerator::GetLastModifiedTime(file_util_info);
|
| +void NativeMediaFileUtil::DeleteDirectoryOnTaskRunnerThread(
|
| + fileapi::FileSystemOperationContext* context,
|
| + const fileapi::FileSystemURL& url,
|
| + const StatusCallback& callback) {
|
| + DCHECK(IsOnTaskRunnerThread(context));
|
| + base::PlatformFileError error = DeleteDirectorySync(context, url);
|
| + if (callback.is_null())
|
| + return;
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback, error));
|
| +}
|
|
|
| - file_list->push_back(entry);
|
| - }
|
| +void NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread(
|
| + fileapi::FileSystemOperationContext* context,
|
| + const fileapi::FileSystemURL& url,
|
| + const CreateSnapshotFileCallback& callback) {
|
| + DCHECK(IsOnTaskRunnerThread(context));
|
| + base::PlatformFileInfo file_info;
|
| + base::FilePath platform_path;
|
| + scoped_refptr<webkit_blob::ShareableFileReference> file_ref;
|
| + base::PlatformFileError error =
|
| + CreateSnapshotFileSync(context, url, &file_info, &platform_path,
|
| + &file_ref);
|
| + if (callback.is_null())
|
| + return;
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback, error, file_info, platform_path, file_ref));
|
| +}
|
|
|
| - return base::PLATFORM_FILE_OK;
|
| +base::PlatformFileError NativeMediaFileUtil::CreateDirectorySync(
|
| + fileapi::FileSystemOperationContext* context,
|
| + const fileapi::FileSystemURL& url,
|
| + bool exclusive,
|
| + bool recursive) {
|
| + base::FilePath file_path;
|
| + base::PlatformFileError error = GetLocalFilePath(context, url, &file_path);
|
| + if (error != base::PLATFORM_FILE_OK)
|
| + return error;
|
| + return fileapi::NativeFileUtil::CreateDirectory(file_path, exclusive,
|
| + recursive);
|
| }
|
|
|
| base::PlatformFileError NativeMediaFileUtil::CopyOrMoveFileSync(
|
| @@ -391,23 +470,6 @@ base::PlatformFileError NativeMediaFileUtil::CopyInForeignFileSync(
|
| true);
|
| }
|
|
|
| -base::PlatformFileError NativeMediaFileUtil::GetFilteredLocalFilePath(
|
| - fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& file_system_url,
|
| - base::FilePath* local_file_path) {
|
| - DCHECK(IsOnTaskRunnerThread(context));
|
| - base::FilePath file_path;
|
| - base::PlatformFileError error =
|
| - GetLocalFilePath(context, file_system_url, &file_path);
|
| - if (error != base::PLATFORM_FILE_OK)
|
| - return error;
|
| - if (!GetMediaPathFilter(context)->Match(file_path))
|
| - return base::PLATFORM_FILE_ERROR_SECURITY;
|
| -
|
| - *local_file_path = file_path;
|
| - return base::PLATFORM_FILE_OK;
|
| -}
|
| -
|
| base::PlatformFileError NativeMediaFileUtil::GetFileInfoSync(
|
| fileapi::FileSystemOperationContext* context,
|
| const fileapi::FileSystemURL& url,
|
| @@ -437,31 +499,74 @@ base::PlatformFileError NativeMediaFileUtil::GetFileInfoSync(
|
| return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| }
|
|
|
| -base::PlatformFileError
|
| -NativeMediaFileUtil::GetFilteredLocalFilePathForExistingFileOrDirectory(
|
| +base::PlatformFileError NativeMediaFileUtil::GetLocalFilePath(
|
| fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& file_system_url,
|
| - base::PlatformFileError failure_error,
|
| + const fileapi::FileSystemURL& url,
|
| base::FilePath* local_file_path) {
|
| + DCHECK(local_file_path);
|
| + DCHECK(url.is_valid());
|
| + if (url.path().empty()) {
|
| + // Root direcory case, which should not be accessed.
|
| + return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
|
| + }
|
| + *local_file_path = url.path();
|
| + return base::PLATFORM_FILE_OK;
|
| +}
|
| +
|
| +base::PlatformFileError NativeMediaFileUtil::ReadDirectorySync(
|
| + fileapi::FileSystemOperationContext* context,
|
| + const fileapi::FileSystemURL& url,
|
| + EntryList* file_list) {
|
| DCHECK(IsOnTaskRunnerThread(context));
|
| - base::FilePath file_path;
|
| - base::PlatformFileError error =
|
| - GetLocalFilePath(context, file_system_url, &file_path);
|
| + DCHECK(file_list);
|
| + DCHECK(file_list->empty());
|
| + base::PlatformFileInfo file_info;
|
| + base::FilePath platform_path;
|
| + base::PlatformFileError error = GetFileInfoSync(context, url, &file_info,
|
| + &platform_path);
|
| +
|
| if (error != base::PLATFORM_FILE_OK)
|
| return error;
|
|
|
| - if (!file_util::PathExists(file_path))
|
| - return failure_error;
|
| - base::PlatformFileInfo file_info;
|
| - if (!file_util::GetFileInfo(file_path, &file_info))
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| + if (!file_info.is_directory)
|
| + return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
|
|
|
| - if (!file_info.is_directory &&
|
| - !GetMediaPathFilter(context)->Match(file_path)) {
|
| - return failure_error;
|
| + file_util::FileEnumerator file_enum(
|
| + platform_path,
|
| + false /* recursive */,
|
| + file_util::FileEnumerator::FILES |
|
| + file_util::FileEnumerator::DIRECTORIES);
|
| + file_util::FileEnumerator::FindInfo file_util_info;
|
| +#if defined(OS_WIN)
|
| + memset(&file_util_info, 0, sizeof(file_util_info));
|
| +#endif // defined(OS_WIN)
|
| +
|
| + for (base::FilePath platform_path = file_enum.Next();
|
| + !platform_path.empty();
|
| + platform_path = file_enum.Next()) {
|
| + // Skip symlinks.
|
| + if (file_util::IsLink(platform_path))
|
| + continue;
|
| +
|
| + file_enum.GetFindInfo(&file_util_info);
|
| +
|
| + // NativeMediaFileUtil skip criteria.
|
| + if (ShouldSkip(platform_path))
|
| + continue;
|
| + if (!file_util::FileEnumerator::IsDirectory(file_util_info) &&
|
| + !GetMediaPathFilter(context)->Match(platform_path))
|
| + continue;
|
| +
|
| + fileapi::DirectoryEntry entry;
|
| + entry.is_directory = file_util::FileEnumerator::IsDirectory(file_util_info);
|
| + entry.name = platform_path.BaseName().value();
|
| + entry.size = file_util::FileEnumerator::GetFilesize(file_util_info);
|
| + entry.last_modified_time =
|
| + file_util::FileEnumerator::GetLastModifiedTime(file_util_info);
|
| +
|
| + file_list->push_back(entry);
|
| }
|
|
|
| - *local_file_path = file_path;
|
| return base::PLATFORM_FILE_OK;
|
| }
|
|
|
| @@ -496,154 +601,49 @@ base::PlatformFileError NativeMediaFileUtil::CreateSnapshotFileSync(
|
| return error;
|
| }
|
|
|
| -// static
|
| -base::PlatformFileError NativeMediaFileUtil::IsMediaFile(
|
| - const base::FilePath& path) {
|
| - base::PlatformFile file_handle;
|
| - const int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
|
| +base::PlatformFileError NativeMediaFileUtil::GetFilteredLocalFilePath(
|
| + fileapi::FileSystemOperationContext* context,
|
| + const fileapi::FileSystemURL& file_system_url,
|
| + base::FilePath* local_file_path) {
|
| + DCHECK(IsOnTaskRunnerThread(context));
|
| + base::FilePath file_path;
|
| base::PlatformFileError error =
|
| - fileapi::NativeFileUtil::CreateOrOpen(path, flags, &file_handle, NULL);
|
| + GetLocalFilePath(context, file_system_url, &file_path);
|
| if (error != base::PLATFORM_FILE_OK)
|
| return error;
|
| -
|
| - ScopedPlatformFile scoped_platform_file(&file_handle);
|
| - char buffer[net::kMaxBytesToSniff];
|
| -
|
| - // Read as much as net::SniffMimeTypeFromLocalData() will bother looking at.
|
| - int64 len =
|
| - base::ReadPlatformFile(file_handle, 0, buffer, net::kMaxBytesToSniff);
|
| - if (len < 0)
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| - if (len == 0)
|
| - return base::PLATFORM_FILE_ERROR_SECURITY;
|
| -
|
| - std::string mime_type;
|
| - if (!net::SniffMimeTypeFromLocalData(buffer, len, &mime_type))
|
| + if (!GetMediaPathFilter(context)->Match(file_path))
|
| return base::PLATFORM_FILE_ERROR_SECURITY;
|
|
|
| - if (StartsWithASCII(mime_type, "image/", true) ||
|
| - StartsWithASCII(mime_type, "audio/", true) ||
|
| - StartsWithASCII(mime_type, "video/", true) ||
|
| - mime_type == "application/x-shockwave-flash") {
|
| - return base::PLATFORM_FILE_OK;
|
| - }
|
| - return base::PLATFORM_FILE_ERROR_SECURITY;
|
| + *local_file_path = file_path;
|
| + return base::PLATFORM_FILE_OK;
|
| }
|
|
|
| -void NativeMediaFileUtil::CreateDirectoryOnTaskRunnerThread(
|
| +base::PlatformFileError
|
| +NativeMediaFileUtil::GetFilteredLocalFilePathForExistingFileOrDirectory(
|
| fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& url,
|
| - bool exclusive,
|
| - bool recursive,
|
| - const StatusCallback& callback) {
|
| + const fileapi::FileSystemURL& file_system_url,
|
| + base::PlatformFileError failure_error,
|
| + base::FilePath* local_file_path) {
|
| DCHECK(IsOnTaskRunnerThread(context));
|
| + base::FilePath file_path;
|
| base::PlatformFileError error =
|
| - CreateDirectorySync(context, url, exclusive, recursive);
|
| - if (callback.is_null())
|
| - return;
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, error));
|
| -}
|
| + GetLocalFilePath(context, file_system_url, &file_path);
|
| + if (error != base::PLATFORM_FILE_OK)
|
| + return error;
|
|
|
| -void NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(
|
| - fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& url,
|
| - const GetFileInfoCallback& callback) {
|
| - DCHECK(IsOnTaskRunnerThread(context));
|
| + if (!file_util::PathExists(file_path))
|
| + return failure_error;
|
| base::PlatformFileInfo file_info;
|
| - base::FilePath platform_path;
|
| - base::PlatformFileError error =
|
| - GetFileInfoSync(context, url, &file_info, &platform_path);
|
| - if (callback.is_null())
|
| - return;
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, error, file_info, platform_path));
|
| -}
|
| -
|
| -void NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(
|
| - fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& url,
|
| - const ReadDirectoryCallback& callback) {
|
| - DCHECK(IsOnTaskRunnerThread(context));
|
| - EntryList entry_list;
|
| - base::PlatformFileError error =
|
| - ReadDirectorySync(context, url, &entry_list);
|
| - if (callback.is_null())
|
| - return;
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, error, entry_list, false /* has_more */));
|
| -}
|
| -
|
| -void NativeMediaFileUtil::CopyOrMoveFileLocalOnTaskRunnerThread(
|
| - fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& src_url,
|
| - const fileapi::FileSystemURL& dest_url,
|
| - bool copy,
|
| - const StatusCallback& callback) {
|
| - DCHECK(IsOnTaskRunnerThread(context));
|
| - base::PlatformFileError error =
|
| - CopyOrMoveFileSync(context, src_url, dest_url, copy);
|
| - if (callback.is_null())
|
| - return;
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, error));
|
| -}
|
| -
|
| -void NativeMediaFileUtil::CopyInForeignFileOnTaskRunnerThread(
|
| - fileapi::FileSystemOperationContext* context,
|
| - const base::FilePath& src_file_path,
|
| - const fileapi::FileSystemURL& dest_url,
|
| - const StatusCallback& callback) {
|
| - DCHECK(IsOnTaskRunnerThread(context));
|
| - base::PlatformFileError error =
|
| - CopyInForeignFileSync(context, src_file_path, dest_url);
|
| - if (callback.is_null())
|
| - return;
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, error));
|
| -}
|
| + if (!file_util::GetFileInfo(file_path, &file_info))
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
|
|
| -void NativeMediaFileUtil::DeleteDirectoryOnTaskRunnerThread(
|
| - fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& url,
|
| - const StatusCallback& callback) {
|
| - DCHECK(IsOnTaskRunnerThread(context));
|
| - base::PlatformFileError error = DeleteDirectorySync(context, url);
|
| - if (callback.is_null())
|
| - return;
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, error));
|
| -}
|
| + if (!file_info.is_directory &&
|
| + !GetMediaPathFilter(context)->Match(file_path)) {
|
| + return failure_error;
|
| + }
|
|
|
| -void NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread(
|
| - fileapi::FileSystemOperationContext* context,
|
| - const fileapi::FileSystemURL& url,
|
| - const CreateSnapshotFileCallback& callback) {
|
| - DCHECK(IsOnTaskRunnerThread(context));
|
| - base::PlatformFileInfo file_info;
|
| - base::FilePath platform_path;
|
| - scoped_refptr<webkit_blob::ShareableFileReference> file_ref;
|
| - base::PlatformFileError error =
|
| - CreateSnapshotFileSync(context, url, &file_info, &platform_path,
|
| - &file_ref);
|
| - if (callback.is_null())
|
| - return;
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, error, file_info, platform_path, file_ref));
|
| + *local_file_path = file_path;
|
| + return base::PLATFORM_FILE_OK;
|
| }
|
|
|
| } // namespace chrome
|
|
|