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

Unified Diff: components/sync/driver/glue/sync_backend_host_core.cc

Issue 2568743004: [Sync] Stop deleting LevelDB files when deleting Directory (Closed)
Patch Set: Updated for Max's comments. Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: components/sync/driver/glue/sync_backend_host_core.cc
diff --git a/components/sync/driver/glue/sync_backend_host_core.cc b/components/sync/driver/glue/sync_backend_host_core.cc
index ca38894fdb6aa1165aa92f9107a5e51fa959e30b..c448500b366aede67886cd53d13769f342e36674 100644
--- a/components/sync/driver/glue/sync_backend_host_core.cc
+++ b/components/sync/driver/glue/sync_backend_host_core.cc
@@ -28,6 +28,7 @@
#include "components/sync/engine/sync_backend_registrar.h"
#include "components/sync/engine/sync_manager.h"
#include "components/sync/engine/sync_manager_factory.h"
+#include "components/sync/syncable/directory.h"
// Helper macros to log with the syncer thread name; useful when there
// are multiple syncers involved.
@@ -57,10 +58,10 @@ class EngineComponentsFactory;
SyncBackendHostCore::SyncBackendHostCore(
const std::string& name,
- const base::FilePath& sync_data_folder_path,
+ const base::FilePath& sync_data_folder,
const base::WeakPtr<SyncBackendHostImpl>& backend)
: name_(name),
- sync_data_folder_path_(sync_data_folder_path),
+ sync_data_folder_(sync_data_folder),
host_(backend),
weak_ptr_factory_(this) {
DCHECK(backend.get());
@@ -325,12 +326,12 @@ void SyncBackendHostCore::DoInitialize(SyncEngine::InitParams params) {
// Blow away the partial or corrupt sync data folder before doing any more
// initialization, if necessary.
if (params.delete_sync_data_folder) {
- DeleteSyncDataFolder();
+ syncable::Directory::DeleteDirectoryFiles(sync_data_folder_);
}
// Make sure that the directory exists before initializing the backend.
// If it already exists, this will do no harm.
- if (!base::CreateDirectory(sync_data_folder_path_)) {
+ if (!base::CreateDirectory(sync_data_folder_)) {
DLOG(FATAL) << "Sync Data directory creation failed.";
}
@@ -345,7 +346,7 @@ void SyncBackendHostCore::DoInitialize(SyncEngine::InitParams params) {
sync_manager_->AddObserver(this);
SyncManager::InitArgs args;
- args.database_location = sync_data_folder_path_;
+ args.database_location = sync_data_folder_;
args.event_handler = params.event_handler;
args.service_url = params.service_url;
args.enable_local_sync_backend = params.enable_local_sync_backend;
@@ -480,7 +481,7 @@ void SyncBackendHostCore::DoShutdown(ShutdownReason reason) {
registrar_ = nullptr;
if (reason == DISABLE_SYNC)
- DeleteSyncDataFolder();
+ syncable::Directory::DeleteDirectoryFiles(sync_data_folder_);
host_.Reset();
weak_ptr_factory_.InvalidateWeakPtrs();
@@ -601,14 +602,6 @@ void SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding() {
sync_manager_->UnregisterDirectoryTypeDebugInfoObserver(this);
}
-void SyncBackendHostCore::DeleteSyncDataFolder() {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (base::DirectoryExists(sync_data_folder_path_)) {
- if (!base::DeleteFile(sync_data_folder_path_, true))
- SLOG(DFATAL) << "Could not delete the Sync Data folder.";
- }
-}
-
void SyncBackendHostCore::StartSavingChanges() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!save_changes_timer_.get());
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_core.h ('k') | components/sync/driver/glue/sync_backend_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698