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

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

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment. Created 9 years 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_impl.h" 5 #include "content/browser/download/download_file_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "content/browser/download/download_create_info.h" 10 #include "content/browser/download/download_create_info.h"
11 #include "content/browser/download/download_manager.h" 11 #include "content/browser/download/download_manager.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 13
14 using content::BrowserThread; 14 using content::BrowserThread;
15 15
16 DownloadFileImpl::DownloadFileImpl( 16 DownloadFileImpl::DownloadFileImpl(
17 const DownloadCreateInfo* info, 17 const DownloadCreateInfo* info,
18 DownloadRequestHandleInterface* request_handle, 18 DownloadRequestHandleInterface* request_handle,
19 DownloadManager* download_manager) 19 DownloadManager* download_manager,
20 bool calculate_hash)
20 : file_(info->save_info.file_path, 21 : file_(info->save_info.file_path,
21 info->url(), 22 info->url(),
22 info->referrer_url, 23 info->referrer_url,
23 info->received_bytes, 24 info->received_bytes,
25 calculate_hash,
26 info->save_info.hash_state,
24 info->save_info.file_stream), 27 info->save_info.file_stream),
25 id_(info->download_id), 28 id_(info->download_id),
26 request_handle_(request_handle), 29 request_handle_(request_handle),
27 download_manager_(download_manager) { 30 download_manager_(download_manager) {
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
29 } 32 }
30 33
31 DownloadFileImpl::~DownloadFileImpl() { 34 DownloadFileImpl::~DownloadFileImpl() {
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
33 } 36 }
34 37
35 // BaseFile delegated functions. 38 // BaseFile delegated functions.
36 net::Error DownloadFileImpl::Initialize(bool calculate_hash) { 39 net::Error DownloadFileImpl::Initialize() {
37 return file_.Initialize(calculate_hash); 40 return file_.Initialize();
38 } 41 }
39 42
40 net::Error DownloadFileImpl::AppendDataToFile(const char* data, 43 net::Error DownloadFileImpl::AppendDataToFile(const char* data,
41 size_t data_len) { 44 size_t data_len) {
42 return file_.AppendDataToFile(data, data_len); 45 return file_.AppendDataToFile(data, data_len);
43 } 46 }
44 47
45 net::Error DownloadFileImpl::Rename(const FilePath& full_path) { 48 net::Error DownloadFileImpl::Rename(const FilePath& full_path) {
46 return file_.Rename(full_path); 49 return file_.Rename(full_path);
47 } 50 }
(...skipping 23 matching lines...) Expand all
71 } 74 }
72 75
73 int64 DownloadFileImpl::BytesSoFar() const { 76 int64 DownloadFileImpl::BytesSoFar() const {
74 return file_.bytes_so_far(); 77 return file_.bytes_so_far();
75 } 78 }
76 79
77 int64 DownloadFileImpl::CurrentSpeed() const { 80 int64 DownloadFileImpl::CurrentSpeed() const {
78 return file_.CurrentSpeed(); 81 return file_.CurrentSpeed();
79 } 82 }
80 83
81 bool DownloadFileImpl::GetSha256Hash(std::string* hash) { 84 bool DownloadFileImpl::GetHash(std::string* hash) {
82 return file_.GetSha256Hash(hash); 85 return file_.GetHash(hash);
86 }
87
88 std::string DownloadFileImpl::GetHashState() {
89 return file_.GetHashState();
83 } 90 }
84 91
85 // DownloadFileInterface implementation. 92 // DownloadFileInterface implementation.
86 void DownloadFileImpl::CancelDownloadRequest() { 93 void DownloadFileImpl::CancelDownloadRequest() {
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
88 request_handle_->CancelRequest(); 95 request_handle_->CancelRequest();
89 } 96 }
90 97
91 int DownloadFileImpl::Id() const { 98 int DownloadFileImpl::Id() const {
92 return id_.local(); 99 return id_.local();
(...skipping 11 matching lines...) Expand all
104 std::string DownloadFileImpl::DebugString() const { 111 std::string DownloadFileImpl::DebugString() const {
105 return base::StringPrintf("{" 112 return base::StringPrintf("{"
106 " id_ = " "%d" 113 " id_ = " "%d"
107 " request_handle = %s" 114 " request_handle = %s"
108 " Base File = %s" 115 " Base File = %s"
109 " }", 116 " }",
110 id_.local(), 117 id_.local(),
111 request_handle_->DebugString().c_str(), 118 request_handle_->DebugString().c_str(),
112 file_.DebugString().c_str()); 119 file_.DebugString().c_str());
113 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698