Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 #include "chrome/browser/autocomplete/history_url_provider.h" | 26 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 27 #include "chrome/browser/bookmarks/bookmark_service.h" | 27 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 28 #include "chrome/browser/history/download_row.h" | 28 #include "chrome/browser/history/download_row.h" |
| 29 #include "chrome/browser/history/history_db_task.h" | 29 #include "chrome/browser/history/history_db_task.h" |
| 30 #include "chrome/browser/history/history_notifications.h" | 30 #include "chrome/browser/history/history_notifications.h" |
| 31 #include "chrome/browser/history/history_publisher.h" | 31 #include "chrome/browser/history/history_publisher.h" |
| 32 #include "chrome/browser/history/in_memory_history_backend.h" | 32 #include "chrome/browser/history/in_memory_history_backend.h" |
| 33 #include "chrome/browser/history/page_usage_data.h" | 33 #include "chrome/browser/history/page_usage_data.h" |
| 34 #include "chrome/browser/history/select_favicon_frames.h" | 34 #include "chrome/browser/history/select_favicon_frames.h" |
| 35 #include "chrome/browser/history/top_sites.h" | 35 #include "chrome/browser/history/top_sites.h" |
| 36 #include "chrome/browser/history/typed_url_syncable_service.h" | |
| 36 #include "chrome/browser/history/visit_filter.h" | 37 #include "chrome/browser/history/visit_filter.h" |
| 37 #include "chrome/common/chrome_constants.h" | 38 #include "chrome/common/chrome_constants.h" |
| 38 #include "chrome/common/chrome_notification_types.h" | 39 #include "chrome/common/chrome_notification_types.h" |
| 39 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
| 40 #include "googleurl/src/gurl.h" | 41 #include "googleurl/src/gurl.h" |
| 41 #include "grit/chromium_strings.h" | 42 #include "grit/chromium_strings.h" |
| 42 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 43 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 44 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 44 #include "sql/error_delegate_util.h" | 45 #include "sql/error_delegate_util.h" |
| 45 | 46 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 | 290 |
| 290 #if defined(OS_ANDROID) | 291 #if defined(OS_ANDROID) |
| 291 file_util::Delete(GetAndroidCacheFileName(), false); | 292 file_util::Delete(GetAndroidCacheFileName(), false); |
| 292 #endif | 293 #endif |
| 293 } | 294 } |
| 294 | 295 |
| 295 void HistoryBackend::Init(const std::string& languages, bool force_fail) { | 296 void HistoryBackend::Init(const std::string& languages, bool force_fail) { |
| 296 if (!force_fail) | 297 if (!force_fail) |
| 297 InitImpl(languages); | 298 InitImpl(languages); |
| 298 delegate_->DBLoaded(id_); | 299 delegate_->DBLoaded(id_); |
| 300 typed_url_syncable_service_.reset(new TypedUrlSyncableService(this)); | |
| 299 } | 301 } |
| 300 | 302 |
| 301 void HistoryBackend::SetOnBackendDestroyTask(MessageLoop* message_loop, | 303 void HistoryBackend::SetOnBackendDestroyTask(MessageLoop* message_loop, |
| 302 const base::Closure& task) { | 304 const base::Closure& task) { |
| 303 if (!backend_destroy_task_.is_null()) | 305 if (!backend_destroy_task_.is_null()) |
| 304 DLOG(WARNING) << "Setting more than one destroy task, overriding"; | 306 DLOG(WARNING) << "Setting more than one destroy task, overriding"; |
| 305 backend_destroy_message_loop_ = message_loop; | 307 backend_destroy_message_loop_ = message_loop; |
| 306 backend_destroy_task_ = task; | 308 backend_destroy_task_ = task; |
| 307 } | 309 } |
| 308 | 310 |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1167 success = true; | 1169 success = true; |
| 1168 | 1170 |
| 1169 // Optionally query the visits. | 1171 // Optionally query the visits. |
| 1170 if (want_visits) | 1172 if (want_visits) |
| 1171 db_->GetVisitsForURL(row->id(), visits); | 1173 db_->GetVisitsForURL(row->id(), visits); |
| 1172 } | 1174 } |
| 1173 } | 1175 } |
| 1174 request->ForwardResult(request->handle(), success, row, visits); | 1176 request->ForwardResult(request->handle(), success, row, visits); |
| 1175 } | 1177 } |
| 1176 | 1178 |
| 1179 TypedUrlSyncableService* HistoryBackend::GetTypedUrlSyncableService() const { | |
| 1180 return typed_url_syncable_service_.get(); | |
| 1181 } | |
| 1182 | |
| 1177 // Segment usage --------------------------------------------------------------- | 1183 // Segment usage --------------------------------------------------------------- |
| 1178 | 1184 |
| 1179 void HistoryBackend::DeleteOldSegmentData() { | 1185 void HistoryBackend::DeleteOldSegmentData() { |
| 1180 if (db_.get()) | 1186 if (db_.get()) |
| 1181 db_->DeleteSegmentData(Time::Now() - | 1187 db_->DeleteSegmentData(Time::Now() - |
| 1182 TimeDelta::FromDays(kSegmentDataRetention)); | 1188 TimeDelta::FromDays(kSegmentDataRetention)); |
| 1183 } | 1189 } |
| 1184 | 1190 |
| 1185 void HistoryBackend::QuerySegmentUsage( | 1191 void HistoryBackend::QuerySegmentUsage( |
| 1186 scoped_refptr<QuerySegmentUsageRequest> request, | 1192 scoped_refptr<QuerySegmentUsageRequest> request, |
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2853 if (!task_scheduled) { | 2859 if (!task_scheduled) { |
| 2854 // No other tasks are scheduled. Process request now. | 2860 // No other tasks are scheduled. Process request now. |
| 2855 ProcessDBTaskImpl(); | 2861 ProcessDBTaskImpl(); |
| 2856 } | 2862 } |
| 2857 } | 2863 } |
| 2858 | 2864 |
| 2859 void HistoryBackend::BroadcastNotifications( | 2865 void HistoryBackend::BroadcastNotifications( |
| 2860 int type, | 2866 int type, |
| 2861 HistoryDetails* details_deleted) { | 2867 HistoryDetails* details_deleted) { |
| 2862 // |delegate_| may be NULL if |this| is in the process of closing (closed by | 2868 // |delegate_| may be NULL if |this| is in the process of closing (closed by |
| 2863 // HistoryService -> HistroyBackend::Closing(). | 2869 // HistoryService -> HistoryBackend::Closing(). |
| 2864 if (delegate_.get()) | 2870 if (delegate_.get()) { |
| 2871 // Typed urls sync service is called here to handle deleted urls, including | |
| 2872 // expirations from ExpireHistoryBackend, new, modified, and visited urls | |
| 2873 if (typed_url_syncable_service_.get()) { | |
| 2874 switch (type) { | |
| 2875 case chrome::NOTIFICATION_HISTORY_URLS_DELETED: { | |
|
brettw
2013/04/20 05:14:18
I don't think it makes sense to key off of the not
mgist1
2013/04/22 20:47:05
Just to clarify, would it be better to remove this
| |
| 2876 typed_url_syncable_service_->OnUrlsDeleted( | |
| 2877 static_cast<history::URLsDeletedDetails*>(details_deleted)); | |
| 2878 break; | |
| 2879 } | |
| 2880 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: { | |
| 2881 typed_url_syncable_service_->OnUrlsModified( | |
| 2882 static_cast<history::URLsModifiedDetails*>(details_deleted)); | |
| 2883 break; | |
| 2884 } | |
| 2885 case chrome::NOTIFICATION_HISTORY_URL_VISITED: { | |
| 2886 typed_url_syncable_service_->OnUrlVisited( | |
| 2887 static_cast<history::URLVisitedDetails*>(details_deleted)); | |
| 2888 break; | |
| 2889 } | |
| 2890 default: | |
| 2891 break; | |
| 2892 } | |
| 2893 } | |
| 2865 delegate_->BroadcastNotifications(type, details_deleted); | 2894 delegate_->BroadcastNotifications(type, details_deleted); |
| 2866 else | 2895 } else { |
| 2867 delete details_deleted; | 2896 delete details_deleted; |
| 2897 } | |
| 2868 } | 2898 } |
| 2869 | 2899 |
| 2870 // Deleting -------------------------------------------------------------------- | 2900 // Deleting -------------------------------------------------------------------- |
| 2871 | 2901 |
| 2872 void HistoryBackend::DeleteAllHistory() { | 2902 void HistoryBackend::DeleteAllHistory() { |
| 2873 // Our approach to deleting all history is: | 2903 // Our approach to deleting all history is: |
| 2874 // 1. Copy the bookmarks and their dependencies to new tables with temporary | 2904 // 1. Copy the bookmarks and their dependencies to new tables with temporary |
| 2875 // names. | 2905 // names. |
| 2876 // 2. Delete the original tables. Since tables can not share pages, we know | 2906 // 2. Delete the original tables. Since tables can not share pages, we know |
| 2877 // that any data we don't want to keep is now in an unused page. | 2907 // that any data we don't want to keep is now in an unused page. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3061 info.url_id = visit.url_id; | 3091 info.url_id = visit.url_id; |
| 3062 info.time = visit.visit_time; | 3092 info.time = visit.visit_time; |
| 3063 info.transition = visit.transition; | 3093 info.transition = visit.transition; |
| 3064 // If we don't have a delegate yet during setup or shutdown, we will drop | 3094 // If we don't have a delegate yet during setup or shutdown, we will drop |
| 3065 // these notifications. | 3095 // these notifications. |
| 3066 if (delegate_.get()) | 3096 if (delegate_.get()) |
| 3067 delegate_->NotifyVisitDBObserversOnAddVisit(info); | 3097 delegate_->NotifyVisitDBObserversOnAddVisit(info); |
| 3068 } | 3098 } |
| 3069 | 3099 |
| 3070 } // namespace history | 3100 } // namespace history |
| OLD | NEW |