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> |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 if (visit_info.visit_time < first_recorded_time_) | 838 if (visit_info.visit_time < first_recorded_time_) |
839 first_recorded_time_ = visit_info.visit_time; | 839 first_recorded_time_ = visit_info.visit_time; |
840 } | 840 } |
841 } | 841 } |
842 | 842 |
843 // Broadcast a notification for typed URLs that have been modified. This | 843 // Broadcast a notification for typed URLs that have been modified. This |
844 // will be picked up by the in-memory URL database on the main thread. | 844 // will be picked up by the in-memory URL database on the main thread. |
845 // | 845 // |
846 // TODO(brettw) bug 1140015: Add an "add page" notification so the history | 846 // TODO(brettw) bug 1140015: Add an "add page" notification so the history |
847 // views can keep in sync. | 847 // views can keep in sync. |
848 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, | 848 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
849 modified.release()); | 849 modified.release()); |
850 | 850 |
851 ScheduleCommit(); | 851 ScheduleCommit(); |
852 } | 852 } |
853 | 853 |
854 bool HistoryBackend::IsExpiredVisitTime(const base::Time& time) { | 854 bool HistoryBackend::IsExpiredVisitTime(const base::Time& time) { |
855 return time < expirer_.GetCurrentArchiveTime(); | 855 return time < expirer_.GetCurrentArchiveTime(); |
856 } | 856 } |
857 | 857 |
858 void HistoryBackend::SetPageTitle(const GURL& url, | 858 void HistoryBackend::SetPageTitle(const GURL& url, |
(...skipping 13 matching lines...) Expand all Loading... | |
872 // This redirect chain should have the destination URL as the last item. | 872 // This redirect chain should have the destination URL as the last item. |
873 DCHECK(!redirects->empty()); | 873 DCHECK(!redirects->empty()); |
874 DCHECK(redirects->back() == url); | 874 DCHECK(redirects->back() == url); |
875 } else { | 875 } else { |
876 // No redirect chain stored, make up one containing the URL we want so we | 876 // No redirect chain stored, make up one containing the URL we want so we |
877 // can use the same logic below. | 877 // can use the same logic below. |
878 dummy_list.push_back(url); | 878 dummy_list.push_back(url); |
879 redirects = &dummy_list; | 879 redirects = &dummy_list; |
880 } | 880 } |
881 | 881 |
882 bool typed_url_changed = false; | |
883 URLRows changed_urls; | 882 URLRows changed_urls; |
Peter Kasting
2012/04/10 02:18:57
Nit: You can save copying the whole URLRows object
mrossetti
2012/04/11 19:38:55
Sweet!
On 2012/04/10 02:18:57, Peter Kasting wrot
| |
884 for (size_t i = 0; i < redirects->size(); i++) { | 883 for (size_t i = 0; i < redirects->size(); i++) { |
885 URLRow row; | 884 URLRow row; |
886 URLID row_id = db_->GetRowForURL(redirects->at(i), &row); | 885 URLID row_id = db_->GetRowForURL(redirects->at(i), &row); |
887 if (row_id && row.title() != title) { | 886 if (row_id && row.title() != title) { |
888 row.set_title(title); | 887 row.set_title(title); |
889 db_->UpdateURLRow(row_id, row); | 888 db_->UpdateURLRow(row_id, row); |
889 row.set_id(row_id); | |
sky
2012/04/10 16:29:01
Doesn't GetRowForURL set the id?
mrossetti
2012/04/11 19:38:55
Yes. Removed.
On 2012/04/10 16:29:01, sky wrote:
| |
890 changed_urls.push_back(row); | 890 changed_urls.push_back(row); |
891 if (row.typed_count() > 0) | |
892 typed_url_changed = true; | |
893 } | 891 } |
894 } | 892 } |
895 | 893 |
896 // Broadcast notifications for typed URLs that have changed. This will | 894 // Broadcast notifications for any URLs that have changed. This will |
897 // update the in-memory database. | 895 // update the in-memory database and the InMemoryURLIndex. |
898 // | 896 if (!changed_urls.empty()) { |
899 // TODO(brettw) bug 1140020: Broadcast for all changes (not just typed), | 897 URLsModifiedDetails* modified = new URLsModifiedDetails; |
900 // in which case some logic can be removed. | 898 modified->changed_urls = changed_urls; |
901 if (typed_url_changed) { | 899 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
902 URLsModifiedDetails* modified = | |
903 new URLsModifiedDetails; | |
904 for (size_t i = 0; i < changed_urls.size(); i++) { | |
905 if (changed_urls[i].typed_count() > 0) | |
906 modified->changed_urls.push_back(changed_urls[i]); | |
907 } | |
908 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, | |
909 modified); | 900 modified); |
910 } | 901 } |
911 | 902 |
912 // Update the full text index. | 903 // Update the full text index. |
913 if (text_database_.get()) | 904 if (text_database_.get()) |
914 text_database_->AddPageTitle(url, title); | 905 text_database_->AddPageTitle(url, title); |
915 | 906 |
916 // Only bother committing if things changed. | 907 // Only bother committing if things changed. |
917 if (!changed_urls.empty()) | 908 if (!changed_urls.empty()) |
918 ScheduleCommit(); | 909 ScheduleCommit(); |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2452 return false; | 2443 return false; |
2453 | 2444 |
2454 favicon->expired = (Time::Now() - last_updated) > | 2445 favicon->expired = (Time::Now() - last_updated) > |
2455 TimeDelta::FromDays(kFaviconRefetchDays); | 2446 TimeDelta::FromDays(kFaviconRefetchDays); |
2456 favicon->known_icon = true; | 2447 favicon->known_icon = true; |
2457 favicon->image_data = data; | 2448 favicon->image_data = data; |
2458 return true; | 2449 return true; |
2459 } | 2450 } |
2460 | 2451 |
2461 } // namespace history | 2452 } // namespace history |
OLD | NEW |