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

Side by Side Diff: chrome/browser/media_galleries/win/mtp_device_operations_util.cc

Issue 177923007: Move AppendFile and *CurrentDirectory to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // |optimal_transfer_size|). This indicates the end of the stream has been 379 // |optimal_transfer_size|). This indicates the end of the stream has been
380 // reached. 380 // reached.
381 if (FAILED(hr)) 381 if (FAILED(hr))
382 return 0U; 382 return 0U;
383 DCHECK_GT(bytes_read, 0U); 383 DCHECK_GT(bytes_read, 0U);
384 CHECK_LE(bytes_read, buffer.length()); 384 CHECK_LE(bytes_read, buffer.length());
385 int data_len = 385 int data_len =
386 base::checked_cast<int>( 386 base::checked_cast<int>(
387 std::min(bytes_read, 387 std::min(bytes_read,
388 base::checked_cast<DWORD>(buffer.length()))); 388 base::checked_cast<DWORD>(buffer.length())));
389 if (file_util::AppendToFile(local_path, buffer.c_str(), data_len) != data_len) 389 if (base::AppendToFile(local_path, buffer.c_str(), data_len) != data_len)
390 return 0U; 390 return 0U;
391 return data_len; 391 return data_len;
392 } 392 }
393 393
394 base::string16 GetObjectIdFromName(IPortableDevice* device, 394 base::string16 GetObjectIdFromName(IPortableDevice* device,
395 const base::string16& parent_id, 395 const base::string16& parent_id,
396 const base::string16& object_name) { 396 const base::string16& object_name) {
397 MTPDeviceObjectEntries object_entries; 397 MTPDeviceObjectEntries object_entries;
398 if (!GetMTPDeviceObjectEntries(device, parent_id, object_name, 398 if (!GetMTPDeviceObjectEntries(device, parent_id, object_name,
399 &object_entries) || 399 &object_entries) ||
400 object_entries.empty()) 400 object_entries.empty())
401 return base::string16(); 401 return base::string16();
402 // TODO(thestig): This DCHECK can fail. Multiple MTP objects can have 402 // TODO(thestig): This DCHECK can fail. Multiple MTP objects can have
403 // the same name. Handle the situation gracefully. Refer to crbug.com/169930 403 // the same name. Handle the situation gracefully. Refer to crbug.com/169930
404 // for more details. 404 // for more details.
405 DCHECK_EQ(1U, object_entries.size()); 405 DCHECK_EQ(1U, object_entries.size());
406 return object_entries[0].object_id; 406 return object_entries[0].object_id;
407 } 407 }
408 408
409 } // namespace media_transfer_protocol 409 } // namespace media_transfer_protocol
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/linux/mtp_read_file_worker.cc ('k') | chrome/browser/net/net_log_temp_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698