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/omnibox/browser/in_memory_url_index.h" | 5 #include "components/omnibox/browser/in_memory_url_index.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "components/history/core/browser/history_service.h" | 10 #include "components/history/core/browser/history_service.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 ClearPrivateData(); | 170 ClearPrivateData(); |
171 needs_to_be_cached_ = true; | 171 needs_to_be_cached_ = true; |
172 } else { | 172 } else { |
173 for (const auto& row : deleted_rows) | 173 for (const auto& row : deleted_rows) |
174 needs_to_be_cached_ |= private_data_->DeleteURL(row.url()); | 174 needs_to_be_cached_ |= private_data_->DeleteURL(row.url()); |
175 } | 175 } |
176 // If we made changes, destroy the previous cache. Otherwise, if we go | 176 // If we made changes, destroy the previous cache. Otherwise, if we go |
177 // through an unclean shutdown (and therefore fail to write a new cache file), | 177 // through an unclean shutdown (and therefore fail to write a new cache file), |
178 // when Chrome restarts and we restore from the previous cache, we'll end up | 178 // when Chrome restarts and we restore from the previous cache, we'll end up |
179 // searching over URLs that may be deleted. This would be wrong, and | 179 // searching over URLs that may be deleted. This would be wrong, and |
180 // surprising to the user who bothered to delete some URLs from his/her | 180 // surprising to the user who bothered to delete some URLs from their |
181 // history. In this situation, deleting the cache is a better solution than | 181 // history. In this situation, deleting the cache is a better solution than |
182 // writing a new cache (after deleting the URLs from the in-memory structure) | 182 // writing a new cache (after deleting the URLs from the in-memory structure) |
183 // because deleting the cache forces it to be rebuilt from history upon | 183 // because deleting the cache forces it to be rebuilt from history upon |
184 // startup. If we instead write a new, updated cache then at the time of next | 184 // startup. If we instead write a new, updated cache then at the time of next |
185 // startup (after an unclean shutdown) we will not rebuild the in-memory data | 185 // startup (after an unclean shutdown) we will not rebuild the in-memory data |
186 // structures from history but rather use the cache. This solution is | 186 // structures from history but rather use the cache. This solution is |
187 // mediocre because this cache may not have the most-recently-visited URLs | 187 // mediocre because this cache may not have the most-recently-visited URLs |
188 // in it (URLs visited after user deleted some URLs from history), which | 188 // in it (URLs visited after user deleted some URLs from history), which |
189 // would be odd and confusing. It's better to force a rebuild. | 189 // would be odd and confusing. It's better to force a rebuild. |
190 base::FilePath path; | 190 base::FilePath path; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 task_runner_->PostTask( | 330 task_runner_->PostTask( |
331 FROM_HERE, | 331 FROM_HERE, |
332 base::Bind(base::IgnoreResult(base::DeleteFile), path, false)); | 332 base::Bind(base::IgnoreResult(base::DeleteFile), path, false)); |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 336 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
337 if (save_cache_observer_) | 337 if (save_cache_observer_) |
338 save_cache_observer_->OnCacheSaveFinished(succeeded); | 338 save_cache_observer_->OnCacheSaveFinished(succeeded); |
339 } | 339 } |
OLD | NEW |