| 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> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/history/download_row.h" | 27 #include "chrome/browser/history/download_row.h" |
| 28 #include "chrome/browser/history/history_db_task.h" | 28 #include "chrome/browser/history/history_db_task.h" |
| 29 #include "chrome/browser/history/history_db_task.h" | 29 #include "chrome/browser/history/history_db_task.h" |
| 30 #include "chrome/browser/history/history_notifications.h" | 30 #include "chrome/browser/history/history_notifications.h" |
| 31 #include "chrome/browser/history/in_memory_history_backend.h" | 31 #include "chrome/browser/history/in_memory_history_backend.h" |
| 32 #include "chrome/browser/history/in_memory_history_backend.h" | 32 #include "chrome/browser/history/in_memory_history_backend.h" |
| 33 #include "chrome/browser/history/top_sites.h" | 33 #include "chrome/browser/history/top_sites.h" |
| 34 #include "chrome/browser/history/typed_url_syncable_service.h" | 34 #include "chrome/browser/history/typed_url_syncable_service.h" |
| 35 #include "chrome/browser/history/typed_url_syncable_service.h" | 35 #include "chrome/browser/history/typed_url_syncable_service.h" |
| 36 #include "chrome/browser/history/visit_filter.h" | 36 #include "chrome/browser/history/visit_filter.h" |
| 37 #include "chrome/common/chrome_constants.h" | |
| 38 #include "chrome/common/importer/imported_favicon_usage.h" | 37 #include "chrome/common/importer/imported_favicon_usage.h" |
| 39 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 40 #include "components/favicon_base/select_favicon_frames.h" | 39 #include "components/favicon_base/select_favicon_frames.h" |
| 41 #include "components/history/core/browser/history_backend_observer.h" | 40 #include "components/history/core/browser/history_backend_observer.h" |
| 42 #include "components/history/core/browser/history_client.h" | 41 #include "components/history/core/browser/history_client.h" |
| 42 #include "components/history/core/browser/history_constants.h" |
| 43 #include "components/history/core/browser/keyword_search_term.h" | 43 #include "components/history/core/browser/keyword_search_term.h" |
| 44 #include "components/history/core/browser/page_usage_data.h" | 44 #include "components/history/core/browser/page_usage_data.h" |
| 45 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 45 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 46 #include "sql/error_delegate_util.h" | 46 #include "sql/error_delegate_util.h" |
| 47 #include "third_party/skia/include/core/SkBitmap.h" | 47 #include "third_party/skia/include/core/SkBitmap.h" |
| 48 #include "ui/gfx/codec/png_codec.h" | 48 #include "ui/gfx/codec/png_codec.h" |
| 49 #include "url/gurl.h" | 49 #include "url/gurl.h" |
| 50 | 50 |
| 51 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
| 52 #include "chrome/browser/history/android/android_provider_backend.h" | 52 #include "chrome/browser/history/android/android_provider_backend.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // Release our reference to the delegate, this reference will be keeping the | 271 // Release our reference to the delegate, this reference will be keeping the |
| 272 // history service alive. | 272 // history service alive. |
| 273 delegate_.reset(); | 273 delegate_.reset(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) { | 276 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) { |
| 277 tracker_.ClearCachedDataForContextID(context_id); | 277 tracker_.ClearCachedDataForContextID(context_id); |
| 278 } | 278 } |
| 279 | 279 |
| 280 base::FilePath HistoryBackend::GetThumbnailFileName() const { | 280 base::FilePath HistoryBackend::GetThumbnailFileName() const { |
| 281 return history_dir_.Append(chrome::kThumbnailsFilename); | 281 return history_dir_.Append(history::kThumbnailsFilename); |
| 282 } | 282 } |
| 283 | 283 |
| 284 base::FilePath HistoryBackend::GetFaviconsFileName() const { | 284 base::FilePath HistoryBackend::GetFaviconsFileName() const { |
| 285 return history_dir_.Append(chrome::kFaviconsFilename); | 285 return history_dir_.Append(history::kFaviconsFilename); |
| 286 } | 286 } |
| 287 | 287 |
| 288 base::FilePath HistoryBackend::GetArchivedFileName() const { | 288 base::FilePath HistoryBackend::GetArchivedFileName() const { |
| 289 return history_dir_.Append(chrome::kArchivedHistoryFilename); | 289 return history_dir_.Append(history::kArchivedHistoryFilename); |
| 290 } | 290 } |
| 291 | 291 |
| 292 #if defined(OS_ANDROID) | 292 #if defined(OS_ANDROID) |
| 293 base::FilePath HistoryBackend::GetAndroidCacheFileName() const { | 293 base::FilePath HistoryBackend::GetAndroidCacheFileName() const { |
| 294 return history_dir_.Append(chrome::kAndroidCacheFilename); | 294 return history_dir_.Append(history::kAndroidCacheFilename); |
| 295 } | 295 } |
| 296 #endif | 296 #endif |
| 297 | 297 |
| 298 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { | 298 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { |
| 299 // Set is used to detect referrer loops. Should not happen, but can | 299 // Set is used to detect referrer loops. Should not happen, but can |
| 300 // if the database is corrupt. | 300 // if the database is corrupt. |
| 301 std::set<VisitID> visit_set; | 301 std::set<VisitID> visit_set; |
| 302 VisitID visit_id = from_visit; | 302 VisitID visit_id = from_visit; |
| 303 while (visit_id) { | 303 while (visit_id) { |
| 304 VisitRow row; | 304 VisitRow row; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 void HistoryBackend::InitImpl(const std::string& languages) { | 597 void HistoryBackend::InitImpl(const std::string& languages) { |
| 598 DCHECK(!db_) << "Initializing HistoryBackend twice"; | 598 DCHECK(!db_) << "Initializing HistoryBackend twice"; |
| 599 // In the rare case where the db fails to initialize a dialog may get shown | 599 // In the rare case where the db fails to initialize a dialog may get shown |
| 600 // the blocks the caller, yet allows other messages through. For this reason | 600 // the blocks the caller, yet allows other messages through. For this reason |
| 601 // we only set db_ to the created database if creation is successful. That | 601 // we only set db_ to the created database if creation is successful. That |
| 602 // way other methods won't do anything as db_ is still NULL. | 602 // way other methods won't do anything as db_ is still NULL. |
| 603 | 603 |
| 604 TimeTicks beginning_time = TimeTicks::Now(); | 604 TimeTicks beginning_time = TimeTicks::Now(); |
| 605 | 605 |
| 606 // Compute the file names. | 606 // Compute the file names. |
| 607 base::FilePath history_name = history_dir_.Append(chrome::kHistoryFilename); | 607 base::FilePath history_name = history_dir_.Append(history::kHistoryFilename); |
| 608 base::FilePath thumbnail_name = GetFaviconsFileName(); | 608 base::FilePath thumbnail_name = GetFaviconsFileName(); |
| 609 base::FilePath archived_name = GetArchivedFileName(); | 609 base::FilePath archived_name = GetArchivedFileName(); |
| 610 | 610 |
| 611 // Delete the old index database files which are no longer used. | 611 // Delete the old index database files which are no longer used. |
| 612 DeleteFTSIndexDatabases(); | 612 DeleteFTSIndexDatabases(); |
| 613 | 613 |
| 614 // History database. | 614 // History database. |
| 615 db_.reset(new HistoryDatabase()); | 615 db_.reset(new HistoryDatabase()); |
| 616 | 616 |
| 617 // Unretained to avoid a ref loop with db_. | 617 // Unretained to avoid a ref loop with db_. |
| (...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2739 int rank = kPageVisitStatsMaxTopSites; | 2739 int rank = kPageVisitStatsMaxTopSites; |
| 2740 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); | 2740 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); |
| 2741 if (it != most_visited_urls_map_.end()) | 2741 if (it != most_visited_urls_map_.end()) |
| 2742 rank = (*it).second; | 2742 rank = (*it).second; |
| 2743 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", | 2743 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", |
| 2744 rank, kPageVisitStatsMaxTopSites + 1); | 2744 rank, kPageVisitStatsMaxTopSites + 1); |
| 2745 } | 2745 } |
| 2746 #endif | 2746 #endif |
| 2747 | 2747 |
| 2748 } // namespace history | 2748 } // namespace history |
| OLD | NEW |