in_memory_directory_backing_store.cc revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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) 12 : DirectoryBackingStore(dir_name), 13 consistent_cache_guid_requested_(false) { 14} 15 16DirOpenResult InMemoryDirectoryBackingStore::Load( 17 MetahandlesIndex* entry_bucket, 18 JournalIndex* delete_journals, 19 Directory::KernelLoadInfo* kernel_load_info) { 20 if (!db_->is_open()) { 21 if (!db_->OpenInMemory()) 22 return FAILED_OPEN_DATABASE; 23 } 24 25 if (!InitializeTables()) 26 return FAILED_OPEN_DATABASE; 27 28 if (consistent_cache_guid_requested_) { 29 if (!db_->Execute("UPDATE share_info " 30 "SET cache_guid = 'IrcjZ2jyzHDV9Io4+zKcXQ=='")) { 31 return FAILED_OPEN_DATABASE; 32 } 33 } 34 35 if (!DropDeletedEntries()) 36 return FAILED_DATABASE_CORRUPT; 37 if (!LoadEntries(entry_bucket)) 38 return FAILED_DATABASE_CORRUPT; 39 if (!LoadDeleteJournals(delete_journals)) 40 return FAILED_DATABASE_CORRUPT; 41 if (!LoadInfo(kernel_load_info)) 42 return FAILED_DATABASE_CORRUPT; 43 if (!VerifyReferenceIntegrity(*entry_bucket)) 44 return FAILED_DATABASE_CORRUPT; 45 46 return OPENED; 47} 48 49} // namespace syncable 50} // namespace syncer 51