| 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/on_disk_directory_backing_store.h" | 5 #include "sync/syncable/on_disk_directory_backing_store.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "sync/syncable/syncable-inl.h" | 10 #include "sync/syncable/syncable-inl.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // fetch the user's data from the cloud. | 80 // fetch the user's data from the cloud. |
| 81 STLDeleteValues(handles_map); | 81 STLDeleteValues(handles_map); |
| 82 STLDeleteElements(delete_journals); | 82 STLDeleteElements(delete_journals); |
| 83 db_.reset(new sql::Connection); | 83 db_.reset(new sql::Connection); |
| 84 // TODO: Manually propagating the default database settings is | 84 // TODO: Manually propagating the default database settings is |
| 85 // brittle. Either have a helper to set these up (or generate a new | 85 // brittle. Either have a helper to set these up (or generate a new |
| 86 // connection), or add something like Reset() to sql::Connection. | 86 // connection), or add something like Reset() to sql::Connection. |
| 87 db_->set_exclusive_locking(); | 87 db_->set_exclusive_locking(); |
| 88 db_->set_page_size(4096); | 88 db_->set_page_size(4096); |
| 89 db_->set_histogram_tag("SyncDirectory"); | 89 db_->set_histogram_tag("SyncDirectory"); |
| 90 file_util::Delete(backing_filepath_, false); | 90 base::Delete(backing_filepath_, false); |
| 91 | 91 |
| 92 result = TryLoad(handles_map, delete_journals, kernel_load_info); | 92 result = TryLoad(handles_map, delete_journals, kernel_load_info); |
| 93 if (result == OPENED) { | 93 if (result == OPENED) { |
| 94 UMA_HISTOGRAM_ENUMERATION( | 94 UMA_HISTOGRAM_ENUMERATION( |
| 95 "Sync.DirectoryOpenResult", SECOND_TRY_SUCCESS, RESULT_COUNT); | 95 "Sync.DirectoryOpenResult", SECOND_TRY_SUCCESS, RESULT_COUNT); |
| 96 } else { | 96 } else { |
| 97 UMA_HISTOGRAM_ENUMERATION( | 97 UMA_HISTOGRAM_ENUMERATION( |
| 98 "Sync.DirectoryOpenResult", SECOND_TRY_FAILURE, RESULT_COUNT); | 98 "Sync.DirectoryOpenResult", SECOND_TRY_FAILURE, RESULT_COUNT); |
| 99 } | 99 } |
| 100 | 100 |
| 101 return result; | 101 return result; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void OnDiskDirectoryBackingStore::ReportFirstTryOpenFailure() { | 104 void OnDiskDirectoryBackingStore::ReportFirstTryOpenFailure() { |
| 105 // In debug builds, the last thing we want is to silently clear the database. | 105 // In debug builds, the last thing we want is to silently clear the database. |
| 106 // It's full of evidence that might help us determine what went wrong. It | 106 // It's full of evidence that might help us determine what went wrong. It |
| 107 // might be sqlite's fault, but it could also be a bug in sync. We crash | 107 // might be sqlite's fault, but it could also be a bug in sync. We crash |
| 108 // immediately so a developer can investigate. | 108 // immediately so a developer can investigate. |
| 109 // | 109 // |
| 110 // Developers: If you're not interested in debugging this right now, just move | 110 // Developers: If you're not interested in debugging this right now, just move |
| 111 // aside the 'Sync Data' directory in your profile. This is similar to what | 111 // aside the 'Sync Data' directory in your profile. This is similar to what |
| 112 // the code would do if this DCHECK were disabled. | 112 // the code would do if this DCHECK were disabled. |
| 113 NOTREACHED() << "Crashing to preserve corrupt sync database"; | 113 NOTREACHED() << "Crashing to preserve corrupt sync database"; |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace syncable | 116 } // namespace syncable |
| 117 } // namespace syncer | 117 } // namespace syncer |
| OLD | NEW |