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

Side by Side Diff: chrome/browser/chromeos/drive/drive_integration_service.cc

Issue 54223003: drive: Recover cache entries from trashed DB to filter out non-dirty cache files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | « no previous file | chrome/browser/chromeos/drive/file_cache.h » ('j') | 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 "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
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
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
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/file_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698