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 <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/time.h" | 21 #include "base/time.h" |
22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
23 #include "chrome/browser/api/bookmarks/bookmark_service.h" | 23 #include "chrome/browser/api/bookmarks/bookmark_service.h" |
24 #include "chrome/browser/autocomplete/history_url_provider.h" | 24 #include "chrome/browser/autocomplete/history_url_provider.h" |
25 #include "chrome/browser/common/cancelable_request.h" | 25 #include "chrome/browser/common/cancelable_request.h" |
| 26 #include "chrome/browser/history/download_persistent_store_info.h" |
26 #include "chrome/browser/history/history_notifications.h" | 27 #include "chrome/browser/history/history_notifications.h" |
27 #include "chrome/browser/history/history_publisher.h" | 28 #include "chrome/browser/history/history_publisher.h" |
28 #include "chrome/browser/history/in_memory_history_backend.h" | 29 #include "chrome/browser/history/in_memory_history_backend.h" |
29 #include "chrome/browser/history/page_usage_data.h" | 30 #include "chrome/browser/history/page_usage_data.h" |
30 #include "chrome/browser/history/select_favicon_frames.h" | 31 #include "chrome/browser/history/select_favicon_frames.h" |
31 #include "chrome/browser/history/top_sites.h" | 32 #include "chrome/browser/history/top_sites.h" |
32 #include "chrome/browser/history/visit_filter.h" | 33 #include "chrome/browser/history/visit_filter.h" |
33 #include "chrome/common/chrome_constants.h" | 34 #include "chrome/common/chrome_constants.h" |
34 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
35 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
36 #include "content/public/browser/download_persistent_store_info.h" | |
37 #include "googleurl/src/gurl.h" | 37 #include "googleurl/src/gurl.h" |
38 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
40 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 40 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
41 | 41 |
42 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
43 #include "chrome/browser/history/android/android_provider_backend.h" | 43 #include "chrome/browser/history/android/android_provider_backend.h" |
44 #endif | 44 #endif |
45 | 45 |
46 using base::Time; | 46 using base::Time; |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 void HistoryBackend::CleanUpInProgressEntries() { | 1213 void HistoryBackend::CleanUpInProgressEntries() { |
1214 if (db_.get()) { | 1214 if (db_.get()) { |
1215 // If some "in progress" entries were not updated when Chrome exited, they | 1215 // If some "in progress" entries were not updated when Chrome exited, they |
1216 // need to be cleaned up. | 1216 // need to be cleaned up. |
1217 db_->CleanUpInProgressEntries(); | 1217 db_->CleanUpInProgressEntries(); |
1218 } | 1218 } |
1219 } | 1219 } |
1220 | 1220 |
1221 // Update a particular download entry. | 1221 // Update a particular download entry. |
1222 void HistoryBackend::UpdateDownload( | 1222 void HistoryBackend::UpdateDownload( |
1223 const content::DownloadPersistentStoreInfo& data) { | 1223 const DownloadPersistentStoreInfo& data) { |
1224 if (db_.get()) | 1224 if (db_.get()) |
1225 db_->UpdateDownload(data); | 1225 db_->UpdateDownload(data); |
1226 } | 1226 } |
1227 | 1227 |
1228 // Update the path of a particular download entry. | |
1229 void HistoryBackend::UpdateDownloadPath(const FilePath& path, | |
1230 int64 db_handle) { | |
1231 if (db_.get()) | |
1232 db_->UpdateDownloadPath(path, db_handle); | |
1233 } | |
1234 | |
1235 // Create a new download entry and pass back the db_handle to it. | 1228 // Create a new download entry and pass back the db_handle to it. |
1236 void HistoryBackend::CreateDownload( | 1229 void HistoryBackend::CreateDownload( |
1237 scoped_refptr<DownloadCreateRequest> request, | 1230 scoped_refptr<DownloadCreateRequest> request, |
1238 int32 id, | 1231 const DownloadPersistentStoreInfo& history_info) { |
1239 const content::DownloadPersistentStoreInfo& history_info) { | |
1240 int64 db_handle = 0; | 1232 int64 db_handle = 0; |
1241 if (!request->canceled()) { | 1233 if (!request->canceled()) { |
1242 if (db_.get()) | 1234 if (db_.get()) |
1243 db_handle = db_->CreateDownload(history_info); | 1235 db_handle = db_->CreateDownload(history_info); |
1244 request->ForwardResult(id, db_handle); | 1236 request->ForwardResult(db_handle); |
1245 } | 1237 } |
1246 } | 1238 } |
1247 | 1239 |
1248 void HistoryBackend::RemoveDownload(int64 db_handle) { | 1240 void HistoryBackend::RemoveDownloads(const std::set<int64>& db_handles) { |
1249 if (db_.get()) | 1241 if (db_.get()) |
1250 db_->RemoveDownload(db_handle); | 1242 db_->RemoveDownloads(db_handles); |
1251 } | |
1252 | |
1253 void HistoryBackend::RemoveDownloadsBetween(const Time remove_begin, | |
1254 const Time remove_end) { | |
1255 if (db_.get()) | |
1256 db_->RemoveDownloadsBetween(remove_begin, remove_end); | |
1257 } | 1243 } |
1258 | 1244 |
1259 void HistoryBackend::QueryHistory(scoped_refptr<QueryHistoryRequest> request, | 1245 void HistoryBackend::QueryHistory(scoped_refptr<QueryHistoryRequest> request, |
1260 const string16& text_query, | 1246 const string16& text_query, |
1261 const QueryOptions& options) { | 1247 const QueryOptions& options) { |
1262 if (request->canceled()) | 1248 if (request->canceled()) |
1263 return; | 1249 return; |
1264 | 1250 |
1265 TimeTicks beginning_time = TimeTicks::Now(); | 1251 TimeTicks beginning_time = TimeTicks::Now(); |
1266 | 1252 |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2870 info.url_id = visit.url_id; | 2856 info.url_id = visit.url_id; |
2871 info.time = visit.visit_time; | 2857 info.time = visit.visit_time; |
2872 info.transition = visit.transition; | 2858 info.transition = visit.transition; |
2873 // If we don't have a delegate yet during setup or shutdown, we will drop | 2859 // If we don't have a delegate yet during setup or shutdown, we will drop |
2874 // these notifications. | 2860 // these notifications. |
2875 if (delegate_.get()) | 2861 if (delegate_.get()) |
2876 delegate_->NotifyVisitDBObserversOnAddVisit(info); | 2862 delegate_->NotifyVisitDBObserversOnAddVisit(info); |
2877 } | 2863 } |
2878 | 2864 |
2879 } // namespace history | 2865 } // namespace history |
OLD | NEW |