| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/deferred_on_disk_directory_backing_store.h" | 5 #include "sync/syncable/deferred_on_disk_directory_backing_store.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "sync/syncable/syncable-inl.h" | 10 #include "sync/syncable/syncable-inl.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 snapshot.delete_journals_to_purge.empty()) { | 31 snapshot.delete_journals_to_purge.empty()) { |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 if (!db_is_on_disk_) { | 35 if (!db_is_on_disk_) { |
| 36 if (!base::DeleteFile(backing_filepath_, false)) | 36 if (!base::DeleteFile(backing_filepath_, false)) |
| 37 return false; | 37 return false; |
| 38 | 38 |
| 39 // Reopen DB on disk. | 39 // Reopen DB on disk. |
| 40 ResetAndCreateConnection(); | 40 ResetAndCreateConnection(); |
| 41 if (!db_->Open(backing_filepath_) || !InitializeTables()) | 41 if (!Open(backing_filepath_) || !InitializeTables()) |
| 42 return false; | 42 return false; |
| 43 | 43 |
| 44 db_is_on_disk_ = true; | 44 db_is_on_disk_ = true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 return DirectoryBackingStore::SaveChanges(snapshot); | 47 return DirectoryBackingStore::SaveChanges(snapshot); |
| 48 } | 48 } |
| 49 | 49 |
| 50 DirOpenResult DeferredOnDiskDirectoryBackingStore::Load( | 50 DirOpenResult DeferredOnDiskDirectoryBackingStore::Load( |
| 51 Directory::MetahandlesMap* handles_map, | 51 Directory::MetahandlesMap* handles_map, |
| 52 JournalIndex* delete_journals, | 52 JournalIndex* delete_journals, |
| 53 MetahandleSet* metahandles_to_purge, | 53 MetahandleSet* metahandles_to_purge, |
| 54 Directory::KernelLoadInfo* kernel_load_info) { | 54 Directory::KernelLoadInfo* kernel_load_info) { |
| 55 // Open an in-memory database at first to create initial sync data needed by | 55 // Open an in-memory database at first to create initial sync data needed by |
| 56 // Directory. | 56 // Directory. |
| 57 CHECK(!db_->is_open()); | 57 CHECK(!IsOpen()); |
| 58 if (!db_->OpenInMemory()) | 58 if (!OpenInMemory()) |
| 59 return FAILED_OPEN_DATABASE; | 59 return FAILED_OPEN_DATABASE; |
| 60 | 60 |
| 61 if (!InitializeTables()) | 61 if (!InitializeTables()) |
| 62 return FAILED_OPEN_DATABASE; | 62 return FAILED_OPEN_DATABASE; |
| 63 if (!LoadEntries(handles_map, metahandles_to_purge)) | 63 if (!LoadEntries(handles_map, metahandles_to_purge)) |
| 64 return FAILED_DATABASE_CORRUPT; | 64 return FAILED_DATABASE_CORRUPT; |
| 65 if (!LoadInfo(kernel_load_info)) | 65 if (!LoadInfo(kernel_load_info)) |
| 66 return FAILED_DATABASE_CORRUPT; | 66 return FAILED_DATABASE_CORRUPT; |
| 67 | 67 |
| 68 return OPENED; | 68 return OPENED; |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace syncable | 71 } // namespace syncable |
| 72 } // namespace syncer | 72 } // namespace syncer |
| OLD | NEW |