| 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/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 "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 if (history_service_) { | 115 if (history_service_) { |
| 116 history_service_->RemoveObserver(this); | 116 history_service_->RemoveObserver(this); |
| 117 history_service_ = nullptr; | 117 history_service_ = nullptr; |
| 118 } | 118 } |
| 119 cache_reader_tracker_.TryCancelAll(); | 119 cache_reader_tracker_.TryCancelAll(); |
| 120 shutdown_ = true; | 120 shutdown_ = true; |
| 121 base::FilePath path; | 121 base::FilePath path; |
| 122 if (!GetCacheFilePath(&path)) | 122 if (!GetCacheFilePath(&path)) |
| 123 return; | 123 return; |
| 124 private_data_tracker_.TryCancelAll(); | 124 private_data_tracker_.TryCancelAll(); |
| 125 URLIndexPrivateData::WritePrivateDataToCacheFileTask(private_data_, path); | 125 |
| 126 // During browser TearDown this method was called from a thread that can |
| 127 // perform FILE ops. Guest Profiles are closed on UI thread, so post a task. |
| 128 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)) |
| 129 URLIndexPrivateData::WritePrivateDataToCacheFileTask(private_data_, path); |
| 130 else |
| 131 PostSaveToCacheFileTask(); |
| 126 needs_to_be_cached_ = false; | 132 needs_to_be_cached_ = false; |
| 127 } | 133 } |
| 128 | 134 |
| 129 void InMemoryURLIndex::ClearPrivateData() { | 135 void InMemoryURLIndex::ClearPrivateData() { |
| 130 private_data_->Clear(); | 136 private_data_->Clear(); |
| 131 } | 137 } |
| 132 | 138 |
| 133 bool InMemoryURLIndex::GetCacheFilePath(base::FilePath* file_path) { | 139 bool InMemoryURLIndex::GetCacheFilePath(base::FilePath* file_path) { |
| 134 if (history_dir_.empty()) | 140 if (history_dir_.empty()) |
| 135 return false; | 141 return false; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 base::Bind(DeleteCacheFile, path)); | 330 base::Bind(DeleteCacheFile, path)); |
| 325 } | 331 } |
| 326 } | 332 } |
| 327 | 333 |
| 328 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 334 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
| 329 if (save_cache_observer_) | 335 if (save_cache_observer_) |
| 330 save_cache_observer_->OnCacheSaveFinished(succeeded); | 336 save_cache_observer_->OnCacheSaveFinished(succeeded); |
| 331 } | 337 } |
| 332 | 338 |
| 333 } // namespace history | 339 } // namespace history |
| OLD | NEW |