| 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 "components/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/history_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 return db_ ? db_->GetNextDownloadId() : kInvalidDownloadId; | 1161 return db_ ? db_->GetNextDownloadId() : kInvalidDownloadId; |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 // Get all the download entries from the database. | 1164 // Get all the download entries from the database. |
| 1165 void HistoryBackend::QueryDownloads(std::vector<DownloadRow>* rows) { | 1165 void HistoryBackend::QueryDownloads(std::vector<DownloadRow>* rows) { |
| 1166 if (db_) | 1166 if (db_) |
| 1167 db_->QueryDownloads(rows); | 1167 db_->QueryDownloads(rows); |
| 1168 } | 1168 } |
| 1169 | 1169 |
| 1170 // Update a particular download entry. | 1170 // Update a particular download entry. |
| 1171 void HistoryBackend::UpdateDownload(const DownloadRow& data) { | 1171 void HistoryBackend::UpdateDownload( |
| 1172 const DownloadRow& data, |
| 1173 bool should_commit_immediately) { |
| 1172 if (!db_) | 1174 if (!db_) |
| 1173 return; | 1175 return; |
| 1174 db_->UpdateDownload(data); | 1176 db_->UpdateDownload(data); |
| 1175 ScheduleCommit(); | 1177 if (should_commit_immediately) |
| 1178 Commit(); |
| 1179 else |
| 1180 ScheduleCommit(); |
| 1176 } | 1181 } |
| 1177 | 1182 |
| 1178 bool HistoryBackend::CreateDownload(const DownloadRow& history_info) { | 1183 bool HistoryBackend::CreateDownload(const DownloadRow& history_info) { |
| 1179 if (!db_) | 1184 if (!db_) |
| 1180 return false; | 1185 return false; |
| 1181 bool success = db_->CreateDownload(history_info); | 1186 bool success = db_->CreateDownload(history_info); |
| 1182 #if defined(OS_ANDROID) | 1187 #if defined(OS_ANDROID) |
| 1183 // On android, browser process can get easily killed. Download will no longer | 1188 // On android, browser process can get easily killed. Download will no longer |
| 1184 // be able to resume and the temporary file will linger forever if the | 1189 // be able to resume and the temporary file will linger forever if the |
| 1185 // download is not committed before that. Do the commit right away to avoid | 1190 // download is not committed before that. Do the commit right away to avoid |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 // transaction is currently open. | 2646 // transaction is currently open. |
| 2642 db_->CommitTransaction(); | 2647 db_->CommitTransaction(); |
| 2643 db_->Vacuum(); | 2648 db_->Vacuum(); |
| 2644 db_->BeginTransaction(); | 2649 db_->BeginTransaction(); |
| 2645 db_->GetStartDate(&first_recorded_time_); | 2650 db_->GetStartDate(&first_recorded_time_); |
| 2646 | 2651 |
| 2647 return true; | 2652 return true; |
| 2648 } | 2653 } |
| 2649 | 2654 |
| 2650 } // namespace history | 2655 } // namespace history |
| OLD | NEW |