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 // The history system runs on a background thread so that potentially slow | 5 // The history system runs on a background thread so that potentially slow |
6 // database operations don't delay the browser. This backend processing is | 6 // database operations don't delay the browser. This backend processing is |
7 // represented by HistoryBackend. The HistoryService's job is to dispatch to | 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to |
8 // that thread. | 8 // that thread. |
9 // | 9 // |
10 // Main thread History thread | 10 // Main thread History thread |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "base/path_service.h" | 30 #include "base/path_service.h" |
31 #include "base/prefs/pref_service.h" | 31 #include "base/prefs/pref_service.h" |
32 #include "base/thread_task_runner_handle.h" | 32 #include "base/thread_task_runner_handle.h" |
33 #include "base/threading/thread.h" | 33 #include "base/threading/thread.h" |
34 #include "base/time/time.h" | 34 #include "base/time/time.h" |
35 #include "chrome/browser/autocomplete/history_url_provider.h" | 35 #include "chrome/browser/autocomplete/history_url_provider.h" |
36 #include "chrome/browser/bookmarks/bookmark_model.h" | 36 #include "chrome/browser/bookmarks/bookmark_model.h" |
37 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 37 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
38 #include "chrome/browser/browser_process.h" | 38 #include "chrome/browser/browser_process.h" |
39 #include "chrome/browser/chrome_notification_types.h" | 39 #include "chrome/browser/chrome_notification_types.h" |
| 40 #include "chrome/browser/extensions/activity_log/activity_log.h" |
40 #include "chrome/browser/history/download_row.h" | 41 #include "chrome/browser/history/download_row.h" |
41 #include "chrome/browser/history/history_backend.h" | 42 #include "chrome/browser/history/history_backend.h" |
42 #include "chrome/browser/history/history_notifications.h" | 43 #include "chrome/browser/history/history_notifications.h" |
43 #include "chrome/browser/history/history_types.h" | 44 #include "chrome/browser/history/history_types.h" |
44 #include "chrome/browser/history/in_memory_database.h" | 45 #include "chrome/browser/history/in_memory_database.h" |
45 #include "chrome/browser/history/in_memory_history_backend.h" | 46 #include "chrome/browser/history/in_memory_history_backend.h" |
46 #include "chrome/browser/history/in_memory_url_index.h" | 47 #include "chrome/browser/history/in_memory_url_index.h" |
47 #include "chrome/browser/history/top_sites.h" | 48 #include "chrome/browser/history/top_sites.h" |
48 #include "chrome/browser/history/visit_database.h" | 49 #include "chrome/browser/history/visit_database.h" |
49 #include "chrome/browser/history/visit_filter.h" | 50 #include "chrome/browser/history/visit_filter.h" |
(...skipping 10 matching lines...) Expand all Loading... |
60 #include "components/visitedlink/browser/visitedlink_master.h" | 61 #include "components/visitedlink/browser/visitedlink_master.h" |
61 #include "content/public/browser/browser_thread.h" | 62 #include "content/public/browser/browser_thread.h" |
62 #include "content/public/browser/download_item.h" | 63 #include "content/public/browser/download_item.h" |
63 #include "content/public/browser/notification_service.h" | 64 #include "content/public/browser/notification_service.h" |
64 #include "grit/chromium_strings.h" | 65 #include "grit/chromium_strings.h" |
65 #include "grit/generated_resources.h" | 66 #include "grit/generated_resources.h" |
66 #include "sync/api/sync_error_factory.h" | 67 #include "sync/api/sync_error_factory.h" |
67 #include "third_party/skia/include/core/SkBitmap.h" | 68 #include "third_party/skia/include/core/SkBitmap.h" |
68 | 69 |
69 using base::Time; | 70 using base::Time; |
| 71 using extensions::ActivityLog; |
70 using history::HistoryBackend; | 72 using history::HistoryBackend; |
71 | 73 |
72 namespace { | 74 namespace { |
73 | 75 |
74 static const char* kHistoryThreadName = "Chrome_HistoryThread"; | 76 static const char* kHistoryThreadName = "Chrome_HistoryThread"; |
75 | 77 |
76 template<typename PODType> void DerefPODType( | 78 template<typename PODType> void DerefPODType( |
77 const base::Callback<void(PODType)>& callback, PODType* pod_value) { | 79 const base::Callback<void(PODType)>& callback, PODType* pod_value) { |
78 callback.Run(*pod_value); | 80 callback.Run(*pod_value); |
79 } | 81 } |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 } | 1070 } |
1069 ShowProfileErrorDialog( | 1071 ShowProfileErrorDialog( |
1070 (init_status == sql::INIT_FAILURE) ? | 1072 (init_status == sql::INIT_FAILURE) ? |
1071 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); | 1073 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); |
1072 } | 1074 } |
1073 | 1075 |
1074 void HistoryService::DeleteURL(const GURL& url) { | 1076 void HistoryService::DeleteURL(const GURL& url) { |
1075 DCHECK(thread_checker_.CalledOnValidThread()); | 1077 DCHECK(thread_checker_.CalledOnValidThread()); |
1076 // We will update the visited links when we observe the delete notifications. | 1078 // We will update the visited links when we observe the delete notifications. |
1077 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURL, url); | 1079 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURL, url); |
| 1080 |
| 1081 // Also clean up this url from the activity log database. |
| 1082 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); |
| 1083 if (activity_log) { |
| 1084 activity_log->RemoveURL(url); |
| 1085 } |
1078 } | 1086 } |
1079 | 1087 |
1080 void HistoryService::DeleteURLsForTest(const std::vector<GURL>& urls) { | 1088 void HistoryService::DeleteURLsForTest(const std::vector<GURL>& urls) { |
1081 DCHECK(thread_checker_.CalledOnValidThread()); | 1089 DCHECK(thread_checker_.CalledOnValidThread()); |
1082 // We will update the visited links when we observe the delete | 1090 // We will update the visited links when we observe the delete |
1083 // notifications. | 1091 // notifications. |
1084 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURLs, urls); | 1092 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURLs, urls); |
| 1093 |
| 1094 // Also clean up these urls from the activity log database. |
| 1095 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); |
| 1096 if (activity_log) { |
| 1097 activity_log->RemoveURLs(urls); |
| 1098 } |
1085 } | 1099 } |
1086 | 1100 |
1087 void HistoryService::ExpireHistoryBetween( | 1101 void HistoryService::ExpireHistoryBetween( |
1088 const std::set<GURL>& restrict_urls, | 1102 const std::set<GURL>& restrict_urls, |
1089 Time begin_time, | 1103 Time begin_time, |
1090 Time end_time, | 1104 Time end_time, |
1091 const base::Closure& callback, | 1105 const base::Closure& callback, |
1092 CancelableTaskTracker* tracker) { | 1106 CancelableTaskTracker* tracker) { |
1093 DCHECK(thread_); | 1107 DCHECK(thread_); |
1094 DCHECK(thread_checker_.CalledOnValidThread()); | 1108 DCHECK(thread_checker_.CalledOnValidThread()); |
1095 DCHECK(history_backend_.get()); | 1109 DCHECK(history_backend_.get()); |
1096 tracker->PostTaskAndReply(thread_->message_loop_proxy().get(), | 1110 tracker->PostTaskAndReply(thread_->message_loop_proxy().get(), |
1097 FROM_HERE, | 1111 FROM_HERE, |
1098 base::Bind(&HistoryBackend::ExpireHistoryBetween, | 1112 base::Bind(&HistoryBackend::ExpireHistoryBetween, |
1099 history_backend_, | 1113 history_backend_, |
1100 restrict_urls, | 1114 restrict_urls, |
1101 begin_time, | 1115 begin_time, |
1102 end_time), | 1116 end_time), |
1103 callback); | 1117 callback); |
| 1118 |
| 1119 // Also clean up these urls from the activity log database. |
| 1120 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); |
| 1121 if (activity_log) { |
| 1122 activity_log->RemoveURLs(restrict_urls); |
| 1123 } |
1104 } | 1124 } |
1105 | 1125 |
1106 void HistoryService::ExpireHistory( | 1126 void HistoryService::ExpireHistory( |
1107 const std::vector<history::ExpireHistoryArgs>& expire_list, | 1127 const std::vector<history::ExpireHistoryArgs>& expire_list, |
1108 const base::Closure& callback, | 1128 const base::Closure& callback, |
1109 CancelableTaskTracker* tracker) { | 1129 CancelableTaskTracker* tracker) { |
1110 DCHECK(thread_); | 1130 DCHECK(thread_); |
1111 DCHECK(thread_checker_.CalledOnValidThread()); | 1131 DCHECK(thread_checker_.CalledOnValidThread()); |
1112 DCHECK(history_backend_.get()); | 1132 DCHECK(history_backend_.get()); |
1113 tracker->PostTaskAndReply( | 1133 tracker->PostTaskAndReply( |
1114 thread_->message_loop_proxy().get(), | 1134 thread_->message_loop_proxy().get(), |
1115 FROM_HERE, | 1135 FROM_HERE, |
1116 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), | 1136 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), |
1117 callback); | 1137 callback); |
| 1138 |
| 1139 // Also remove the URLs from the activity log database. |
| 1140 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); |
| 1141 if (activity_log) { |
| 1142 for (std::vector<history::ExpireHistoryArgs>::const_iterator it = |
| 1143 expire_list.begin(); it != expire_list.end(); ++it) { |
| 1144 activity_log->RemoveURLs(it->urls); |
| 1145 } |
| 1146 } |
1118 } | 1147 } |
1119 | 1148 |
1120 void HistoryService::ExpireLocalAndRemoteHistoryBetween( | 1149 void HistoryService::ExpireLocalAndRemoteHistoryBetween( |
1121 const std::set<GURL>& restrict_urls, | 1150 const std::set<GURL>& restrict_urls, |
1122 Time begin_time, | 1151 Time begin_time, |
1123 Time end_time, | 1152 Time end_time, |
1124 const base::Closure& callback, | 1153 const base::Closure& callback, |
1125 CancelableTaskTracker* tracker) { | 1154 CancelableTaskTracker* tracker) { |
1126 // TODO(dubroy): This should be factored out into a separate class that | 1155 // TODO(dubroy): This should be factored out into a separate class that |
1127 // dispatches deletions to the proper places. | 1156 // dispatches deletions to the proper places. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 DCHECK(thread_checker_.CalledOnValidThread()); | 1258 DCHECK(thread_checker_.CalledOnValidThread()); |
1230 visit_database_observers_.RemoveObserver(observer); | 1259 visit_database_observers_.RemoveObserver(observer); |
1231 } | 1260 } |
1232 | 1261 |
1233 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 1262 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
1234 const history::BriefVisitInfo& info) { | 1263 const history::BriefVisitInfo& info) { |
1235 DCHECK(thread_checker_.CalledOnValidThread()); | 1264 DCHECK(thread_checker_.CalledOnValidThread()); |
1236 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, | 1265 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, |
1237 OnAddVisit(info)); | 1266 OnAddVisit(info)); |
1238 } | 1267 } |
OLD | NEW |