| 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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 | 884 |
| 885 if (typed_url_syncable_service_.get()) | 885 if (typed_url_syncable_service_.get()) |
| 886 typed_url_syncable_service_->OnUrlsModified(&modified->changed_urls); | 886 typed_url_syncable_service_->OnUrlsModified(&modified->changed_urls); |
| 887 | 887 |
| 888 // Broadcast a notification for typed URLs that have been modified. This | 888 // Broadcast a notification for typed URLs that have been modified. This |
| 889 // will be picked up by the in-memory URL database on the main thread. | 889 // will be picked up by the in-memory URL database on the main thread. |
| 890 // | 890 // |
| 891 // TODO(brettw) bug 1140015: Add an "add page" notification so the history | 891 // TODO(brettw) bug 1140015: Add an "add page" notification so the history |
| 892 // views can keep in sync. | 892 // views can keep in sync. |
| 893 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, | 893 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
| 894 modified.PassAs<HistoryDetails>()); | 894 modified.Pass()); |
| 895 | 895 |
| 896 ScheduleCommit(); | 896 ScheduleCommit(); |
| 897 } | 897 } |
| 898 | 898 |
| 899 bool HistoryBackend::IsExpiredVisitTime(const base::Time& time) { | 899 bool HistoryBackend::IsExpiredVisitTime(const base::Time& time) { |
| 900 return time < expirer_.GetCurrentExpirationTime(); | 900 return time < expirer_.GetCurrentExpirationTime(); |
| 901 } | 901 } |
| 902 | 902 |
| 903 void HistoryBackend::SetPageTitle(const GURL& url, | 903 void HistoryBackend::SetPageTitle(const GURL& url, |
| 904 const base::string16& title) { | 904 const base::string16& title) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 934 details->changed_urls.push_back(row); | 934 details->changed_urls.push_back(row); |
| 935 } | 935 } |
| 936 } | 936 } |
| 937 | 937 |
| 938 // Broadcast notifications for any URLs that have changed. This will | 938 // Broadcast notifications for any URLs that have changed. This will |
| 939 // update the in-memory database and the InMemoryURLIndex. | 939 // update the in-memory database and the InMemoryURLIndex. |
| 940 if (!details->changed_urls.empty()) { | 940 if (!details->changed_urls.empty()) { |
| 941 if (typed_url_syncable_service_.get()) | 941 if (typed_url_syncable_service_.get()) |
| 942 typed_url_syncable_service_->OnUrlsModified(&details->changed_urls); | 942 typed_url_syncable_service_->OnUrlsModified(&details->changed_urls); |
| 943 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, | 943 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
| 944 details.PassAs<HistoryDetails>()); | 944 details.Pass()); |
| 945 ScheduleCommit(); | 945 ScheduleCommit(); |
| 946 } | 946 } |
| 947 } | 947 } |
| 948 | 948 |
| 949 void HistoryBackend::AddPageNoVisitForBookmark(const GURL& url, | 949 void HistoryBackend::AddPageNoVisitForBookmark(const GURL& url, |
| 950 const base::string16& title) { | 950 const base::string16& title) { |
| 951 if (!db_) | 951 if (!db_) |
| 952 return; | 952 return; |
| 953 | 953 |
| 954 URLRow url_info(url); | 954 URLRow url_info(url); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 details->changed_urls.push_back(*it); | 1020 details->changed_urls.push_back(*it); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 // Broadcast notifications for any URLs that have actually been changed. This | 1023 // Broadcast notifications for any URLs that have actually been changed. This |
| 1024 // will update the in-memory database and the InMemoryURLIndex. | 1024 // will update the in-memory database and the InMemoryURLIndex. |
| 1025 size_t num_updated_records = details->changed_urls.size(); | 1025 size_t num_updated_records = details->changed_urls.size(); |
| 1026 if (num_updated_records) { | 1026 if (num_updated_records) { |
| 1027 if (typed_url_syncable_service_) | 1027 if (typed_url_syncable_service_) |
| 1028 typed_url_syncable_service_->OnUrlsModified(&details->changed_urls); | 1028 typed_url_syncable_service_->OnUrlsModified(&details->changed_urls); |
| 1029 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, | 1029 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
| 1030 details.PassAs<HistoryDetails>()); | 1030 details.Pass()); |
| 1031 ScheduleCommit(); | 1031 ScheduleCommit(); |
| 1032 } | 1032 } |
| 1033 return num_updated_records; | 1033 return num_updated_records; |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 bool HistoryBackend::AddVisits(const GURL& url, | 1036 bool HistoryBackend::AddVisits(const GURL& url, |
| 1037 const std::vector<VisitInfo>& visits, | 1037 const std::vector<VisitInfo>& visits, |
| 1038 VisitSource visit_source) { | 1038 VisitSource visit_source) { |
| 1039 if (db_) { | 1039 if (db_) { |
| 1040 for (std::vector<VisitInfo>::const_iterator visit = visits.begin(); | 1040 for (std::vector<VisitInfo>::const_iterator visit = visits.begin(); |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2604 kept_urls.clear(); | 2604 kept_urls.clear(); |
| 2605 | 2605 |
| 2606 db_->GetStartDate(&first_recorded_time_); | 2606 db_->GetStartDate(&first_recorded_time_); |
| 2607 | 2607 |
| 2608 // Send out the notification that history is cleared. The in-memory database | 2608 // Send out the notification that history is cleared. The in-memory database |
| 2609 // will pick this up and clear itself. | 2609 // will pick this up and clear itself. |
| 2610 scoped_ptr<URLsDeletedDetails> details(new URLsDeletedDetails); | 2610 scoped_ptr<URLsDeletedDetails> details(new URLsDeletedDetails); |
| 2611 details->all_history = true; | 2611 details->all_history = true; |
| 2612 NotifySyncURLsDeleted(true, false, NULL); | 2612 NotifySyncURLsDeleted(true, false, NULL); |
| 2613 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_DELETED, | 2613 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
| 2614 details.PassAs<HistoryDetails>()); | 2614 details.Pass()); |
| 2615 } | 2615 } |
| 2616 | 2616 |
| 2617 bool HistoryBackend::ClearAllThumbnailHistory(const URLRows& kept_urls) { | 2617 bool HistoryBackend::ClearAllThumbnailHistory(const URLRows& kept_urls) { |
| 2618 if (!thumbnail_db_) { | 2618 if (!thumbnail_db_) { |
| 2619 // When we have no reference to the thumbnail database, maybe there was an | 2619 // When we have no reference to the thumbnail database, maybe there was an |
| 2620 // error opening it. In this case, we just try to blow it away to try to | 2620 // error opening it. In this case, we just try to blow it away to try to |
| 2621 // fix the error if it exists. This may fail, in which case either the | 2621 // fix the error if it exists. This may fail, in which case either the |
| 2622 // file doesn't exist or there's no more we can do. | 2622 // file doesn't exist or there's no more we can do. |
| 2623 sql::Connection::Delete(GetFaviconsFileName()); | 2623 sql::Connection::Delete(GetFaviconsFileName()); |
| 2624 | 2624 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2726 int rank = kPageVisitStatsMaxTopSites; | 2726 int rank = kPageVisitStatsMaxTopSites; |
| 2727 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); | 2727 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); |
| 2728 if (it != most_visited_urls_map_.end()) | 2728 if (it != most_visited_urls_map_.end()) |
| 2729 rank = (*it).second; | 2729 rank = (*it).second; |
| 2730 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", | 2730 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", |
| 2731 rank, kPageVisitStatsMaxTopSites + 1); | 2731 rank, kPageVisitStatsMaxTopSites + 1); |
| 2732 } | 2732 } |
| 2733 #endif | 2733 #endif |
| 2734 | 2734 |
| 2735 } // namespace history | 2735 } // namespace history |
| OLD | NEW |