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

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

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merged db_handle, id; onCreated, onErased Created 9 years, 5 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
« no previous file with comments | « chrome/browser/history/history.cc ('k') | chrome/browser/history/history_marshaling.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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>
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1076
1077 // Downloads ------------------------------------------------------------------- 1077 // Downloads -------------------------------------------------------------------
1078 1078
1079 // Get all the download entries from the database. 1079 // Get all the download entries from the database.
1080 void HistoryBackend::QueryDownloads( 1080 void HistoryBackend::QueryDownloads(
1081 scoped_refptr<DownloadQueryRequest> request) { 1081 scoped_refptr<DownloadQueryRequest> request) {
1082 if (request->canceled()) 1082 if (request->canceled())
1083 return; 1083 return;
1084 if (db_.get()) 1084 if (db_.get())
1085 db_->QueryDownloads(&request->value); 1085 db_->QueryDownloads(&request->value);
1086 request->ForwardResult(DownloadQueryRequest::TupleType(&request->value)); 1086 request->ForwardResult(DownloadQueryRequest::TupleType(&request->value.results ));
1087 } 1087 }
1088 1088
1089 // Clean up entries that has been corrupted (because of the crash, for example). 1089 // Clean up entries that has been corrupted (because of the crash, for example).
1090 void HistoryBackend::CleanUpInProgressEntries() { 1090 void HistoryBackend::CleanUpInProgressEntries() {
1091 if (db_.get()) { 1091 if (db_.get()) {
1092 // If some "in progress" entries were not updated when Chrome exited, they 1092 // If some "in progress" entries were not updated when Chrome exited, they
1093 // need to be cleaned up. 1093 // need to be cleaned up.
1094 db_->CleanUpInProgressEntries(); 1094 db_->CleanUpInProgressEntries();
1095 } 1095 }
1096 } 1096 }
(...skipping 11 matching lines...) Expand all
1108 int64 db_handle) { 1108 int64 db_handle) {
1109 if (db_.get()) 1109 if (db_.get())
1110 db_->UpdateDownloadPath(path, db_handle); 1110 db_->UpdateDownloadPath(path, db_handle);
1111 } 1111 }
1112 1112
1113 // Create a new download entry and pass back the db_handle to it. 1113 // Create a new download entry and pass back the db_handle to it.
1114 void HistoryBackend::CreateDownload( 1114 void HistoryBackend::CreateDownload(
1115 scoped_refptr<DownloadCreateRequest> request, 1115 scoped_refptr<DownloadCreateRequest> request,
1116 int32 id, 1116 int32 id,
1117 const DownloadHistoryInfo& history_info) { 1117 const DownloadHistoryInfo& history_info) {
1118 int64 db_handle = 0;
1119 if (!request->canceled()) { 1118 if (!request->canceled()) {
1120 if (db_.get()) 1119 if (db_.get()) {
1121 db_handle = db_->CreateDownload(history_info); 1120 bool success = db_->CreateDownload(history_info);
1122 request->ForwardResult(DownloadCreateRequest::TupleType(id, db_handle)); 1121 DCHECK(success) << history_info.id;
1122 }
1123 request->ForwardResult(DownloadCreateRequest::TupleType(id));
1123 } 1124 }
1124 } 1125 }
1125 1126
1126 void HistoryBackend::RemoveDownload(int64 db_handle) { 1127 void HistoryBackend::RemoveDownload(int64 db_handle) {
1127 if (db_.get()) 1128 if (db_.get())
1128 db_->RemoveDownload(db_handle); 1129 db_->RemoveDownload(db_handle);
1129 } 1130 }
1130 1131
1131 void HistoryBackend::RemoveDownloadsBetween(const Time remove_begin, 1132 void HistoryBackend::RemoveDownloadsBetween(const Time remove_begin,
1132 const Time remove_end) { 1133 const Time remove_end) {
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 return true; 2230 return true;
2230 } 2231 }
2231 2232
2232 BookmarkService* HistoryBackend::GetBookmarkService() { 2233 BookmarkService* HistoryBackend::GetBookmarkService() {
2233 if (bookmark_service_) 2234 if (bookmark_service_)
2234 bookmark_service_->BlockTillLoaded(); 2235 bookmark_service_->BlockTillLoaded();
2235 return bookmark_service_; 2236 return bookmark_service_;
2236 } 2237 }
2237 2238
2238 } // namespace history 2239 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history.cc ('k') | chrome/browser/history/history_marshaling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698