OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sync/syncable/in_memory_directory_backing_store.h" | 5 #include "sync/syncable/in_memory_directory_backing_store.h" |
6 | 6 |
7 namespace syncer { | 7 namespace syncer { |
8 namespace syncable { | 8 namespace syncable { |
9 | 9 |
10 InMemoryDirectoryBackingStore::InMemoryDirectoryBackingStore( | 10 InMemoryDirectoryBackingStore::InMemoryDirectoryBackingStore( |
11 const std::string& dir_name) | 11 const std::string& dir_name) |
12 : DirectoryBackingStore(dir_name), | 12 : DirectoryBackingStore(dir_name), |
13 consistent_cache_guid_requested_(false) { | 13 consistent_cache_guid_requested_(false) { |
14 } | 14 } |
15 | 15 |
16 DirOpenResult InMemoryDirectoryBackingStore::Load( | 16 DirOpenResult InMemoryDirectoryBackingStore::Load( |
17 Directory::MetahandlesMap* handles_map, | 17 Directory::MetahandlesMap* handles_map, |
18 JournalIndex* delete_journals, | 18 JournalIndex* delete_journals, |
19 MetahandleSet* metahandles_to_purge, | 19 MetahandleSet* metahandles_to_purge, |
20 Directory::KernelLoadInfo* kernel_load_info) { | 20 Directory::KernelLoadInfo* kernel_load_info) { |
21 if (!db_->is_open()) { | 21 if (!IsOpen()) { |
22 if (!db_->OpenInMemory()) | 22 if (!OpenInMemory()) |
23 return FAILED_OPEN_DATABASE; | 23 return FAILED_OPEN_DATABASE; |
24 } | 24 } |
25 | 25 |
26 if (!InitializeTables()) | 26 if (!InitializeTables()) |
27 return FAILED_OPEN_DATABASE; | 27 return FAILED_OPEN_DATABASE; |
28 | 28 |
29 if (consistent_cache_guid_requested_) { | 29 if (consistent_cache_guid_requested_) { |
30 if (!db_->Execute("UPDATE share_info " | 30 if (!db()->Execute( |
31 "SET cache_guid = 'IrcjZ2jyzHDV9Io4+zKcXQ=='")) { | 31 "UPDATE share_info " |
| 32 "SET cache_guid = 'IrcjZ2jyzHDV9Io4+zKcXQ=='")) { |
32 return FAILED_OPEN_DATABASE; | 33 return FAILED_OPEN_DATABASE; |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
36 if (!LoadEntries(handles_map, metahandles_to_purge)) | 37 if (!LoadEntries(handles_map, metahandles_to_purge)) |
37 return FAILED_DATABASE_CORRUPT; | 38 return FAILED_DATABASE_CORRUPT; |
38 if (!LoadDeleteJournals(delete_journals)) | 39 if (!LoadDeleteJournals(delete_journals)) |
39 return FAILED_DATABASE_CORRUPT; | 40 return FAILED_DATABASE_CORRUPT; |
40 if (!LoadInfo(kernel_load_info)) | 41 if (!LoadInfo(kernel_load_info)) |
41 return FAILED_DATABASE_CORRUPT; | 42 return FAILED_DATABASE_CORRUPT; |
42 if (!VerifyReferenceIntegrity(handles_map)) | 43 if (!VerifyReferenceIntegrity(handles_map)) |
43 return FAILED_DATABASE_CORRUPT; | 44 return FAILED_DATABASE_CORRUPT; |
44 | 45 |
45 return OPENED; | 46 return OPENED; |
46 } | 47 } |
47 | 48 |
48 } // namespace syncable | 49 } // namespace syncable |
49 } // namespace syncer | 50 } // namespace syncer |
OLD | NEW |