blob: b50da384cc4f644292a01b130ac564924872dd09 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/files/file_path.h"
#include "sync/base/sync_export.h"
#include "sync/syncable/directory_backing_store.h"
namespace syncer {
namespace syncable {
// Store used for backing up user's data before first sync. It creates an
// in-memory store first and switch to on-disk store if SaveChanges() is
// called, which only happens when SyncBackupManager is shut down and a
// syncing backend is to be created. Thus we guarantee that user data is not
// persisted until user is actually going to sync.
class SYNC_EXPORT_PRIVATE DeferredOnDiskDirectoryBackingStore
: public DirectoryBackingStore {
DeferredOnDiskDirectoryBackingStore(const std::string& dir_name,
const base::FilePath& backing_filepath);
~DeferredOnDiskDirectoryBackingStore() override;
DirOpenResult Load(Directory::MetahandlesMap* handles_map,
JournalIndex* delete_journals,
MetahandleSet* metahandles_to_purge,
Directory::KernelLoadInfo* kernel_load_info) override;
bool SaveChanges(const Directory::SaveChangesSnapshot& snapshot) override;
base::FilePath backing_filepath_;
// Whether current DB is on disk.
bool db_is_on_disk_;
} // namespace syncable
} // namespace syncer