OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/media_galleries/win/mtp_device_operations_util.h" | 5 #include "chrome/browser/media_galleries/win/mtp_device_operations_util.h" |
6 | 6 |
7 #include <portabledevice.h> | 7 #include <portabledevice.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 DWORD CopyDataChunkToLocalFile(IStream* stream, | 371 DWORD CopyDataChunkToLocalFile(IStream* stream, |
372 const base::FilePath& local_path, | 372 const base::FilePath& local_path, |
373 size_t optimal_transfer_size) { | 373 size_t optimal_transfer_size) { |
374 base::ThreadRestrictions::AssertIOAllowed(); | 374 base::ThreadRestrictions::AssertIOAllowed(); |
375 DCHECK(stream); | 375 DCHECK(stream); |
376 DCHECK(!local_path.empty()); | 376 DCHECK(!local_path.empty()); |
377 if (optimal_transfer_size == 0U) | 377 if (optimal_transfer_size == 0U) |
378 return 0U; | 378 return 0U; |
379 DWORD bytes_read = 0; | 379 DWORD bytes_read = 0; |
380 std::string buffer; | 380 std::string buffer; |
381 HRESULT hr = stream->Read(WriteInto(&buffer, optimal_transfer_size + 1), | 381 HRESULT hr = stream->Read(base::WriteInto(&buffer, optimal_transfer_size + 1), |
382 optimal_transfer_size, &bytes_read); | 382 optimal_transfer_size, &bytes_read); |
383 // IStream::Read() returns S_FALSE when the actual number of bytes read from | 383 // IStream::Read() returns S_FALSE when the actual number of bytes read from |
384 // the stream object is less than the number of bytes requested (aka | 384 // the stream object is less than the number of bytes requested (aka |
385 // |optimal_transfer_size|). This indicates the end of the stream has been | 385 // |optimal_transfer_size|). This indicates the end of the stream has been |
386 // reached. | 386 // reached. |
387 if (FAILED(hr)) | 387 if (FAILED(hr)) |
388 return 0U; | 388 return 0U; |
389 DCHECK_GT(bytes_read, 0U); | 389 DCHECK_GT(bytes_read, 0U); |
390 CHECK_LE(bytes_read, buffer.length()); | 390 CHECK_LE(bytes_read, buffer.length()); |
391 int data_len = | 391 int data_len = |
(...skipping 13 matching lines...) Expand all Loading... |
405 object_entries.empty()) | 405 object_entries.empty()) |
406 return base::string16(); | 406 return base::string16(); |
407 // TODO(thestig): This DCHECK can fail. Multiple MTP objects can have | 407 // TODO(thestig): This DCHECK can fail. Multiple MTP objects can have |
408 // the same name. Handle the situation gracefully. Refer to crbug.com/169930 | 408 // the same name. Handle the situation gracefully. Refer to crbug.com/169930 |
409 // for more details. | 409 // for more details. |
410 DCHECK_EQ(1U, object_entries.size()); | 410 DCHECK_EQ(1U, object_entries.size()); |
411 return object_entries[0].object_id; | 411 return object_entries[0].object_id; |
412 } | 412 } |
413 | 413 |
414 } // namespace media_transfer_protocol | 414 } // namespace media_transfer_protocol |
OLD | NEW |