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

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

Issue 8371009: Make passing of DownloadRequestHandle separate from DownloadCreateInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/download/download_file.h" 5 #include "content/browser/download/download_file.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "content/browser/browser_thread.h" 11 #include "content/browser/browser_thread.h"
12 #include "content/browser/download/download_create_info.h" 12 #include "content/browser/download/download_create_info.h"
13 #include "content/browser/download/download_manager.h" 13 #include "content/browser/download/download_manager.h"
14 14
15 namespace { 15 namespace {
16 16
17 // The maximum number of 'uniquified' files we will try to create. 17 // The maximum number of 'uniquified' files we will try to create.
18 // This is used when the filename we're trying to download is already in use, 18 // This is used when the filename we're trying to download is already in use,
19 // so we create a new unique filename by appending " (nnn)" before the 19 // so we create a new unique filename by appending " (nnn)" before the
20 // extension, where 1 <= nnn <= kMaxUniqueFiles. 20 // extension, where 1 <= nnn <= kMaxUniqueFiles.
21 // Also used by code that cleans up said files. 21 // Also used by code that cleans up said files.
22 static const int kMaxUniqueFiles = 100; 22 static const int kMaxUniqueFiles = 100;
23 23
24 } 24 }
25 25
26 DownloadFile::DownloadFile(const DownloadCreateInfo* info, 26 DownloadFile::DownloadFile(const DownloadCreateInfo* info,
27 const DownloadRequestHandle& request_handle,
27 DownloadManager* download_manager) 28 DownloadManager* download_manager)
28 : BaseFile(info->save_info.file_path, 29 : BaseFile(info->save_info.file_path,
29 info->url(), 30 info->url(),
30 info->referrer_url, 31 info->referrer_url,
31 info->received_bytes, 32 info->received_bytes,
32 info->save_info.file_stream), 33 info->save_info.file_stream),
33 id_(info->download_id), 34 id_(info->download_id),
34 request_handle_(info->request_handle), 35 request_handle_(request_handle),
35 download_manager_(download_manager) { 36 download_manager_(download_manager) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
37 } 38 }
38 39
39 DownloadFile::~DownloadFile() { 40 DownloadFile::~DownloadFile() {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
41 } 42 }
42 43
43 void DownloadFile::CancelDownloadRequest() { 44 void DownloadFile::CancelDownloadRequest() {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 new_path = FilePath(path); 104 new_path = FilePath(path);
104 AppendNumberToPath(&new_path, count); 105 AppendNumberToPath(&new_path, count);
105 106
106 if (!file_util::PathExists(new_path) && 107 if (!file_util::PathExists(new_path) &&
107 !file_util::PathExists(AppendSuffixToPath(new_path, suffix))) 108 !file_util::PathExists(AppendSuffixToPath(new_path, suffix)))
108 return count; 109 return count;
109 } 110 }
110 111
111 return -1; 112 return -1;
112 } 113 }
OLDNEW
« no previous file with comments | « content/browser/download/download_file.h ('k') | content/browser/download/download_file_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698