summaryrefslogtreecommitdiff
path: root/chromium/sync/syncable/in_memory_directory_backing_store.cc
blob: 57995f823789ba15d06cbe2b066a6768dbe7bb18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2012 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 "sync/syncable/in_memory_directory_backing_store.h"

namespace syncer {
namespace syncable {

InMemoryDirectoryBackingStore::InMemoryDirectoryBackingStore(
    const std::string& dir_name)
    : DirectoryBackingStore(dir_name),
      consistent_cache_guid_requested_(false) {
}

DirOpenResult InMemoryDirectoryBackingStore::Load(
    Directory::MetahandlesMap* handles_map,
    JournalIndex* delete_journals,
    Directory::KernelLoadInfo* kernel_load_info) {
  if (!db_->is_open()) {
    if (!db_->OpenInMemory())
      return FAILED_OPEN_DATABASE;
  }

  if (!InitializeTables())
    return FAILED_OPEN_DATABASE;

  if (consistent_cache_guid_requested_) {
    if (!db_->Execute("UPDATE share_info "
                      "SET cache_guid = 'IrcjZ2jyzHDV9Io4+zKcXQ=='")) {
      return FAILED_OPEN_DATABASE;
    }
  }

  if (!DropDeletedEntries())
    return FAILED_DATABASE_CORRUPT;
  if (!LoadEntries(handles_map))
    return FAILED_DATABASE_CORRUPT;
  if (!LoadDeleteJournals(delete_journals))
    return FAILED_DATABASE_CORRUPT;
  if (!LoadInfo(kernel_load_info))
    return FAILED_DATABASE_CORRUPT;
  if (!VerifyReferenceIntegrity(handles_map))
    return FAILED_DATABASE_CORRUPT;

  return OPENED;
}

}  // namespace syncable
}  // namespace syncer