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

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

Issue 3029025: Download code cleanup: (Closed)
Patch Set: rebase'n'final Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/download/download_file.h" 5 #include "chrome/browser/download/download_file.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/download/download_manager.h" 10 #include "chrome/browser/download/download_manager.h"
(...skipping 16 matching lines...) Expand all
27 child_id_(info->child_id), 27 child_id_(info->child_id),
28 request_id_(info->request_id), 28 request_id_(info->request_id),
29 full_path_(info->save_info.file_path), 29 full_path_(info->save_info.file_path),
30 path_renamed_(false), 30 path_renamed_(false),
31 dont_sleep_(true) { 31 dont_sleep_(true) {
32 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); 32 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
33 } 33 }
34 34
35 DownloadFile::~DownloadFile() { 35 DownloadFile::~DownloadFile() {
36 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); 36 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
37 if (in_progress())
38 Cancel();
37 Close(); 39 Close();
38 } 40 }
39 41
40 bool DownloadFile::Initialize() { 42 bool DownloadFile::Initialize() {
41 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); 43 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
42 if (!full_path_.empty() || 44 if (!full_path_.empty() ||
43 download_util::CreateTemporaryFileForDownload(&full_path_)) 45 download_util::CreateTemporaryFileForDownload(&full_path_))
44 return Open(); 46 return Open();
45 return false; 47 return false;
46 } 48 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 194
193 void DownloadFile::CancelDownloadRequest(ResourceDispatcherHost* rdh) { 195 void DownloadFile::CancelDownloadRequest(ResourceDispatcherHost* rdh) {
194 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); 196 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
195 ChromeThread::PostTask( 197 ChromeThread::PostTask(
196 ChromeThread::IO, FROM_HERE, 198 ChromeThread::IO, FROM_HERE,
197 NewRunnableFunction(&download_util::CancelDownloadRequest, 199 NewRunnableFunction(&download_util::CancelDownloadRequest,
198 rdh, 200 rdh,
199 child_id_, 201 child_id_,
200 request_id_)); 202 request_id_));
201 } 203 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/download_item_controller.mm ('k') | chrome/browser/download/download_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698