Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: chrome/browser/history/history_backend.cc

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r159248 Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 void HistoryBackend::CleanUpInProgressEntries() { 1215 void HistoryBackend::CleanUpInProgressEntries() {
1216 if (db_.get()) { 1216 if (db_.get()) {
1217 // If some "in progress" entries were not updated when Chrome exited, they 1217 // If some "in progress" entries were not updated when Chrome exited, they
1218 // need to be cleaned up. 1218 // need to be cleaned up.
1219 db_->CleanUpInProgressEntries(); 1219 db_->CleanUpInProgressEntries();
1220 } 1220 }
1221 } 1221 }
1222 1222
1223 // Update a particular download entry. 1223 // Update a particular download entry.
1224 void HistoryBackend::UpdateDownload( 1224 void HistoryBackend::UpdateDownload(
1225 const content::DownloadPersistentStoreInfo& data) { 1225 const DownloadPersistentStoreInfo& data) {
1226 if (db_.get()) 1226 if (db_.get())
1227 db_->UpdateDownload(data); 1227 db_->UpdateDownload(data);
1228 } 1228 }
1229 1229
1230 // Update the path of a particular download entry.
1231 void HistoryBackend::UpdateDownloadPath(const FilePath& path,
1232 int64 db_handle) {
1233 if (db_.get())
1234 db_->UpdateDownloadPath(path, db_handle);
1235 }
1236
1237 // Create a new download entry and pass back the db_handle to it. 1230 // Create a new download entry and pass back the db_handle to it.
1238 void HistoryBackend::CreateDownload( 1231 void HistoryBackend::CreateDownload(
1239 scoped_refptr<DownloadCreateRequest> request, 1232 scoped_refptr<DownloadCreateRequest> request,
1240 int32 id, 1233 const DownloadPersistentStoreInfo& history_info) {
1241 const content::DownloadPersistentStoreInfo& history_info) {
1242 int64 db_handle = 0; 1234 int64 db_handle = 0;
1243 if (!request->canceled()) { 1235 if (!request->canceled()) {
1244 if (db_.get()) 1236 if (db_.get())
1245 db_handle = db_->CreateDownload(history_info); 1237 db_handle = db_->CreateDownload(history_info);
1246 request->ForwardResult(id, db_handle); 1238 request->ForwardResult(db_handle);
1247 } 1239 }
1248 } 1240 }
1249 1241
1250 void HistoryBackend::RemoveDownload(int64 db_handle) { 1242 void HistoryBackend::RemoveDownloads(const std::set<int64>& db_handles) {
1251 if (db_.get()) 1243 if (db_.get())
1252 db_->RemoveDownload(db_handle); 1244 db_->RemoveDownloads(db_handles);
1253 }
1254
1255 void HistoryBackend::RemoveDownloadsBetween(const Time remove_begin,
1256 const Time remove_end) {
1257 if (db_.get())
1258 db_->RemoveDownloadsBetween(remove_begin, remove_end);
1259 } 1245 }
1260 1246
1261 void HistoryBackend::QueryHistory(scoped_refptr<QueryHistoryRequest> request, 1247 void HistoryBackend::QueryHistory(scoped_refptr<QueryHistoryRequest> request,
1262 const string16& text_query, 1248 const string16& text_query,
1263 const QueryOptions& options) { 1249 const QueryOptions& options) {
1264 if (request->canceled()) 1250 if (request->canceled())
1265 return; 1251 return;
1266 1252
1267 TimeTicks beginning_time = TimeTicks::Now(); 1253 TimeTicks beginning_time = TimeTicks::Now();
1268 1254
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after
2872 info.url_id = visit.url_id; 2858 info.url_id = visit.url_id;
2873 info.time = visit.visit_time; 2859 info.time = visit.visit_time;
2874 info.transition = visit.transition; 2860 info.transition = visit.transition;
2875 // If we don't have a delegate yet during setup or shutdown, we will drop 2861 // If we don't have a delegate yet during setup or shutdown, we will drop
2876 // these notifications. 2862 // these notifications.
2877 if (delegate_.get()) 2863 if (delegate_.get())
2878 delegate_->NotifyVisitDBObserversOnAddVisit(info); 2864 delegate_->NotifyVisitDBObserversOnAddVisit(info);
2879 } 2865 }
2880 2866
2881 } // namespace history 2867 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698