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

Side by Side Diff: chrome/browser/download/download_history.cc

Issue 2675613002: Rename ShouldUpdateHistoryResult enum values to not use NO. (Closed)
Patch Set: Created 3 years, 10 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 // DownloadHistory manages persisting DownloadItems to the history service by 5 // DownloadHistory manages persisting DownloadItems to the history service by
6 // observing a single DownloadManager and all its DownloadItems using an 6 // observing a single DownloadManager and all its DownloadItems using an
7 // AllDownloadItemNotifier. 7 // AllDownloadItemNotifier.
8 // 8 //
9 // DownloadHistory decides whether and when to add items to, remove items from, 9 // DownloadHistory decides whether and when to add items to, remove items from,
10 // and update items in the database. DownloadHistory uses DownloadHistoryData to 10 // and update items in the database. DownloadHistory uses DownloadHistoryData to
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 item->GetReceivedBytes(), item->GetTotalBytes(), 137 item->GetReceivedBytes(), item->GetTotalBytes(),
138 history::ToHistoryDownloadState(item->GetState()), 138 history::ToHistoryDownloadState(item->GetState()),
139 history::ToHistoryDownloadDangerType(item->GetDangerType()), 139 history::ToHistoryDownloadDangerType(item->GetDangerType()),
140 history::ToHistoryDownloadInterruptReason(item->GetLastReason()), 140 history::ToHistoryDownloadInterruptReason(item->GetLastReason()),
141 std::string(), // Hash value (not available yet) 141 std::string(), // Hash value (not available yet)
142 history::ToHistoryDownloadId(item->GetId()), item->GetGuid(), 142 history::ToHistoryDownloadId(item->GetId()), item->GetGuid(),
143 item->GetOpened(), by_ext_id, by_ext_name); 143 item->GetOpened(), by_ext_id, by_ext_name);
144 } 144 }
145 145
146 enum class ShouldUpdateHistoryResult { 146 enum class ShouldUpdateHistoryResult {
147 NO, 147 NO_UPDATE,
148 UPDATE, 148 UPDATE,
149 UPDATE_IMMEDIATELY, 149 UPDATE_IMMEDIATELY,
150 }; 150 };
151 151
152 ShouldUpdateHistoryResult ShouldUpdateHistory( 152 ShouldUpdateHistoryResult ShouldUpdateHistory(
153 const history::DownloadRow* previous, 153 const history::DownloadRow* previous,
154 const history::DownloadRow& current) { 154 const history::DownloadRow& current) {
155 // When download path is determined, Chrome should commit the history 155 // When download path is determined, Chrome should commit the history
156 // immediately. Otherwise the file will be left permanently on the external 156 // immediately. Otherwise the file will be left permanently on the external
157 // storage if Chrome crashes right away. 157 // storage if Chrome crashes right away.
158 // TODO(qinmin): this doesn't solve all the issues. When download starts, 158 // TODO(qinmin): this doesn't solve all the issues. When download starts,
159 // Chrome will write the http response data to a temporary file, and later 159 // Chrome will write the http response data to a temporary file, and later
(...skipping 14 matching lines...) Expand all
174 (previous->state != current.state) || 174 (previous->state != current.state) ||
175 (previous->danger_type != current.danger_type) || 175 (previous->danger_type != current.danger_type) ||
176 (previous->interrupt_reason != current.interrupt_reason) || 176 (previous->interrupt_reason != current.interrupt_reason) ||
177 (previous->hash != current.hash) || 177 (previous->hash != current.hash) ||
178 (previous->opened != current.opened) || 178 (previous->opened != current.opened) ||
179 (previous->by_ext_id != current.by_ext_id) || 179 (previous->by_ext_id != current.by_ext_id) ||
180 (previous->by_ext_name != current.by_ext_name)) { 180 (previous->by_ext_name != current.by_ext_name)) {
181 return ShouldUpdateHistoryResult::UPDATE; 181 return ShouldUpdateHistoryResult::UPDATE;
182 } 182 }
183 183
184 return ShouldUpdateHistoryResult::NO; 184 return ShouldUpdateHistoryResult::NO_UPDATE;
185 } 185 }
186 186
187 typedef std::vector<history::DownloadRow> InfoVector; 187 typedef std::vector<history::DownloadRow> InfoVector;
188 188
189 } // anonymous namespace 189 } // anonymous namespace
190 190
191 DownloadHistory::HistoryAdapter::HistoryAdapter( 191 DownloadHistory::HistoryAdapter::HistoryAdapter(
192 history::HistoryService* history) 192 history::HistoryService* history)
193 : history_(history) { 193 : history_(history) {
194 } 194 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 return; 423 return;
424 } 424 }
425 if (item->IsTemporary()) { 425 if (item->IsTemporary()) {
426 OnDownloadRemoved(notifier_.GetManager(), item); 426 OnDownloadRemoved(notifier_.GetManager(), item);
427 return; 427 return;
428 } 428 }
429 429
430 history::DownloadRow current_info(GetDownloadRow(item)); 430 history::DownloadRow current_info(GetDownloadRow(item));
431 ShouldUpdateHistoryResult should_update_result = 431 ShouldUpdateHistoryResult should_update_result =
432 ShouldUpdateHistory(data->info(), current_info); 432 ShouldUpdateHistory(data->info(), current_info);
433 bool should_update = (should_update_result != ShouldUpdateHistoryResult::NO); 433 bool should_update =
434 (should_update_result != ShouldUpdateHistoryResult::NO_UPDATE);
434 UMA_HISTOGRAM_ENUMERATION("Download.HistoryPropagatedUpdate", 435 UMA_HISTOGRAM_ENUMERATION("Download.HistoryPropagatedUpdate",
435 should_update, 2); 436 should_update, 2);
436 if (should_update) { 437 if (should_update) {
437 history_->UpdateDownload( 438 history_->UpdateDownload(
438 current_info, 439 current_info,
439 should_update_result == ShouldUpdateHistoryResult::UPDATE_IMMEDIATELY); 440 should_update_result == ShouldUpdateHistoryResult::UPDATE_IMMEDIATELY);
440 for (Observer& observer : observers_) 441 for (Observer& observer : observers_)
441 observer.OnDownloadStored(item, current_info); 442 observer.OnDownloadStored(item, current_info);
442 } 443 }
443 if (item->GetState() == content::DownloadItem::IN_PROGRESS) { 444 if (item->GetState() == content::DownloadItem::IN_PROGRESS) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 489 }
489 490
490 void DownloadHistory::RemoveDownloadsBatch() { 491 void DownloadHistory::RemoveDownloadsBatch() {
491 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 492 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
492 IdSet remove_ids; 493 IdSet remove_ids;
493 removing_ids_.swap(remove_ids); 494 removing_ids_.swap(remove_ids);
494 history_->RemoveDownloads(remove_ids); 495 history_->RemoveDownloads(remove_ids);
495 for (Observer& observer : observers_) 496 for (Observer& observer : observers_)
496 observer.OnDownloadsRemoved(remove_ids); 497 observer.OnDownloadsRemoved(remove_ids);
497 } 498 }
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