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

Side by Side Diff: components/history/core/browser/history_backend.cc

Issue 2292733002: Commit a new download to history db immediately on Android (Closed)
Patch Set: adding comments Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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) 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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 if (!db_) 1172 if (!db_)
1173 return; 1173 return;
1174 db_->UpdateDownload(data); 1174 db_->UpdateDownload(data);
1175 ScheduleCommit(); 1175 ScheduleCommit();
1176 } 1176 }
1177 1177
1178 bool HistoryBackend::CreateDownload(const DownloadRow& history_info) { 1178 bool HistoryBackend::CreateDownload(const DownloadRow& history_info) {
1179 if (!db_) 1179 if (!db_)
1180 return false; 1180 return false;
1181 bool success = db_->CreateDownload(history_info); 1181 bool success = db_->CreateDownload(history_info);
1182 #if defined(OS_ANDROID)
1183 // 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
1185 // download is not committed before that. Do the commit right away to avoid
1186 // uncommitted download entry before browser kill.
sky 2016/08/30 03:21:21 'before browser kill' -> 'if browser is killed'
qinmin 2016/08/30 16:31:32 Done.
1187 Commit();
1188 #else
1182 ScheduleCommit(); 1189 ScheduleCommit();
1190 #endif
1183 return success; 1191 return success;
1184 } 1192 }
1185 1193
1186 void HistoryBackend::RemoveDownloads(const std::set<uint32_t>& ids) { 1194 void HistoryBackend::RemoveDownloads(const std::set<uint32_t>& ids) {
1187 if (!db_) 1195 if (!db_)
1188 return; 1196 return;
1189 size_t downloads_count_before = db_->CountDownloads(); 1197 size_t downloads_count_before = db_->CountDownloads();
1190 base::TimeTicks started_removing = base::TimeTicks::Now(); 1198 base::TimeTicks started_removing = base::TimeTicks::Now();
1191 // HistoryBackend uses a long-running Transaction that is committed 1199 // HistoryBackend uses a long-running Transaction that is committed
1192 // periodically, so this loop doesn't actually hit the disk too hard. 1200 // periodically, so this loop doesn't actually hit the disk too hard.
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 // transaction is currently open. 2637 // transaction is currently open.
2630 db_->CommitTransaction(); 2638 db_->CommitTransaction();
2631 db_->Vacuum(); 2639 db_->Vacuum();
2632 db_->BeginTransaction(); 2640 db_->BeginTransaction();
2633 db_->GetStartDate(&first_recorded_time_); 2641 db_->GetStartDate(&first_recorded_time_);
2634 2642
2635 return true; 2643 return true;
2636 } 2644 }
2637 2645
2638 } // namespace history 2646 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698