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

Side by Side Diff: content/browser/download/save_file_manager.cc

Issue 1833723002: Initialize |bytes_so_far| local variable in SaveFileManager::SaveFinished. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove re-initialization of |bytes_so_far|. Created 4 years, 9 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "content/browser/download/save_file_manager.h" 7 #include "content/browser/download/save_file_manager.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // fetching data. We forward the message to OnSaveFinished in UI thread. 199 // fetching data. We forward the message to OnSaveFinished in UI thread.
200 void SaveFileManager::SaveFinished(SaveItemId save_item_id, 200 void SaveFileManager::SaveFinished(SaveItemId save_item_id,
201 SavePackageId save_package_id, 201 SavePackageId save_package_id,
202 bool is_success) { 202 bool is_success) {
203 DVLOG(20) << " " << __FUNCTION__ << "()" 203 DVLOG(20) << " " << __FUNCTION__ << "()"
204 << " save_item_id = " << save_item_id 204 << " save_item_id = " << save_item_id
205 << " save_package_id = " << save_package_id 205 << " save_package_id = " << save_package_id
206 << " is_success = " << is_success; 206 << " is_success = " << is_success;
207 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 207 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
208 208
209 int64_t bytes_so_far; 209 int64_t bytes_so_far = 0;
210 SaveFile* save_file = LookupSaveFile(save_item_id); 210 SaveFile* save_file = LookupSaveFile(save_item_id);
211 if (save_file != nullptr) { 211 if (save_file != nullptr) {
212 DCHECK(save_file->InProgress()); 212 DCHECK(save_file->InProgress());
213 DVLOG(20) << " " << __FUNCTION__ << "()" 213 DVLOG(20) << " " << __FUNCTION__ << "()"
214 << " save_file = " << save_file->DebugString(); 214 << " save_file = " << save_file->DebugString();
215 bytes_so_far = save_file->BytesSoFar(); 215 bytes_so_far = save_file->BytesSoFar();
216 save_file->Finish(); 216 save_file->Finish();
217 save_file->Detach(); 217 save_file->Detach();
218 } else { 218 } else {
219 // We got called before StartSave - this should only happen if 219 // We got called before StartSave - this should only happen if
220 // ResourceHandler failed before it got a chance to parse headers 220 // ResourceHandler failed before it got a chance to parse headers
221 // and metadata. 221 // and metadata.
222 DCHECK(!is_success); 222 DCHECK(!is_success);
223
224 bytes_so_far = 0;
225 } 223 }
226 224
227 BrowserThread::PostTask( 225 BrowserThread::PostTask(
228 BrowserThread::UI, FROM_HERE, 226 BrowserThread::UI, FROM_HERE,
229 base::Bind(&SaveFileManager::OnSaveFinished, this, save_item_id, 227 base::Bind(&SaveFileManager::OnSaveFinished, this, save_item_id,
230 bytes_so_far, is_success)); 228 bytes_so_far, is_success));
231 } 229 }
232 230
233 // Notifications sent from the file thread and run on the UI thread. 231 // Notifications sent from the file thread and run on the UI thread.
234 232
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 SaveFile* save_file = it->second; 419 SaveFile* save_file = it->second;
422 DCHECK(!save_file->InProgress()); 420 DCHECK(!save_file->InProgress());
423 base::DeleteFile(save_file->FullPath(), false); 421 base::DeleteFile(save_file->FullPath(), false);
424 delete save_file; 422 delete save_file;
425 save_file_map_.erase(it); 423 save_file_map_.erase(it);
426 } 424 }
427 } 425 }
428 } 426 }
429 427
430 } // namespace content 428 } // namespace content
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