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

Side by Side Diff: device/media_transfer_protocol/media_transfer_protocol_daemon_client.h

Issue 947943002: Implement CopyFileFromLocal of MTPDeviceAsyncDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. 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 // Client code to talk to the Media Transfer Protocol daemon. The MTP daemon is 5 // Client code to talk to the Media Transfer Protocol daemon. The MTP daemon is
6 // responsible for communicating with PTP / MTP capable devices like cameras 6 // responsible for communicating with PTP / MTP capable devices like cameras
7 // and smartphones. 7 // and smartphones.
8 8
9 #ifndef DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_ 9 #ifndef DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_
10 #define DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_ 10 #define DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 // A callback to handle the result of GetFileInfo. 62 // A callback to handle the result of GetFileInfo.
63 // The argument is a vector of file entries. 63 // The argument is a vector of file entries.
64 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries) 64 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries)
65 > GetFileInfoCallback; 65 > GetFileInfoCallback;
66 66
67 // A callback to handle the result of ReadFileChunkById. 67 // A callback to handle the result of ReadFileChunkById.
68 // The argument is a string containing the file data. 68 // The argument is a string containing the file data.
69 typedef base::Callback<void(const std::string& data)> ReadFileCallback; 69 typedef base::Callback<void(const std::string& data)> ReadFileCallback;
70 70
71 // A callback to handle the result of CopyFileFromLocal.
72 typedef base::Closure CopyFileFromLocalCallback;
73
71 // A callback to handle storage attach/detach events. 74 // A callback to handle storage attach/detach events.
72 // The first argument is true for attach, false for detach. 75 // The first argument is true for attach, false for detach.
73 // The second argument is the storage name. 76 // The second argument is the storage name.
74 typedef base::Callback<void(bool is_attach, 77 typedef base::Callback<void(bool is_attach,
75 const std::string& storage_name) 78 const std::string& storage_name)
76 > MTPStorageEventHandler; 79 > MTPStorageEventHandler;
77 80
78 virtual ~MediaTransferProtocolDaemonClient(); 81 virtual ~MediaTransferProtocolDaemonClient();
79 82
80 // Calls EnumerateStorages method. |callback| is called after the 83 // Calls EnumerateStorages method. |callback| is called after the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // |file_id| is a MTP-device specific id for a file. 133 // |file_id| is a MTP-device specific id for a file.
131 // |offset| is the offset into the file. 134 // |offset| is the offset into the file.
132 // |bytes_to_read| cannot exceed 1 MiB. 135 // |bytes_to_read| cannot exceed 1 MiB.
133 virtual void ReadFileChunk(const std::string& handle, 136 virtual void ReadFileChunk(const std::string& handle,
134 uint32 file_id, 137 uint32 file_id,
135 uint32 offset, 138 uint32 offset,
136 uint32 bytes_to_read, 139 uint32 bytes_to_read,
137 const ReadFileCallback& callback, 140 const ReadFileCallback& callback,
138 const ErrorCallback& error_callback) = 0; 141 const ErrorCallback& error_callback) = 0;
139 142
143 // Calls CopyFileFromLocal method. |callback| is called after the method call
144 // succeeds, otherwise, |error_callback| is called.
145 // |source_file_descriptor| is a file descriptor of source file.
146 // |parent_id| is a object id of a target directory.
147 // |file_name| is a file name of a target file.
148 virtual void CopyFileFromLocal(const std::string& handle,
149 const int source_file_descriptor,
150 const uint32 parent_id,
151 const std::string& file_name,
152 const CopyFileFromLocalCallback& callback,
153 const ErrorCallback& error_callback) = 0;
154
140 // Registers given callback for events. Should only be called once. 155 // Registers given callback for events. Should only be called once.
141 // |storage_event_handler| is called when a mtp storage attach or detach 156 // |storage_event_handler| is called when a mtp storage attach or detach
142 // signal is received. 157 // signal is received.
143 virtual void ListenForChanges(const MTPStorageEventHandler& handler) = 0; 158 virtual void ListenForChanges(const MTPStorageEventHandler& handler) = 0;
144 159
145 // Factory function, creates a new instance and returns ownership. 160 // Factory function, creates a new instance and returns ownership.
146 static MediaTransferProtocolDaemonClient* Create(dbus::Bus* bus); 161 static MediaTransferProtocolDaemonClient* Create(dbus::Bus* bus);
147 162
148 protected: 163 protected:
149 // Create() should be used instead. 164 // Create() should be used instead.
150 MediaTransferProtocolDaemonClient(); 165 MediaTransferProtocolDaemonClient();
151 166
152 private: 167 private:
153 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDaemonClient); 168 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDaemonClient);
154 }; 169 };
155 170
156 } // namespace device 171 } // namespace device
157 172
158 #endif // DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_ H_ 173 #endif // DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698