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 22 matching lines...) Expand all Loading... |
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" | 37 #include "chrome/common/chrome_constants.h" |
38 #include "chrome/common/importer/imported_favicon_usage.h" | 38 #include "chrome/common/importer/imported_favicon_usage.h" |
39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
40 #include "components/favicon_base/select_favicon_frames.h" | 40 #include "components/favicon_base/select_favicon_frames.h" |
41 #include "components/history/core/browser/history_backend_observer.h" | 41 #include "components/history/core/browser/history_backend_observer.h" |
42 #include "components/history/core/browser/history_client.h" | 42 #include "components/history/core/browser/history_client.h" |
| 43 #include "components/history/core/browser/history_constants.h" |
43 #include "components/history/core/browser/keyword_search_term.h" | 44 #include "components/history/core/browser/keyword_search_term.h" |
44 #include "components/history/core/browser/page_usage_data.h" | 45 #include "components/history/core/browser/page_usage_data.h" |
45 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 46 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
46 #include "sql/error_delegate_util.h" | 47 #include "sql/error_delegate_util.h" |
47 #include "third_party/skia/include/core/SkBitmap.h" | 48 #include "third_party/skia/include/core/SkBitmap.h" |
48 #include "ui/gfx/codec/png_codec.h" | 49 #include "ui/gfx/codec/png_codec.h" |
49 #include "url/gurl.h" | 50 #include "url/gurl.h" |
50 | 51 |
51 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
52 #include "chrome/browser/history/android/android_provider_backend.h" | 53 #include "chrome/browser/history/android/android_provider_backend.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // Release our reference to the delegate, this reference will be keeping the | 256 // Release our reference to the delegate, this reference will be keeping the |
256 // history service alive. | 257 // history service alive. |
257 delegate_.reset(); | 258 delegate_.reset(); |
258 } | 259 } |
259 | 260 |
260 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) { | 261 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) { |
261 tracker_.ClearCachedDataForContextID(context_id); | 262 tracker_.ClearCachedDataForContextID(context_id); |
262 } | 263 } |
263 | 264 |
264 base::FilePath HistoryBackend::GetThumbnailFileName() const { | 265 base::FilePath HistoryBackend::GetThumbnailFileName() const { |
265 return history_dir_.Append(chrome::kThumbnailsFilename); | 266 return history_dir_.Append(history::kThumbnailsFilename); |
266 } | 267 } |
267 | 268 |
268 base::FilePath HistoryBackend::GetFaviconsFileName() const { | 269 base::FilePath HistoryBackend::GetFaviconsFileName() const { |
269 return history_dir_.Append(chrome::kFaviconsFilename); | 270 return history_dir_.Append(history::kFaviconsFilename); |
270 } | 271 } |
271 | 272 |
272 base::FilePath HistoryBackend::GetArchivedFileName() const { | 273 base::FilePath HistoryBackend::GetArchivedFileName() const { |
273 return history_dir_.Append(chrome::kArchivedHistoryFilename); | 274 return history_dir_.Append(history::kArchivedHistoryFilename); |
274 } | 275 } |
275 | 276 |
276 #if defined(OS_ANDROID) | 277 #if defined(OS_ANDROID) |
277 base::FilePath HistoryBackend::GetAndroidCacheFileName() const { | 278 base::FilePath HistoryBackend::GetAndroidCacheFileName() const { |
278 return history_dir_.Append(chrome::kAndroidCacheFilename); | 279 return history_dir_.Append(history::kAndroidCacheFilename); |
279 } | 280 } |
280 #endif | 281 #endif |
281 | 282 |
282 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { | 283 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { |
283 // Set is used to detect referrer loops. Should not happen, but can | 284 // Set is used to detect referrer loops. Should not happen, but can |
284 // if the database is corrupt. | 285 // if the database is corrupt. |
285 std::set<VisitID> visit_set; | 286 std::set<VisitID> visit_set; |
286 VisitID visit_id = from_visit; | 287 VisitID visit_id = from_visit; |
287 while (visit_id) { | 288 while (visit_id) { |
288 VisitRow row; | 289 VisitRow row; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 void HistoryBackend::InitImpl(const std::string& languages) { | 582 void HistoryBackend::InitImpl(const std::string& languages) { |
582 DCHECK(!db_) << "Initializing HistoryBackend twice"; | 583 DCHECK(!db_) << "Initializing HistoryBackend twice"; |
583 // In the rare case where the db fails to initialize a dialog may get shown | 584 // In the rare case where the db fails to initialize a dialog may get shown |
584 // the blocks the caller, yet allows other messages through. For this reason | 585 // the blocks the caller, yet allows other messages through. For this reason |
585 // we only set db_ to the created database if creation is successful. That | 586 // we only set db_ to the created database if creation is successful. That |
586 // way other methods won't do anything as db_ is still NULL. | 587 // way other methods won't do anything as db_ is still NULL. |
587 | 588 |
588 TimeTicks beginning_time = TimeTicks::Now(); | 589 TimeTicks beginning_time = TimeTicks::Now(); |
589 | 590 |
590 // Compute the file names. | 591 // Compute the file names. |
591 base::FilePath history_name = history_dir_.Append(chrome::kHistoryFilename); | 592 base::FilePath history_name = history_dir_.Append(history::kHistoryFilename); |
592 base::FilePath thumbnail_name = GetFaviconsFileName(); | 593 base::FilePath thumbnail_name = GetFaviconsFileName(); |
593 base::FilePath archived_name = GetArchivedFileName(); | 594 base::FilePath archived_name = GetArchivedFileName(); |
594 | 595 |
595 // Delete the old index database files which are no longer used. | 596 // Delete the old index database files which are no longer used. |
596 DeleteFTSIndexDatabases(); | 597 DeleteFTSIndexDatabases(); |
597 | 598 |
598 // History database. | 599 // History database. |
599 db_.reset(new HistoryDatabase()); | 600 db_.reset(new HistoryDatabase()); |
600 | 601 |
601 // Unretained to avoid a ref loop with db_. | 602 // Unretained to avoid a ref loop with db_. |
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2690 info.url_id = visit.url_id; | 2691 info.url_id = visit.url_id; |
2691 info.time = visit.visit_time; | 2692 info.time = visit.visit_time; |
2692 info.transition = visit.transition; | 2693 info.transition = visit.transition; |
2693 // If we don't have a delegate yet during setup or shutdown, we will drop | 2694 // If we don't have a delegate yet during setup or shutdown, we will drop |
2694 // these notifications. | 2695 // these notifications. |
2695 if (delegate_) | 2696 if (delegate_) |
2696 delegate_->NotifyAddVisit(info); | 2697 delegate_->NotifyAddVisit(info); |
2697 } | 2698 } |
2698 | 2699 |
2699 } // namespace history | 2700 } // namespace history |
OLD | NEW |