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

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

Issue 1007173003: Implement MoveFileLocal (with rename operation). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include "device/media_transfer_protocol/media_transfer_protocol_daemon_client.h " 5 #include "device/media_transfer_protocol/media_transfer_protocol_daemon_client.h "
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 writer.AppendUint32(offset); 164 writer.AppendUint32(offset);
165 writer.AppendUint32(bytes_to_read); 165 writer.AppendUint32(bytes_to_read);
166 proxy_->CallMethod( 166 proxy_->CallMethod(
167 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 167 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
168 base::Bind(&MediaTransferProtocolDaemonClientImpl::OnReadFile, 168 base::Bind(&MediaTransferProtocolDaemonClientImpl::OnReadFile,
169 weak_ptr_factory_.GetWeakPtr(), 169 weak_ptr_factory_.GetWeakPtr(),
170 callback, 170 callback,
171 error_callback)); 171 error_callback));
172 } 172 }
173 173
174 void RenameObject(const std::string& handle,
175 const uint32 object_id,
176 const std::string& new_name,
177 const RenameObjectCallback& callback,
178 const ErrorCallback& error_callback) override {
179 dbus::MethodCall method_call(mtpd::kMtpdInterface, mtpd::kRenameObject);
180 dbus::MessageWriter writer(&method_call);
181 writer.AppendString(handle);
182 writer.AppendUint32(object_id);
183 writer.AppendString(new_name);
184 proxy_->CallMethod(
185 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
186 base::Bind(&MediaTransferProtocolDaemonClientImpl::OnRenameObject,
187 weak_ptr_factory_.GetWeakPtr(), callback, error_callback));
188 }
189
174 void CopyFileFromLocal(const std::string& handle, 190 void CopyFileFromLocal(const std::string& handle,
175 const int source_file_descriptor, 191 const int source_file_descriptor,
176 const uint32 parent_id, 192 const uint32 parent_id,
177 const std::string& file_name, 193 const std::string& file_name,
178 const CopyFileFromLocalCallback& callback, 194 const CopyFileFromLocalCallback& callback,
179 const ErrorCallback& error_callback) override { 195 const ErrorCallback& error_callback) override {
180 dbus::FileDescriptor file_descriptor(source_file_descriptor); 196 dbus::FileDescriptor file_descriptor(source_file_descriptor);
181 file_descriptor.CheckValidity(); 197 file_descriptor.CheckValidity();
182 198
183 dbus::MethodCall method_call(mtpd::kMtpdInterface, 199 dbus::MethodCall method_call(mtpd::kMtpdInterface,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 size_t data_length = 0; 394 size_t data_length = 0;
379 dbus::MessageReader reader(response); 395 dbus::MessageReader reader(response);
380 if (!reader.PopArrayOfBytes(&data_bytes, &data_length)) { 396 if (!reader.PopArrayOfBytes(&data_bytes, &data_length)) {
381 error_callback.Run(); 397 error_callback.Run();
382 return; 398 return;
383 } 399 }
384 std::string data(reinterpret_cast<const char*>(data_bytes), data_length); 400 std::string data(reinterpret_cast<const char*>(data_bytes), data_length);
385 callback.Run(data); 401 callback.Run(data);
386 } 402 }
387 403
404 void OnRenameObject(const RenameObjectCallback& callback,
405 const ErrorCallback& error_callback,
406 dbus::Response* response) {
407 if (!response) {
408 error_callback.Run();
409 return;
410 }
411
412 callback.Run();
413 }
414
388 void OnCopyFileFromLocal(const CopyFileFromLocalCallback& callback, 415 void OnCopyFileFromLocal(const CopyFileFromLocalCallback& callback,
389 const ErrorCallback& error_callback, 416 const ErrorCallback& error_callback,
390 dbus::Response* response) { 417 dbus::Response* response) {
391 if (!response) { 418 if (!response) {
392 error_callback.Run(); 419 error_callback.Run();
393 return; 420 return;
394 } 421 }
395 422
396 callback.Run(); 423 callback.Run();
397 } 424 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 477
451 MediaTransferProtocolDaemonClient::~MediaTransferProtocolDaemonClient() {} 478 MediaTransferProtocolDaemonClient::~MediaTransferProtocolDaemonClient() {}
452 479
453 // static 480 // static
454 MediaTransferProtocolDaemonClient* MediaTransferProtocolDaemonClient::Create( 481 MediaTransferProtocolDaemonClient* MediaTransferProtocolDaemonClient::Create(
455 dbus::Bus* bus) { 482 dbus::Bus* bus) {
456 return new MediaTransferProtocolDaemonClientImpl(bus); 483 return new MediaTransferProtocolDaemonClientImpl(bus);
457 } 484 }
458 485
459 } // namespace device 486 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698