| 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 "chrome/browser/history/in_memory_url_index.h" | 5 #include "chrome/browser/history/in_memory_url_index.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/history/history_notifications.h" | 9 #include "chrome/browser/history/history_notifications.h" |
| 10 #include "chrome/browser/history/url_database.h" | 10 #include "chrome/browser/history/url_database.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 void InMemoryURLIndex::Init() { | 129 void InMemoryURLIndex::Init() { |
| 130 PostRestoreFromCacheFileTask(); | 130 PostRestoreFromCacheFileTask(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void InMemoryURLIndex::ShutDown() { | 133 void InMemoryURLIndex::ShutDown() { |
| 134 registrar_.RemoveAll(); | 134 registrar_.RemoveAll(); |
| 135 cache_reader_consumer_.CancelAllRequests(); | 135 cache_reader_consumer_.CancelAllRequests(); |
| 136 shutdown_ = true; | 136 shutdown_ = true; |
| 137 PostSaveToCacheFileTask(); | 137 FilePath path; |
| 138 if (!GetCacheFilePath(&path)) |
| 139 return; |
| 140 scoped_refptr<RefCountedBool> succeeded(new RefCountedBool(false)); |
| 141 URLIndexPrivateData::WritePrivateDataToCacheFileTask( |
| 142 private_data_, path, succeeded); |
| 138 needs_to_be_cached_ = false; | 143 needs_to_be_cached_ = false; |
| 139 } | 144 } |
| 140 | 145 |
| 141 void InMemoryURLIndex::ClearPrivateData() { | 146 void InMemoryURLIndex::ClearPrivateData() { |
| 142 private_data_->Clear(); | 147 private_data_->Clear(); |
| 143 } | 148 } |
| 144 | 149 |
| 145 bool InMemoryURLIndex::GetCacheFilePath(FilePath* file_path) { | 150 bool InMemoryURLIndex::GetCacheFilePath(FilePath* file_path) { |
| 146 if (history_dir_.empty()) | 151 if (history_dir_.empty()) |
| 147 return false; | 152 return false; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 314 } |
| 310 } | 315 } |
| 311 | 316 |
| 312 void InMemoryURLIndex::OnCacheSaveDone( | 317 void InMemoryURLIndex::OnCacheSaveDone( |
| 313 scoped_refptr<RefCountedBool> succeeded) { | 318 scoped_refptr<RefCountedBool> succeeded) { |
| 314 if (save_cache_observer_) | 319 if (save_cache_observer_) |
| 315 save_cache_observer_->OnCacheSaveFinished(succeeded->value()); | 320 save_cache_observer_->OnCacheSaveFinished(succeeded->value()); |
| 316 } | 321 } |
| 317 | 322 |
| 318 } // namespace history | 323 } // namespace history |
| OLD | NEW |