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 "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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // The IO thread will call this when saving is completed or it got error when | 256 // The IO thread will call this when saving is completed or it got error when |
257 // fetching data. In the former case, we forward the message to OnSaveFinished | 257 // fetching data. In the former case, we forward the message to OnSaveFinished |
258 // in UI thread. In the latter case, the save ID will be -1, which means the | 258 // in UI thread. In the latter case, the save ID will be -1, which means the |
259 // saving action did not even start, so we need to call OnErrorFinished in UI | 259 // saving action did not even start, so we need to call OnErrorFinished in UI |
260 // thread, which will use the save URL to find corresponding request record and | 260 // thread, which will use the save URL to find corresponding request record and |
261 // delete it. | 261 // delete it. |
262 void SaveFileManager::SaveFinished(int save_id, | 262 void SaveFileManager::SaveFinished(int save_id, |
263 const GURL& save_url, | 263 const GURL& save_url, |
264 int render_process_id, | 264 int render_process_id, |
265 bool is_success) { | 265 bool is_success) { |
266 VLOG(20) << " " << __FUNCTION__ << "()" | 266 DVLOG(20) << " " << __FUNCTION__ << "()" |
267 << " save_id = " << save_id | 267 << " save_id = " << save_id |
268 << " save_url = \"" << save_url.spec() << "\"" | 268 << " save_url = \"" << save_url.spec() << "\"" |
269 << " is_success = " << is_success; | 269 << " is_success = " << is_success; |
270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
271 SaveFileMap::iterator it = save_file_map_.find(save_id); | 271 SaveFileMap::iterator it = save_file_map_.find(save_id); |
272 if (it != save_file_map_.end()) { | 272 if (it != save_file_map_.end()) { |
273 SaveFile* save_file = it->second; | 273 SaveFile* save_file = it->second; |
274 // This routine may be called twice for the same from from | 274 // This routine may be called twice for the same from from |
275 // SaveePackage::OnReceivedSerializedHtmlData, once for the file | 275 // SaveePackage::OnReceivedSerializedHtmlData, once for the file |
276 // itself, and once when all frames have been serialized. | 276 // itself, and once when all frames have been serialized. |
277 // So we can't assert that the file is InProgress() here. | 277 // So we can't assert that the file is InProgress() here. |
278 // TODO(rdsmith): Fix this logic and put the DCHECK below back in. | 278 // TODO(rdsmith): Fix this logic and put the DCHECK below back in. |
279 // DCHECK(save_file->InProgress()); | 279 // DCHECK(save_file->InProgress()); |
280 | 280 |
281 VLOG(20) << " " << __FUNCTION__ << "()" | 281 DVLOG(20) << " " << __FUNCTION__ << "()" |
282 << " save_file = " << save_file->DebugString(); | 282 << " save_file = " << save_file->DebugString(); |
283 BrowserThread::PostTask( | 283 BrowserThread::PostTask( |
284 BrowserThread::UI, FROM_HERE, | 284 BrowserThread::UI, FROM_HERE, |
285 base::Bind(&SaveFileManager::OnSaveFinished, this, save_id, | 285 base::Bind(&SaveFileManager::OnSaveFinished, this, save_id, |
286 save_file->BytesSoFar(), is_success)); | 286 save_file->BytesSoFar(), is_success)); |
287 | 287 |
288 save_file->Finish(); | 288 save_file->Finish(); |
289 save_file->Detach(); | 289 save_file->Detach(); |
290 } else if (save_id == -1) { | 290 } else if (save_id == -1) { |
291 // Before saving started, we got error. We still call finish process. | 291 // Before saving started, we got error. We still call finish process. |
292 DCHECK(!save_url.is_empty()); | 292 DCHECK(!save_url.is_empty()); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 SaveFile* save_file = it->second; | 524 SaveFile* save_file = it->second; |
525 DCHECK(!save_file->InProgress()); | 525 DCHECK(!save_file->InProgress()); |
526 base::DeleteFile(save_file->FullPath(), false); | 526 base::DeleteFile(save_file->FullPath(), false); |
527 delete save_file; | 527 delete save_file; |
528 save_file_map_.erase(it); | 528 save_file_map_.erase(it); |
529 } | 529 } |
530 } | 530 } |
531 } | 531 } |
532 | 532 |
533 } // namespace content | 533 } // namespace content |
OLD | NEW |