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