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

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

Issue 176693003: chromeos: Make dbus::MessageReader memory ownership explicit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unnecessary reinterpret_cast Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « dbus/message_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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
OLDNEW
« no previous file with comments | « dbus/message_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698