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

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

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup, and added fields to DownloadPersistentStoreInfo. 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/download/download_create_info.h" 11 #include "content/browser/download/download_create_info.h"
12 #include "content/browser/download/download_manager.h" 12 #include "content/browser/download/download_manager.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 14
15 using content::BrowserThread; 15 using content::BrowserThread;
16 16
17 namespace { 17 namespace {
18 18
19 // The maximum number of 'uniquified' files we will try to create. 19 // The maximum number of 'uniquified' files we will try to create.
20 // This is used when the filename we're trying to download is already in use, 20 // This is used when the filename we're trying to download is already in use,
21 // so we create a new unique filename by appending " (nnn)" before the 21 // so we create a new unique filename by appending " (nnn)" before the
22 // extension, where 1 <= nnn <= kMaxUniqueFiles. 22 // extension, where 1 <= nnn <= kMaxUniqueFiles.
23 // Also used by code that cleans up said files. 23 // Also used by code that cleans up said files.
24 static const int kMaxUniqueFiles = 100; 24 static const int kMaxUniqueFiles = 100;
25 25
26 } 26 }
27 27
28 DownloadFile::DownloadFile(const DownloadCreateInfo* info, 28 DownloadFile::DownloadFile(const DownloadCreateInfo* info,
29 DownloadRequestHandleInterface* request_handle, 29 DownloadRequestHandleInterface* request_handle,
30 DownloadManager* download_manager) 30 DownloadManager* download_manager,
31 const std::string& initial_hash)
31 : BaseFile(info->save_info.file_path, 32 : BaseFile(info->save_info.file_path,
32 info->url(), 33 info->url(),
33 info->referrer_url, 34 info->referrer_url,
34 info->received_bytes, 35 info->received_bytes,
36 initial_hash,
35 info->save_info.file_stream), 37 info->save_info.file_stream),
36 id_(info->download_id), 38 id_(info->download_id),
37 request_handle_(request_handle), 39 request_handle_(request_handle),
38 download_manager_(download_manager) { 40 download_manager_(download_manager) {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
40 } 42 }
41 43
42 DownloadFile::~DownloadFile() { 44 DownloadFile::~DownloadFile() {
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
44 } 46 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 new_path = FilePath(path); 108 new_path = FilePath(path);
107 AppendNumberToPath(&new_path, count); 109 AppendNumberToPath(&new_path, count);
108 110
109 if (!file_util::PathExists(new_path) && 111 if (!file_util::PathExists(new_path) &&
110 !file_util::PathExists(AppendSuffixToPath(new_path, suffix))) 112 !file_util::PathExists(AppendSuffixToPath(new_path, suffix)))
111 return count; 113 return count;
112 } 114 }
113 115
114 return -1; 116 return -1;
115 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698