OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 // bother. | 778 // bother. |
779 bool has_indexed = false; | 779 bool has_indexed = false; |
780 if (text_database_.get()) { | 780 if (text_database_.get()) { |
781 // We do not have to make it update the visit database, below, we will | 781 // We do not have to make it update the visit database, below, we will |
782 // create the visit entry with the indexed flag set. | 782 // create the visit entry with the indexed flag set. |
783 has_indexed = text_database_->AddPageData(i->url(), url_id, 0, | 783 has_indexed = text_database_->AddPageData(i->url(), url_id, 0, |
784 i->last_visit(), | 784 i->last_visit(), |
785 i->title(), string16()); | 785 i->title(), string16()); |
786 } | 786 } |
787 | 787 |
788 // Make up a visit to correspond to that page. | 788 // Sync code manages the visits itself. |
789 VisitRow visit_info(url_id, i->last_visit(), 0, | 789 if (visit_source != SOURCE_SYNCED) { |
790 PageTransition::LINK | PageTransition::CHAIN_START | | 790 // Make up a visit to correspond to the last visit to the page. |
791 PageTransition::CHAIN_END, 0); | 791 VisitRow visit_info(url_id, i->last_visit(), 0, |
792 visit_info.is_indexed = has_indexed; | 792 PageTransition::LINK | PageTransition::CHAIN_START | |
793 if (!visit_database->AddVisit(&visit_info, visit_source)) { | 793 PageTransition::CHAIN_END, 0); |
794 NOTREACHED() << "Adding visit failed."; | 794 visit_info.is_indexed = has_indexed; |
795 return; | 795 if (!visit_database->AddVisit(&visit_info, visit_source)) { |
| 796 NOTREACHED() << "Adding visit failed."; |
| 797 return; |
| 798 } |
| 799 |
| 800 if (visit_info.visit_time < first_recorded_time_) |
| 801 first_recorded_time_ = visit_info.visit_time; |
796 } | 802 } |
797 | |
798 if (visit_info.visit_time < first_recorded_time_) | |
799 first_recorded_time_ = visit_info.visit_time; | |
800 } | 803 } |
801 | 804 |
802 // Broadcast a notification for typed URLs that have been modified. This | 805 // Broadcast a notification for typed URLs that have been modified. This |
803 // will be picked up by the in-memory URL database on the main thread. | 806 // will be picked up by the in-memory URL database on the main thread. |
804 // | 807 // |
805 // TODO(brettw) bug 1140015: Add an "add page" notification so the history | 808 // TODO(brettw) bug 1140015: Add an "add page" notification so the history |
806 // views can keep in sync. | 809 // views can keep in sync. |
807 BroadcastNotifications(NotificationType::HISTORY_TYPED_URLS_MODIFIED, | 810 BroadcastNotifications(NotificationType::HISTORY_TYPED_URLS_MODIFIED, |
808 modified.release()); | 811 modified.release()); |
809 | 812 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 return false; | 920 return false; |
918 } | 921 } |
919 | 922 |
920 bool HistoryBackend::UpdateURL(URLID id, const history::URLRow& url) { | 923 bool HistoryBackend::UpdateURL(URLID id, const history::URLRow& url) { |
921 if (db_.get()) | 924 if (db_.get()) |
922 return db_->UpdateURLRow(id, url); | 925 return db_->UpdateURLRow(id, url); |
923 return false; | 926 return false; |
924 } | 927 } |
925 | 928 |
926 bool HistoryBackend::AddVisits(const GURL& url, | 929 bool HistoryBackend::AddVisits(const GURL& url, |
927 const std::vector<base::Time>& visits, | 930 const std::vector<VisitInfo>& visits, |
928 VisitSource visit_source) { | 931 VisitSource visit_source) { |
929 if (db_.get()) { | 932 if (db_.get()) { |
930 for (std::vector<base::Time>::const_iterator visit = visits.begin(); | 933 for (std::vector<VisitInfo>::const_iterator visit = visits.begin(); |
931 visit != visits.end(); ++visit) { | 934 visit != visits.end(); ++visit) { |
932 if (!AddPageVisit(url, *visit, 0, 0, visit_source).first) { | 935 if (!AddPageVisit( |
| 936 url, visit->first, 0, visit->second, visit_source).first) { |
933 return false; | 937 return false; |
934 } | 938 } |
935 } | 939 } |
936 ScheduleCommit(); | 940 ScheduleCommit(); |
937 return true; | 941 return true; |
938 } | 942 } |
939 return false; | 943 return false; |
940 } | 944 } |
941 | 945 |
942 bool HistoryBackend::RemoveVisits(const VisitVector& visits) { | 946 bool HistoryBackend::RemoveVisits(const VisitVector& visits) { |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 return true; | 2250 return true; |
2247 } | 2251 } |
2248 | 2252 |
2249 BookmarkService* HistoryBackend::GetBookmarkService() { | 2253 BookmarkService* HistoryBackend::GetBookmarkService() { |
2250 if (bookmark_service_) | 2254 if (bookmark_service_) |
2251 bookmark_service_->BlockTillLoaded(); | 2255 bookmark_service_->BlockTillLoaded(); |
2252 return bookmark_service_; | 2256 return bookmark_service_; |
2253 } | 2257 } |
2254 | 2258 |
2255 } // namespace history | 2259 } // namespace history |
OLD | NEW |