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

Unified Diff: chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.h

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_delegate_impl_linux.h
diff --git a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.h b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.h
index eba37039e8281803547dc683055d15a36210c374..58bf1712fa0f4ab9ecc440b76a7c8d19c9fe8e0b 100644
--- a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.h
+++ b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.h
@@ -64,6 +64,8 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
// Maps file paths to file info.
typedef std::map<base::FilePath, storage::DirectoryEntry> FileInfoCache;
+ typedef base::Closure DeleteObjectSuccessCallback;
+
// Should only be called by CreateMTPDeviceAsyncDelegate() factory call.
// Defer the device initializations until the first file operation request.
// Do all the initializations in EnsureInitAndRunTask() function.
@@ -92,12 +94,18 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) override;
- bool IsReadOnly() override;
+ bool IsReadOnly() const override;
void CopyFileFromLocal(
const base::FilePath& source_file_path,
const base::FilePath& device_file_path,
const CopyFileFromLocalSuccessCallback& success_callback,
const ErrorCallback& error_callback) override;
+ void DeleteFile(const base::FilePath& file_path,
+ const DeleteFileSuccessCallback& success_callback,
+ const ErrorCallback& error_callback) override;
+ void DeleteDirectory(const base::FilePath& file_path,
+ const DeleteDirectorySuccessCallback& success_callback,
+ const ErrorCallback& error_callback) override;
void CancelPendingTasksAndDeleteDelegate() override;
// The internal methods correspond to the similarly named methods above.
@@ -125,6 +133,29 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
const CopyFileFromLocalSuccessCallback& success_callback,
const ErrorCallback& error_callback,
const int source_file_descriptor);
+ virtual void DeleteFileInternal(
+ const base::FilePath& file_path,
+ const DeleteFileSuccessCallback& success_callback,
+ const ErrorCallback& error_callback,
+ const base::File::Info& file_info);
+ virtual void DeleteDirectoryInternal(
+ const base::FilePath& file_path,
+ const DeleteDirectorySuccessCallback& success_callback,
+ const ErrorCallback& error_callback,
+ const base::File::Info& file_info);
+
+ // Called when ReadDirectoryEntryIds succeeds.
+ virtual void OnDidReadDirectoryEntryIdsToDeleteDirectory(
+ const uint32 directory_id,
+ const DeleteDirectorySuccessCallback& success_callback,
+ const ErrorCallback& error_callback,
+ const std::vector<uint32>& file_ids);
+
+ // Calls DeleteObjectOnUIThread on UI thread.
+ virtual void RunDeleteObjectOnUIThread(
+ const uint32 object_id,
+ const DeleteObjectSuccessCallback& success_callback,
+ const ErrorCallback& error_callback);
// Ensures the device is initialized for communication.
// If the device is already initialized, call RunTask().
@@ -245,6 +276,14 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
const int source_file_descriptor,
base::File::Error error);
+ // Called when DeleteObject() succeeds.
+ void OnDidDeleteObject(const uint32 object_id,
+ const DeleteObjectSuccessCallback success_callback);
+
+ // Called when DeleteFileOrDirectory() fails.
+ void HandleDeleteFileOrDirectoryError(const ErrorCallback& error_callback,
+ base::File::Error error);
+
// Handles the device file |error| while operating on |file_id|.
// |error_callback| is invoked to notify the caller about the file error.
void HandleDeviceFileError(const ErrorCallback& error_callback,
@@ -265,6 +304,9 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
// and return true.
bool CachedPathToId(const base::FilePath& path, uint32* id) const;
+ // Evict the cache of |id|.
+ void EvictCachedPathToId(const uint32 id);
+
// MTP device initialization state.
InitializationState init_state_;

Powered by Google App Engine
This is Rietveld 408576698