in_memory_directory_backing_store.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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    Directory::KernelLoadInfo* kernel_load_info) {
17  if (!db_->is_open()) {
18    if (!db_->OpenInMemory())
19      return FAILED_OPEN_DATABASE;
20  }
21
22  if (!InitializeTables())
23    return FAILED_OPEN_DATABASE;
24
25  if (!DropDeletedEntries())
26    return FAILED_DATABASE_CORRUPT;
27  if (!LoadEntries(entry_bucket))
28    return FAILED_DATABASE_CORRUPT;
29  if (!LoadInfo(kernel_load_info))
30    return FAILED_DATABASE_CORRUPT;
31  if (!VerifyReferenceIntegrity(*entry_bucket))
32    return FAILED_DATABASE_CORRUPT;
33
34  return OPENED;
35}
36
37}  // namespace syncable
38}  // namespace syncer
39