Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: webkit/fileapi/media/device_media_file_util.cc

Issue 11358243: Redesigned and refactored ScopedMTPDeviceMapEntry, MTPDeviceMapService & MTPDeviceDelegate classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/media/device_media_file_util.cc
diff --git a/webkit/fileapi/media/device_media_file_util.cc b/webkit/fileapi/media/device_media_file_util.cc
index 6283bff5f4d449460a92c0507fa098bf3ade8ba8..bf7cd401f8b9098ab72893d592b087548cf93110 100644
--- a/webkit/fileapi/media/device_media_file_util.cc
+++ b/webkit/fileapi/media/device_media_file_util.cc
@@ -63,7 +63,9 @@ PlatformFileError DeviceMediaFileUtil::GetFileInfo(
const FileSystemURL& url,
PlatformFileInfo* file_info,
FilePath* platform_path) {
- DCHECK(context->mtp_device_delegate());
+ if (!context->mtp_device_delegate().get())
+ return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+
PlatformFileError error =
context->mtp_device_delegate()->GetFileInfo(url.path(), file_info);
if (error != base::PLATFORM_FILE_OK)
@@ -80,7 +82,10 @@ scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>
FileSystemOperationContext* context,
const FileSystemURL& url,
bool recursive) {
- DCHECK(context->mtp_device_delegate());
+ if (!context->mtp_device_delegate().get()) {
+ return scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>(
+ new FileSystemFileUtil::EmptyFileEnumerator());
+ }
return make_scoped_ptr(new FilteringFileEnumerator(
context->mtp_device_delegate()->CreateFileEnumerator(url.path(),
recursive),
@@ -113,7 +118,9 @@ PlatformFileError DeviceMediaFileUtil::Truncate(
bool DeviceMediaFileUtil::IsDirectoryEmpty(
FileSystemOperationContext* context,
const FileSystemURL& url) {
- DCHECK(context->mtp_device_delegate());
+ if (!context->mtp_device_delegate().get())
+ return false;
+
scoped_ptr<AbstractFileEnumerator> enumerator(
CreateFileEnumerator(context, url, false));
FilePath path;
@@ -161,7 +168,8 @@ base::PlatformFileError DeviceMediaFileUtil::CreateSnapshotFile(
DCHECK(file_info);
DCHECK(local_path);
DCHECK(snapshot_policy);
- DCHECK(context->mtp_device_delegate());
+ if (!context->mtp_device_delegate().get())
+ return base::PLATFORM_FILE_ERROR_NOT_FOUND;
// We return a temporary file as a snapshot.
*snapshot_policy = FileSystemFileUtil::kSnapshotFileTemporary;

Powered by Google App Engine
This is Rietveld 408576698