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 <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/files/file_enumerator.h" | 17 #include "base/files/file_enumerator.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
20 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
21 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
22 #include "base/rand_util.h" | 22 #include "base/rand_util.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
26 #include "chrome/browser/autocomplete/history_url_provider.h" | |
27 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
28 #include "chrome/browser/favicon/favicon_changed_details.h" | 27 #include "chrome/browser/favicon/favicon_changed_details.h" |
29 #include "chrome/browser/history/download_row.h" | 28 #include "chrome/browser/history/download_row.h" |
30 #include "chrome/browser/history/history_db_task.h" | 29 #include "chrome/browser/history/history_db_task.h" |
31 #include "chrome/browser/history/history_notifications.h" | 30 #include "chrome/browser/history/history_notifications.h" |
32 #include "chrome/browser/history/in_memory_history_backend.h" | 31 #include "chrome/browser/history/in_memory_history_backend.h" |
33 #include "chrome/browser/history/page_usage_data.h" | 32 #include "chrome/browser/history/page_usage_data.h" |
34 #include "chrome/browser/history/top_sites.h" | 33 #include "chrome/browser/history/top_sites.h" |
35 #include "chrome/browser/history/typed_url_syncable_service.h" | 34 #include "chrome/browser/history/typed_url_syncable_service.h" |
36 #include "chrome/browser/history/visit_filter.h" | 35 #include "chrome/browser/history/visit_filter.h" |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 while (db_->GetRedirectToVisit(cur_visit, &cur_visit, &cur_url)) { | 1456 while (db_->GetRedirectToVisit(cur_visit, &cur_visit, &cur_url)) { |
1458 if (visit_set.find(cur_visit) != visit_set.end()) { | 1457 if (visit_set.find(cur_visit) != visit_set.end()) { |
1459 NOTREACHED() << "Loop in visit chain, giving up"; | 1458 NOTREACHED() << "Loop in visit chain, giving up"; |
1460 return; | 1459 return; |
1461 } | 1460 } |
1462 visit_set.insert(cur_visit); | 1461 visit_set.insert(cur_visit); |
1463 redirects->push_back(cur_url); | 1462 redirects->push_back(cur_url); |
1464 } | 1463 } |
1465 } | 1464 } |
1466 | 1465 |
1467 void HistoryBackend::ScheduleAutocomplete(HistoryURLProvider* provider, | 1466 void HistoryBackend::ScheduleAutocomplete(const base::Callback< |
1468 HistoryURLProviderParams* params) { | 1467 void(history::HistoryBackend*, history::URLDatabase*)>& callback) { |
1469 // ExecuteWithDB should handle the NULL database case. | 1468 callback.Run(this, db_.get()); |
1470 provider->ExecuteWithDB(this, db_.get(), params); | |
1471 } | 1469 } |
1472 | 1470 |
1473 void HistoryBackend::DeleteFTSIndexDatabases() { | 1471 void HistoryBackend::DeleteFTSIndexDatabases() { |
1474 // Find files on disk matching the text databases file pattern so we can | 1472 // Find files on disk matching the text databases file pattern so we can |
1475 // quickly test for and delete them. | 1473 // quickly test for and delete them. |
1476 base::FilePath::StringType filepattern = | 1474 base::FilePath::StringType filepattern = |
1477 FILE_PATH_LITERAL("History Index *"); | 1475 FILE_PATH_LITERAL("History Index *"); |
1478 base::FileEnumerator enumerator( | 1476 base::FileEnumerator enumerator( |
1479 history_dir_, false, base::FileEnumerator::FILES, filepattern); | 1477 history_dir_, false, base::FileEnumerator::FILES, filepattern); |
1480 int num_databases_deleted = 0; | 1478 int num_databases_deleted = 0; |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 int rank = kPageVisitStatsMaxTopSites; | 2741 int rank = kPageVisitStatsMaxTopSites; |
2744 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); | 2742 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); |
2745 if (it != most_visited_urls_map_.end()) | 2743 if (it != most_visited_urls_map_.end()) |
2746 rank = (*it).second; | 2744 rank = (*it).second; |
2747 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", | 2745 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", |
2748 rank, kPageVisitStatsMaxTopSites + 1); | 2746 rank, kPageVisitStatsMaxTopSites + 1); |
2749 } | 2747 } |
2750 #endif | 2748 #endif |
2751 | 2749 |
2752 } // namespace history | 2750 } // namespace history |
OLD | NEW |