| 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/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/time.h" | 21 #include "base/time.h" |
| 22 #include "chrome/browser/autocomplete/history_url_provider.h" | 22 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 23 #include "chrome/browser/bookmarks/bookmark_service.h" | 23 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 24 #include "chrome/browser/cancelable_request.h" | 24 #include "chrome/browser/cancelable_request.h" |
| 25 #include "chrome/browser/history/history_notifications.h" | 25 #include "chrome/browser/history/history_notifications.h" |
| 26 #include "chrome/browser/history/history_publisher.h" | 26 #include "chrome/browser/history/history_publisher.h" |
| 27 #include "chrome/browser/history/in_memory_history_backend.h" | 27 #include "chrome/browser/history/in_memory_history_backend.h" |
| 28 #include "chrome/browser/history/page_usage_data.h" | 28 #include "chrome/browser/history/page_usage_data.h" |
| 29 #include "chrome/browser/history/top_sites.h" | 29 #include "chrome/browser/history/top_sites.h" |
| 30 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/common/chrome_constants.h" | 31 #include "chrome/common/chrome_constants.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
| 33 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 33 #include "content/browser/download/download_persistent_store_info.h" | 35 #include "content/browser/download/download_persistent_store_info.h" |
| 34 #include "googleurl/src/gurl.h" | 36 #include "googleurl/src/gurl.h" |
| 35 #include "grit/chromium_strings.h" | 37 #include "grit/chromium_strings.h" |
| 36 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
| 37 #include "net/base/registry_controlled_domain.h" | 39 #include "net/base/registry_controlled_domain.h" |
| 38 | 40 |
| 39 using base::Time; | 41 using base::Time; |
| 40 using base::TimeDelta; | 42 using base::TimeDelta; |
| 41 using base::TimeTicks; | 43 using base::TimeTicks; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 bool track_unique_; | 195 bool track_unique_; |
| 194 | 196 |
| 195 // When track_unique_ is set, this is updated with every URL seen so far. | 197 // When track_unique_ is set, this is updated with every URL seen so far. |
| 196 std::set<GURL> unique_urls_; | 198 std::set<GURL> unique_urls_; |
| 197 | 199 |
| 198 DISALLOW_COPY_AND_ASSIGN(URLQuerier); | 200 DISALLOW_COPY_AND_ASSIGN(URLQuerier); |
| 199 }; | 201 }; |
| 200 | 202 |
| 201 // HistoryBackend -------------------------------------------------------------- | 203 // HistoryBackend -------------------------------------------------------------- |
| 202 | 204 |
| 203 HistoryBackend::HistoryBackend(const FilePath& history_dir, | 205 HistoryBackend::HistoryBackend(Profile* profile, |
| 206 const FilePath& history_dir, |
| 204 int id, | 207 int id, |
| 205 Delegate* delegate, | 208 Delegate* delegate, |
| 206 BookmarkService* bookmark_service) | 209 BookmarkService* bookmark_service) |
| 207 : delegate_(delegate), | 210 : delegate_(delegate), |
| 208 id_(id), | 211 id_(id), |
| 209 history_dir_(history_dir), | 212 history_dir_(history_dir), |
| 210 ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this, bookmark_service)), | 213 ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this, bookmark_service)), |
| 211 recent_redirects_(kMaxRedirectCount), | 214 recent_redirects_(kMaxRedirectCount), |
| 212 backend_destroy_message_loop_(NULL), | 215 backend_destroy_message_loop_(NULL), |
| 213 segment_queried_(false), | 216 segment_queried_(false), |
| 214 bookmark_service_(bookmark_service) { | 217 bookmark_service_(bookmark_service) { |
| 218 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 219 switches::kDisableHistoryQuickProvider)) |
| 220 in_memory_url_index_ = new InMemoryURLIndex(profile, history_dir_); |
| 215 } | 221 } |
| 216 | 222 |
| 217 HistoryBackend::~HistoryBackend() { | 223 HistoryBackend::~HistoryBackend() { |
| 218 DCHECK(!scheduled_commit_) << "Deleting without cleanup"; | 224 DCHECK(!scheduled_commit_) << "Deleting without cleanup"; |
| 219 ReleaseDBTasks(); | 225 ReleaseDBTasks(); |
| 220 | 226 |
| 221 // First close the databases before optionally running the "destroy" task. | 227 // First close the databases before optionally running the "destroy" task. |
| 222 if (db_.get()) { | 228 if (db_.get()) { |
| 223 // Commit the long-running transaction. | 229 // Commit the long-running transaction. |
| 224 db_->CommitTransaction(); | 230 db_->CommitTransaction(); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 // to delete the archived database and need to do so before we try to | 648 // to delete the archived database and need to do so before we try to |
| 643 // open the file. We can ignore any error (maybe the file doesn't exist). | 649 // open the file. We can ignore any error (maybe the file doesn't exist). |
| 644 file_util::Delete(archived_name, false); | 650 file_util::Delete(archived_name, false); |
| 645 } | 651 } |
| 646 archived_db_.reset(new ArchivedDatabase()); | 652 archived_db_.reset(new ArchivedDatabase()); |
| 647 if (!archived_db_->Init(archived_name)) { | 653 if (!archived_db_->Init(archived_name)) { |
| 648 LOG(WARNING) << "Could not initialize the archived database."; | 654 LOG(WARNING) << "Could not initialize the archived database."; |
| 649 archived_db_.reset(); | 655 archived_db_.reset(); |
| 650 } | 656 } |
| 651 | 657 |
| 658 if (in_memory_url_index_.get()) |
| 659 in_memory_url_index_->Init(languages); |
| 660 |
| 652 // Tell the expiration module about all the nice databases we made. This must | 661 // Tell the expiration module about all the nice databases we made. This must |
| 653 // happen before db_->Init() is called since the callback ForceArchiveHistory | 662 // happen before db_->Init() is called since the callback ForceArchiveHistory |
| 654 // may need to expire stuff. | 663 // may need to expire stuff. |
| 655 // | 664 // |
| 656 // *sigh*, this can all be cleaned up when that migration code is removed. | 665 // *sigh*, this can all be cleaned up when that migration code is removed. |
| 657 // The main DB initialization should intuitively be first (not that it | 666 // The main DB initialization should intuitively be first (not that it |
| 658 // actually matters) and the expirer should be set last. | 667 // actually matters) and the expirer should be set last. |
| 659 expirer_.SetDatabases(db_.get(), archived_db_.get(), | 668 expirer_.SetDatabases(db_.get(), archived_db_.get(), |
| 660 thumbnail_db_.get(), text_database_.get()); | 669 thumbnail_db_.get(), text_database_.get()); |
| 661 | 670 |
| (...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 break; | 2325 break; |
| 2317 } | 2326 } |
| 2318 } | 2327 } |
| 2319 } | 2328 } |
| 2320 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name | 2329 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name |
| 2321 TimeTicks::Now() - beginning_time); | 2330 TimeTicks::Now() - beginning_time); |
| 2322 return success; | 2331 return success; |
| 2323 } | 2332 } |
| 2324 | 2333 |
| 2325 } // namespace history | 2334 } // namespace history |
| OLD | NEW |