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

Unified Diff: chrome/browser/media_galleries/linux/mtp_device_task_helper.cc

Issue 982283002: Implement DeleteFile and DeleteDirectory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DCHECK. Created 5 years, 9 months 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: chrome/browser/media_galleries/linux/mtp_device_task_helper.cc
diff --git a/chrome/browser/media_galleries/linux/mtp_device_task_helper.cc b/chrome/browser/media_galleries/linux/mtp_device_task_helper.cc
index 5fb766fd2e92e0c7d40094f83ff9b2c2ae26e20c..5cb586197d82771483eceeb40aee0fc38ff97209 100644
--- a/chrome/browser/media_galleries/linux/mtp_device_task_helper.cc
+++ b/chrome/browser/media_galleries/linux/mtp_device_task_helper.cc
@@ -109,6 +109,21 @@ void MTPDeviceTaskHelper::ReadDirectory(
error_callback));
}
+void MTPDeviceTaskHelper::ReadDirectoryEntryIds(
+ const uint32 directory_id,
+ const ReadDirectoryEntryIdsSuccessCallback& success_callback,
+ const ErrorCallback& error_callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (device_handle_.empty())
+ return HandleDeviceError(error_callback, base::File::FILE_ERROR_FAILED);
+
+ GetMediaTransferProtocolManager()->ReadDirectoryEntryIds(
+ device_handle_, directory_id,
+ base::Bind(&MTPDeviceTaskHelper::OnDidReadDirectoryEntryIds,
+ weak_ptr_factory_.GetWeakPtr(), success_callback,
+ error_callback));
+}
+
void MTPDeviceTaskHelper::WriteDataIntoSnapshotFile(
const SnapshotRequestInfo& request_info,
const base::File::Info& snapshot_file_info) {
@@ -138,6 +153,7 @@ void MTPDeviceTaskHelper::ReadBytes(
weak_ptr_factory_.GetWeakPtr(), request));
}
+// TODO(yawano) storage_name is not used, delete it.
void MTPDeviceTaskHelper::CopyFileFromLocal(
const std::string& storage_name,
const int source_file_descriptor,
@@ -154,6 +170,19 @@ void MTPDeviceTaskHelper::CopyFileFromLocal(
error_callback));
}
+void MTPDeviceTaskHelper::DeleteObject(
+ const uint32 object_id,
+ const DeleteObjectSuccessCallback& success_callback,
+ const ErrorCallback& error_callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ GetMediaTransferProtocolManager()->DeleteObject(
+ device_handle_, object_id,
+ base::Bind(&MTPDeviceTaskHelper::OnDeleteObject,
+ weak_ptr_factory_.GetWeakPtr(), success_callback,
+ error_callback));
+}
+
void MTPDeviceTaskHelper::CloseStorage() const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (device_handle_.empty())
@@ -222,6 +251,20 @@ void MTPDeviceTaskHelper::OnDidReadDirectory(
base::Bind(success_callback, entries, has_more));
}
+void MTPDeviceTaskHelper::OnDidReadDirectoryEntryIds(
+ const ReadDirectoryEntryIdsSuccessCallback& success_callback,
+ const ErrorCallback& error_callback,
+ const std::vector<uint32>& file_ids,
+ const bool error) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (error)
+ return HandleDeviceError(error_callback, base::File::FILE_ERROR_FAILED);
+
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(success_callback, file_ids));
+}
+
void MTPDeviceTaskHelper::OnGetFileInfoToReadBytes(
const MTPDeviceAsyncDelegate::ReadBytesRequest& request,
const MtpFileEntry& file_entry,
@@ -300,6 +343,22 @@ void MTPDeviceTaskHelper::OnCopyFileFromLocal(
base::Bind(success_callback));
}
+void MTPDeviceTaskHelper::OnDeleteObject(
+ const DeleteObjectSuccessCallback& success_callback,
+ const ErrorCallback& error_callback,
+ const bool error) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (error) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(error_callback, base::File::FILE_ERROR_FAILED));
+ return;
+ }
+
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(success_callback));
+}
+
void MTPDeviceTaskHelper::HandleDeviceError(
const ErrorCallback& error_callback,
base::File::Error error) const {

Powered by Google App Engine
This is Rietveld 408576698