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 "chrome/browser/chromeos/drive/file_cache.h" | 5 #include "chrome/browser/chromeos/drive/file_cache.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 net::GetExtensionsForMimeType(mime_type, &extensions); | 467 net::GetExtensionsForMimeType(mime_type, &extensions); |
468 | 468 |
469 // Add extension if possible. | 469 // Add extension if possible. |
470 if (!extensions.empty()) | 470 if (!extensions.empty()) |
471 dest_base_name = dest_base_name.AddExtension(extensions[0]); | 471 dest_base_name = dest_base_name.AddExtension(extensions[0]); |
472 } | 472 } |
473 | 473 |
474 // Add file number to the file name and move. | 474 // Add file number to the file name and move. |
475 const base::FilePath& dest_path = dest_directory.Append(dest_base_name) | 475 const base::FilePath& dest_path = dest_directory.Append(dest_base_name) |
476 .InsertBeforeExtensionASCII(base::StringPrintf("%08d", file_number++)); | 476 .InsertBeforeExtensionASCII(base::StringPrintf("%08d", file_number++)); |
477 if (!file_util::CreateDirectory(dest_directory) || | 477 if (!base::CreateDirectory(dest_directory) || |
478 !base::Move(current, dest_path)) { | 478 !base::Move(current, dest_path)) { |
479 LOG(WARNING) << "Failed to move: " << current.value() | 479 LOG(WARNING) << "Failed to move: " << current.value() |
480 << " to " << dest_path.value(); | 480 << " to " << dest_path.value(); |
481 return false; | 481 return false; |
482 } | 482 } |
483 } | 483 } |
484 UMA_HISTOGRAM_COUNTS("Drive.NumberOfCacheFilesRecoveredAfterDBCorruption", | 484 UMA_HISTOGRAM_COUNTS("Drive.NumberOfCacheFilesRecoveredAfterDBCorruption", |
485 file_number - 1); | 485 file_number - 1); |
486 return true; | 486 return true; |
487 } | 487 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 const std::string& id = GetIdFromPath(new_path); | 586 const std::string& id = GetIdFromPath(new_path); |
587 new_path = GetCacheFilePath(util::CanonicalizeResourceId(id)); | 587 new_path = GetCacheFilePath(util::CanonicalizeResourceId(id)); |
588 if (new_path != current && !base::Move(current, new_path)) | 588 if (new_path != current && !base::Move(current, new_path)) |
589 return false; | 589 return false; |
590 } | 590 } |
591 return true; | 591 return true; |
592 } | 592 } |
593 | 593 |
594 } // namespace internal | 594 } // namespace internal |
595 } // namespace drive | 595 } // namespace drive |
OLD | NEW |