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

Side by Side Diff: device/media_transfer_protocol/media_transfer_protocol_manager.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ 5 #ifndef DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_
6 #define DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ 6 #define DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 29 matching lines...) Expand all
40 typedef base::Callback<void(bool error)> CloseStorageCallback; 40 typedef base::Callback<void(bool error)> CloseStorageCallback;
41 41
42 // A callback to handle the result of ReadDirectory. 42 // A callback to handle the result of ReadDirectory.
43 // The first argument is a vector of file entries. 43 // The first argument is a vector of file entries.
44 // The second argument is true if there are more file entries. 44 // The second argument is true if there are more file entries.
45 // The third argument is true if there was an error. 45 // The third argument is true if there was an error.
46 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries, 46 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries,
47 bool has_more, 47 bool has_more,
48 bool error)> ReadDirectoryCallback; 48 bool error)> ReadDirectoryCallback;
49 49
50 // A callback to handle the result of ReadDirectoryEntryIds.
51 // The first argument is a vector of file ids.
52 // The second argument is true if there was an error.
53 typedef base::Callback<void(const std::vector<uint32>& file_ids, bool error)>
54 ReadDirectoryEntryIdsCallback;
55
50 // A callback to handle the result of ReadFileChunk. 56 // A callback to handle the result of ReadFileChunk.
51 // The first argument is a string containing the file data. 57 // The first argument is a string containing the file data.
52 // The second argument is true if there was an error. 58 // The second argument is true if there was an error.
53 typedef base::Callback<void(const std::string& data, 59 typedef base::Callback<void(const std::string& data,
54 bool error)> ReadFileCallback; 60 bool error)> ReadFileCallback;
55 61
56 // A callback to handle the result of GetFileInfo. 62 // A callback to handle the result of GetFileInfo.
57 // The first argument is a file entry. 63 // The first argument is a file entry.
58 // The second argument is true if there was an error. 64 // The second argument is true if there was an error.
59 typedef base::Callback<void(const MtpFileEntry& file_entry, 65 typedef base::Callback<void(const MtpFileEntry& file_entry,
60 bool error)> GetFileInfoCallback; 66 bool error)> GetFileInfoCallback;
61 67
62 // A callback to handle the result of CopyFileFromLocal. 68 // A callback to handle the result of CopyFileFromLocal.
63 // The first argument is true if there was an error. 69 // The first argument is true if there was an error.
64 typedef base::Callback<void(bool error)> CopyFileFromLocalCallback; 70 typedef base::Callback<void(bool error)> CopyFileFromLocalCallback;
65 71
72 // A callback to handle the result of DeleteObject.
73 // The first argument is true if there was an error.
74 typedef base::Callback<void(bool error)> DeleteObjectCallback;
75
66 // Implement this interface to be notified about MTP storage 76 // Implement this interface to be notified about MTP storage
67 // attachment / detachment events. 77 // attachment / detachment events.
68 class Observer { 78 class Observer {
69 public: 79 public:
70 virtual ~Observer() {} 80 virtual ~Observer() {}
71 81
72 // A function called after a MTP storage has been attached / detached. 82 // A function called after a MTP storage has been attached / detached.
73 virtual void StorageChanged(bool is_attached, 83 virtual void StorageChanged(bool is_attached,
74 const std::string& storage_name) = 0; 84 const std::string& storage_name) = 0;
75 }; 85 };
(...skipping 22 matching lines...) Expand all
98 // Close |storage_handle| and runs |callback|. 108 // Close |storage_handle| and runs |callback|.
99 virtual void CloseStorage(const std::string& storage_handle, 109 virtual void CloseStorage(const std::string& storage_handle,
100 const CloseStorageCallback& callback) = 0; 110 const CloseStorageCallback& callback) = 0;
101 111
102 // Reads directory entries from |file_id| on |storage_handle| and runs 112 // Reads directory entries from |file_id| on |storage_handle| and runs
103 // |callback|. 113 // |callback|.
104 virtual void ReadDirectory(const std::string& storage_handle, 114 virtual void ReadDirectory(const std::string& storage_handle,
105 uint32 file_id, 115 uint32 file_id,
106 const ReadDirectoryCallback& callback) = 0; 116 const ReadDirectoryCallback& callback) = 0;
107 117
118 // Reads directory entry ids from |file_id| on |storage_handle| and runs
119 // |callback|.
120 virtual void ReadDirectoryEntryIds(
121 const std::string& storage_handle,
122 const uint32 file_id,
123 const ReadDirectoryEntryIdsCallback& callback) = 0;
124
108 // Reads file data from |file_id| on |storage_handle| and runs |callback|. 125 // Reads file data from |file_id| on |storage_handle| and runs |callback|.
109 // Reads |count| bytes of data starting at |offset|. 126 // Reads |count| bytes of data starting at |offset|.
110 virtual void ReadFileChunk(const std::string& storage_handle, 127 virtual void ReadFileChunk(const std::string& storage_handle,
111 uint32 file_id, 128 uint32 file_id,
112 uint32 offset, 129 uint32 offset,
113 uint32 count, 130 uint32 count,
114 const ReadFileCallback& callback) = 0; 131 const ReadFileCallback& callback) = 0;
115 132
116 // Gets the file metadata for |file_id| on |storage_handle| and runs 133 // Gets the file metadata for |file_id| on |storage_handle| and runs
117 // |callback|. 134 // |callback|.
118 virtual void GetFileInfo(const std::string& storage_handle, 135 virtual void GetFileInfo(const std::string& storage_handle,
119 uint32 file_id, 136 uint32 file_id,
120 const GetFileInfoCallback& callback) = 0; 137 const GetFileInfoCallback& callback) = 0;
121 138
122 // Copies the file from |source_file_descriptor| to |file_name| on 139 // Copies the file from |source_file_descriptor| to |file_name| on
123 // |parent_id|. 140 // |parent_id|.
124 virtual void CopyFileFromLocal(const std::string& storage_handle, 141 virtual void CopyFileFromLocal(const std::string& storage_handle,
125 const int source_file_descriptor, 142 const int source_file_descriptor,
126 const uint32 parent_id, 143 const uint32 parent_id,
127 const std::string& file_name, 144 const std::string& file_name,
128 const CopyFileFromLocalCallback& callback) = 0; 145 const CopyFileFromLocalCallback& callback) = 0;
129 146
147 // Deletes |object_id|.
148 virtual void DeleteObject(const std::string& storage_handle,
149 const uint32 object_id,
150 const DeleteObjectCallback& callback) = 0;
151
130 // Creates and returns the global MediaTransferProtocolManager instance. 152 // Creates and returns the global MediaTransferProtocolManager instance.
131 // On Linux, |task_runner| specifies the task runner to process asynchronous 153 // On Linux, |task_runner| specifies the task runner to process asynchronous
132 // operations. 154 // operations.
133 // On ChromeOS, |task_runner| should just be set to NULL because ChromeOS 155 // On ChromeOS, |task_runner| should just be set to NULL because ChromeOS
134 // already has a dedicated message loop proxy. 156 // already has a dedicated message loop proxy.
135 static MediaTransferProtocolManager* Initialize( 157 static MediaTransferProtocolManager* Initialize(
136 scoped_refptr<base::SequencedTaskRunner> task_runner); 158 scoped_refptr<base::SequencedTaskRunner> task_runner);
137 }; 159 };
138 160
139 } // namespace device 161 } // namespace device
140 162
141 #endif // DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ 163 #endif // DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698