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 "components/sync/syncable/on_disk_directory_backing_store.h" | 5 #include "components/sync/syncable/on_disk_directory_backing_store.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/stl_util.h" | |
10 #include "components/sync/syncable/syncable-inl.h" | |
11 | 9 |
12 namespace syncer { | 10 namespace syncer { |
13 namespace syncable { | 11 namespace syncable { |
14 | 12 |
15 namespace { | 13 namespace { |
16 | 14 |
17 enum HistogramResultEnum { | 15 enum HistogramResultEnum { |
18 FIRST_TRY_SUCCESS, | 16 FIRST_TRY_SUCCESS, |
19 SECOND_TRY_SUCCESS, | 17 SECOND_TRY_SUCCESS, |
20 SECOND_TRY_FAILURE, | 18 SECOND_TRY_FAILURE, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 UMA_HISTOGRAM_ENUMERATION("Sync.DirectoryOpenResult", FIRST_TRY_SUCCESS, | 69 UMA_HISTOGRAM_ENUMERATION("Sync.DirectoryOpenResult", FIRST_TRY_SUCCESS, |
72 RESULT_COUNT); | 70 RESULT_COUNT); |
73 return OPENED; | 71 return OPENED; |
74 } | 72 } |
75 | 73 |
76 ReportFirstTryOpenFailure(); | 74 ReportFirstTryOpenFailure(); |
77 | 75 |
78 // The fallback: delete the current database and return a fresh one. We can | 76 // The fallback: delete the current database and return a fresh one. We can |
79 // fetch the user's data from the cloud. | 77 // fetch the user's data from the cloud. |
80 handles_map->clear(); | 78 handles_map->clear(); |
81 base::STLDeleteElements(delete_journals); | 79 delete_journals->clear(); |
82 | 80 |
83 ResetAndCreateConnection(); | 81 ResetAndCreateConnection(); |
84 | 82 |
85 base::DeleteFile(backing_file_path_, false); | 83 base::DeleteFile(backing_file_path_, false); |
86 | 84 |
87 result = TryLoad(handles_map, delete_journals, metahandles_to_purge, | 85 result = TryLoad(handles_map, delete_journals, metahandles_to_purge, |
88 kernel_load_info); | 86 kernel_load_info); |
89 if (result == OPENED) { | 87 if (result == OPENED) { |
90 UMA_HISTOGRAM_ENUMERATION("Sync.DirectoryOpenResult", SECOND_TRY_SUCCESS, | 88 UMA_HISTOGRAM_ENUMERATION("Sync.DirectoryOpenResult", SECOND_TRY_SUCCESS, |
91 RESULT_COUNT); | 89 RESULT_COUNT); |
(...skipping 17 matching lines...) Expand all Loading... |
109 NOTREACHED() << "Crashing to preserve corrupt sync database"; | 107 NOTREACHED() << "Crashing to preserve corrupt sync database"; |
110 } | 108 } |
111 | 109 |
112 const base::FilePath& OnDiskDirectoryBackingStore::backing_file_path() const { | 110 const base::FilePath& OnDiskDirectoryBackingStore::backing_file_path() const { |
113 DCHECK(CalledOnValidThread()); | 111 DCHECK(CalledOnValidThread()); |
114 return backing_file_path_; | 112 return backing_file_path_; |
115 } | 113 } |
116 | 114 |
117 } // namespace syncable | 115 } // namespace syncable |
118 } // namespace syncer | 116 } // namespace syncer |
OLD | NEW |