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

Side by Side Diff: chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h

Issue 982283002: Implement DeleteFile and DeleteDirectory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit_tests. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 scoped_refptr<net::IOBuffer> buf; 59 scoped_refptr<net::IOBuffer> buf;
60 int64 offset; 60 int64 offset;
61 int buf_len; 61 int buf_len;
62 ReadBytesSuccessCallback success_callback; 62 ReadBytesSuccessCallback success_callback;
63 ErrorCallback error_callback; 63 ErrorCallback error_callback;
64 }; 64 };
65 65
66 // A callback to be called when CopyFileFromLocal method call succeeds. 66 // A callback to be called when CopyFileFromLocal method call succeeds.
67 typedef base::Closure CopyFileFromLocalSuccessCallback; 67 typedef base::Closure CopyFileFromLocalSuccessCallback;
68 68
69 // A callback to be called when DeleteFile method call succeeds.
70 typedef base::Closure DeleteFileSuccessCallback;
71
72 // A callback to be called when DeleteDirectory method call succeeds.
73 typedef base::Closure DeleteDirectorySuccessCallback;
74
69 // Gets information about the given |file_path| and invokes the appropriate 75 // Gets information about the given |file_path| and invokes the appropriate
70 // callback asynchronously when complete. 76 // callback asynchronously when complete.
71 virtual void GetFileInfo( 77 virtual void GetFileInfo(
72 const base::FilePath& file_path, 78 const base::FilePath& file_path,
73 const GetFileInfoSuccessCallback& success_callback, 79 const GetFileInfoSuccessCallback& success_callback,
74 const ErrorCallback& error_callback) = 0; 80 const ErrorCallback& error_callback) = 0;
75 81
76 // Enumerates the |root| directory contents and invokes the appropriate 82 // Enumerates the |root| directory contents and invokes the appropriate
77 // callback asynchronously when complete. 83 // callback asynchronously when complete.
78 virtual void ReadDirectory( 84 virtual void ReadDirectory(
(...skipping 17 matching lines...) Expand all
96 // appropriate callback asynchronously when complete. Only valid when 102 // appropriate callback asynchronously when complete. Only valid when
97 // IsStreaming() is true. 103 // IsStreaming() is true.
98 virtual void ReadBytes(const base::FilePath& device_file_path, 104 virtual void ReadBytes(const base::FilePath& device_file_path,
99 const scoped_refptr<net::IOBuffer>& buf, 105 const scoped_refptr<net::IOBuffer>& buf,
100 int64 offset, 106 int64 offset,
101 int buf_len, 107 int buf_len,
102 const ReadBytesSuccessCallback& success_callback, 108 const ReadBytesSuccessCallback& success_callback,
103 const ErrorCallback& error_callback) = 0; 109 const ErrorCallback& error_callback) = 0;
104 110
105 // Returns true if storage is opened for read only. 111 // Returns true if storage is opened for read only.
106 virtual bool IsReadOnly() = 0; 112 virtual bool IsReadOnly() const = 0;
107 113
108 // Copies a file from |source_file_path| to |device_file_path|. 114 // Copies a file from |source_file_path| to |device_file_path|.
109 virtual void CopyFileFromLocal( 115 virtual void CopyFileFromLocal(
110 const base::FilePath& source_file_path, 116 const base::FilePath& source_file_path,
111 const base::FilePath& device_file_path, 117 const base::FilePath& device_file_path,
112 const CopyFileFromLocalSuccessCallback& success_callback, 118 const CopyFileFromLocalSuccessCallback& success_callback,
113 const ErrorCallback& error_callback) = 0; 119 const ErrorCallback& error_callback) = 0;
114 120
121 // Deletes a file at |file_path|.
122 virtual void DeleteFile(const base::FilePath& file_path,
123 const DeleteFileSuccessCallback& success_callback,
124 const ErrorCallback& error_callback) = 0;
125
126 // Deletes a directory at |file_path|. The directory must be empty.
127 virtual void DeleteDirectory(
128 const base::FilePath& file_path,
129 const DeleteDirectorySuccessCallback& success_callback,
130 const ErrorCallback& error_callback) = 0;
131
115 // Called when the 132 // Called when the
116 // (1) Browser application is in shutdown mode (or) 133 // (1) Browser application is in shutdown mode (or)
117 // (2) Last extension using this MTP device is destroyed (or) 134 // (2) Last extension using this MTP device is destroyed (or)
118 // (3) Attached MTP device is removed (or) 135 // (3) Attached MTP device is removed (or)
119 // (4) User revoked the MTP device gallery permission. 136 // (4) User revoked the MTP device gallery permission.
120 // Ownership of |MTPDeviceAsyncDelegate| is handed off to the delegate 137 // Ownership of |MTPDeviceAsyncDelegate| is handed off to the delegate
121 // implementation class by this call. This function should take care of 138 // implementation class by this call. This function should take care of
122 // cancelling all the pending tasks before deleting itself. 139 // cancelling all the pending tasks before deleting itself.
123 virtual void CancelPendingTasksAndDeleteDelegate() = 0; 140 virtual void CancelPendingTasksAndDeleteDelegate() = 0;
124 141
125 protected: 142 protected:
126 // Always destruct this object via CancelPendingTasksAndDeleteDelegate(). 143 // Always destruct this object via CancelPendingTasksAndDeleteDelegate().
127 virtual ~MTPDeviceAsyncDelegate() {} 144 virtual ~MTPDeviceAsyncDelegate() {}
128 }; 145 };
129 146
130 typedef base::Callback<void(MTPDeviceAsyncDelegate*)> 147 typedef base::Callback<void(MTPDeviceAsyncDelegate*)>
131 CreateMTPDeviceAsyncDelegateCallback; 148 CreateMTPDeviceAsyncDelegateCallback;
132 149
133 void CreateMTPDeviceAsyncDelegate( 150 void CreateMTPDeviceAsyncDelegate(
134 const base::FilePath::StringType& device_location, 151 const base::FilePath::StringType& device_location,
135 const bool read_only, 152 const bool read_only,
136 const CreateMTPDeviceAsyncDelegateCallback& callback); 153 const CreateMTPDeviceAsyncDelegateCallback& callback);
137 154
138 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ 155 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698