| 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/drive_integration_service.h" | 5 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/prefs/pref_change_registrar.h" | 9 #include "base/prefs/pref_change_registrar.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const std::string& dest_directory_name = l10n_util::GetStringUTF8( | 136 const std::string& dest_directory_name = l10n_util::GetStringUTF8( |
| 137 IDS_FILE_BROWSER_RECOVERED_FILES_FROM_GOOGLE_DRIVE_DIRECTORY_NAME); | 137 IDS_FILE_BROWSER_RECOVERED_FILES_FROM_GOOGLE_DRIVE_DIRECTORY_NAME); |
| 138 base::FilePath dest_directory = downloads_directory.Append( | 138 base::FilePath dest_directory = downloads_directory.Append( |
| 139 base::FilePath::FromUTF8Unsafe(dest_directory_name)); | 139 base::FilePath::FromUTF8Unsafe(dest_directory_name)); |
| 140 for (int uniquifier = 1; base::PathExists(dest_directory); ++uniquifier) { | 140 for (int uniquifier = 1; base::PathExists(dest_directory); ++uniquifier) { |
| 141 dest_directory = downloads_directory.Append( | 141 dest_directory = downloads_directory.Append( |
| 142 base::FilePath::FromUTF8Unsafe(dest_directory_name)) | 142 base::FilePath::FromUTF8Unsafe(dest_directory_name)) |
| 143 .InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", uniquifier)); | 143 .InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", uniquifier)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 std::map<std::string, FileCacheEntry> recovered_cache_entries; |
| 147 metadata_storage->RecoverCacheEntriesFromTrashedResourceMap( |
| 148 &recovered_cache_entries); |
| 149 |
| 146 LOG(INFO) << "DB could not be opened for some reasons. " | 150 LOG(INFO) << "DB could not be opened for some reasons. " |
| 147 << "Recovering cache files to " << dest_directory.value(); | 151 << "Recovering cache files to " << dest_directory.value(); |
| 148 if (!cache->RecoverFilesFromCacheDirectory(dest_directory)) { | 152 if (!cache->RecoverFilesFromCacheDirectory(dest_directory, |
| 153 recovered_cache_entries)) { |
| 149 LOG(WARNING) << "Failed to recover cache files."; | 154 LOG(WARNING) << "Failed to recover cache files."; |
| 150 return FILE_ERROR_FAILED; | 155 return FILE_ERROR_FAILED; |
| 151 } | 156 } |
| 152 } | 157 } |
| 153 | 158 |
| 154 FileError error = resource_metadata->Initialize(); | 159 FileError error = resource_metadata->Initialize(); |
| 155 LOG_IF(WARNING, error != FILE_ERROR_OK) | 160 LOG_IF(WARNING, error != FILE_ERROR_OK) |
| 156 << "Failed to initialize resource metadata. " << FileErrorToString(error); | 161 << "Failed to initialize resource metadata. " << FileErrorToString(error); |
| 157 return error; | 162 return error; |
| 158 } | 163 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 NULL, base::FilePath(), NULL); | 593 NULL, base::FilePath(), NULL); |
| 589 } else { | 594 } else { |
| 590 service = factory_for_test_.Run(profile); | 595 service = factory_for_test_.Run(profile); |
| 591 } | 596 } |
| 592 | 597 |
| 593 service->SetEnabled(drive::util::IsDriveEnabledForProfile(profile)); | 598 service->SetEnabled(drive::util::IsDriveEnabledForProfile(profile)); |
| 594 return service; | 599 return service; |
| 595 } | 600 } |
| 596 | 601 |
| 597 } // namespace drive | 602 } // namespace drive |
| OLD | NEW |