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 #include "sql/error_delegate_util.h" | 41 #include "sql/error_delegate_util.h" |
42 | 42 |
43 #if defined(OS_ANDROID) | 43 #if defined(OS_ANDROID) |
44 #include "chrome/browser/history/android/android_provider_backend.h" | 44 #include "chrome/browser/history/android/android_provider_backend.h" |
45 #endif | 45 #endif |
46 | 46 |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 void HistoryBackend::CleanUpInProgressEntries() { | 1285 void HistoryBackend::CleanUpInProgressEntries() { |
1286 if (db_.get()) { | 1286 if (db_.get()) { |
1287 // If some "in progress" entries were not updated when Chrome exited, they | 1287 // If some "in progress" entries were not updated when Chrome exited, they |
1288 // need to be cleaned up. | 1288 // need to be cleaned up. |
1289 db_->CleanUpInProgressEntries(); | 1289 db_->CleanUpInProgressEntries(); |
1290 } | 1290 } |
1291 } | 1291 } |
1292 | 1292 |
1293 // Update a particular download entry. | 1293 // Update a particular download entry. |
1294 void HistoryBackend::UpdateDownload( | 1294 void HistoryBackend::UpdateDownload( |
1295 const content::DownloadPersistentStoreInfo& data) { | 1295 const DownloadPersistentStoreInfo& data) { |
1296 if (db_.get()) | 1296 if (db_.get()) |
1297 db_->UpdateDownload(data); | 1297 db_->UpdateDownload(data); |
1298 } | 1298 } |
1299 | 1299 |
1300 // Update the path of a particular download entry. | |
1301 void HistoryBackend::UpdateDownloadPath(const FilePath& path, | |
1302 int64 db_handle) { | |
1303 if (db_.get()) | |
1304 db_->UpdateDownloadPath(path, db_handle); | |
1305 } | |
1306 | |
1307 // Create a new download entry and pass back the db_handle to it. | 1300 // Create a new download entry and pass back the db_handle to it. |
1308 void HistoryBackend::CreateDownload( | 1301 void HistoryBackend::CreateDownload( |
1309 scoped_refptr<DownloadCreateRequest> request, | 1302 scoped_refptr<DownloadCreateRequest> request, |
1310 int32 id, | 1303 const DownloadPersistentStoreInfo& history_info) { |
1311 const content::DownloadPersistentStoreInfo& history_info) { | |
1312 int64 db_handle = 0; | 1304 int64 db_handle = 0; |
1313 if (!request->canceled()) { | 1305 if (!request->canceled()) { |
1314 if (db_.get()) | 1306 if (db_.get()) |
1315 db_handle = db_->CreateDownload(history_info); | 1307 db_handle = db_->CreateDownload(history_info); |
1316 request->ForwardResult(id, db_handle); | 1308 request->ForwardResult(db_handle); |
1317 } | 1309 } |
1318 } | 1310 } |
1319 | 1311 |
1320 void HistoryBackend::RemoveDownload(int64 db_handle) { | 1312 void HistoryBackend::RemoveDownloads(const std::set<int64>& db_handles) { |
1321 if (db_.get()) | 1313 if (db_.get()) |
1322 db_->RemoveDownload(db_handle); | 1314 db_->RemoveDownloads(db_handles); |
1323 } | |
1324 | |
1325 void HistoryBackend::RemoveDownloadsBetween(const Time remove_begin, | |
1326 const Time remove_end) { | |
1327 if (db_.get()) | |
1328 db_->RemoveDownloadsBetween(remove_begin, remove_end); | |
1329 } | 1315 } |
1330 | 1316 |
1331 void HistoryBackend::QueryHistory(scoped_refptr<QueryHistoryRequest> request, | 1317 void HistoryBackend::QueryHistory(scoped_refptr<QueryHistoryRequest> request, |
1332 const string16& text_query, | 1318 const string16& text_query, |
1333 const QueryOptions& options) { | 1319 const QueryOptions& options) { |
1334 if (request->canceled()) | 1320 if (request->canceled()) |
1335 return; | 1321 return; |
1336 | 1322 |
1337 TimeTicks beginning_time = TimeTicks::Now(); | 1323 TimeTicks beginning_time = TimeTicks::Now(); |
1338 | 1324 |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 info.url_id = visit.url_id; | 2912 info.url_id = visit.url_id; |
2927 info.time = visit.visit_time; | 2913 info.time = visit.visit_time; |
2928 info.transition = visit.transition; | 2914 info.transition = visit.transition; |
2929 // If we don't have a delegate yet during setup or shutdown, we will drop | 2915 // If we don't have a delegate yet during setup or shutdown, we will drop |
2930 // these notifications. | 2916 // these notifications. |
2931 if (delegate_.get()) | 2917 if (delegate_.get()) |
2932 delegate_->NotifyVisitDBObserversOnAddVisit(info); | 2918 delegate_->NotifyVisitDBObserversOnAddVisit(info); |
2933 } | 2919 } |
2934 | 2920 |
2935 } // namespace history | 2921 } // namespace history |
OLD | NEW |