in_memory_directory_backing_store.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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
3// found in the LICENSE file.
4
5#include "sync/syncable/in_memory_directory_backing_store.h"
6
7namespace syncer {
8namespace syncable {
9
10InMemoryDirectoryBackingStore::InMemoryDirectoryBackingStore(
11    const std::string& dir_name) : DirectoryBackingStore(dir_name) {
12}
13
14DirOpenResult InMemoryDirectoryBackingStore::Load(
15    MetahandlesIndex* entry_bucket,
16    JournalIndex* delete_journals,
17    Directory::KernelLoadInfo* kernel_load_info) {
18  if (!db_->is_open()) {
19    if (!db_->OpenInMemory())
20      return FAILED_OPEN_DATABASE;
21  }
22
23  if (!InitializeTables())
24    return FAILED_OPEN_DATABASE;
25
26  if (!DropDeletedEntries())
27    return FAILED_DATABASE_CORRUPT;
28  if (!LoadEntries(entry_bucket))
29    return FAILED_DATABASE_CORRUPT;
30  if (!LoadDeleteJournals(delete_journals))
31    return FAILED_DATABASE_CORRUPT;
32  if (!LoadInfo(kernel_load_info))
33    return FAILED_DATABASE_CORRUPT;
34  if (!VerifyReferenceIntegrity(*entry_bucket))
35    return FAILED_DATABASE_CORRUPT;
36
37  return OPENED;
38}
39
40}  // namespace syncable
41}  // namespace syncer
42