| OLD | NEW |
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "dbus/bus.h" | 9 #include "dbus/bus.h" |
| 10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // Handles the result of ReadFileChunkByPath/Id and calls |callback| or | 342 // Handles the result of ReadFileChunkByPath/Id and calls |callback| or |
| 343 // |error_callback|. | 343 // |error_callback|. |
| 344 void OnReadFile(const ReadFileCallback& callback, | 344 void OnReadFile(const ReadFileCallback& callback, |
| 345 const ErrorCallback& error_callback, | 345 const ErrorCallback& error_callback, |
| 346 dbus::Response* response) { | 346 dbus::Response* response) { |
| 347 if (!response) { | 347 if (!response) { |
| 348 error_callback.Run(); | 348 error_callback.Run(); |
| 349 return; | 349 return; |
| 350 } | 350 } |
| 351 | 351 |
| 352 uint8* data_bytes = NULL; | 352 const uint8* data_bytes = NULL; |
| 353 size_t data_length = 0; | 353 size_t data_length = 0; |
| 354 dbus::MessageReader reader(response); | 354 dbus::MessageReader reader(response); |
| 355 if (!reader.PopArrayOfBytes(&data_bytes, &data_length)) { | 355 if (!reader.PopArrayOfBytes(&data_bytes, &data_length)) { |
| 356 error_callback.Run(); | 356 error_callback.Run(); |
| 357 return; | 357 return; |
| 358 } | 358 } |
| 359 std::string data(reinterpret_cast<const char*>(data_bytes), data_length); | 359 std::string data(reinterpret_cast<const char*>(data_bytes), data_length); |
| 360 callback.Run(data); | 360 callback.Run(data); |
| 361 } | 361 } |
| 362 | 362 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 MediaTransferProtocolDaemonClient::~MediaTransferProtocolDaemonClient() {} | 424 MediaTransferProtocolDaemonClient::~MediaTransferProtocolDaemonClient() {} |
| 425 | 425 |
| 426 // static | 426 // static |
| 427 MediaTransferProtocolDaemonClient* MediaTransferProtocolDaemonClient::Create( | 427 MediaTransferProtocolDaemonClient* MediaTransferProtocolDaemonClient::Create( |
| 428 dbus::Bus* bus) { | 428 dbus::Bus* bus) { |
| 429 return new MediaTransferProtocolDaemonClientImpl(bus); | 429 return new MediaTransferProtocolDaemonClientImpl(bus); |
| 430 } | 430 } |
| 431 | 431 |
| 432 } // namespace device | 432 } // namespace device |
| OLD | NEW |