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

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: DownloadSaveInfo::offset is now int64. 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 : file_(info->save_info.file_path, 20 : file_(info->save_info.file_path,
21 info->url(), 21 info->url(),
22 info->referrer_url, 22 info->referrer_url,
23 info->received_bytes, 23 info->received_bytes,
24 info->save_info.hash_state,
24 info->save_info.file_stream), 25 info->save_info.file_stream),
25 id_(info->download_id), 26 id_(info->download_id),
26 request_handle_(request_handle), 27 request_handle_(request_handle),
27 download_manager_(download_manager) { 28 download_manager_(download_manager) {
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
29 } 30 }
30 31
31 DownloadFileImpl::~DownloadFileImpl() { 32 DownloadFileImpl::~DownloadFileImpl() {
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
33 } 34 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 72 }
72 73
73 int64 DownloadFileImpl::BytesSoFar() const { 74 int64 DownloadFileImpl::BytesSoFar() const {
74 return file_.bytes_so_far(); 75 return file_.bytes_so_far();
75 } 76 }
76 77
77 bool DownloadFileImpl::GetSha256Hash(std::string* hash) { 78 bool DownloadFileImpl::GetSha256Hash(std::string* hash) {
78 return file_.GetSha256Hash(hash); 79 return file_.GetSha256Hash(hash);
79 } 80 }
80 81
82 std::string DownloadFileImpl::GetSha256HashState() {
83 return file_.GetSha256HashState();
84 }
85
81 // DownloadFileInterface implementation. 86 // DownloadFileInterface implementation.
82 void DownloadFileImpl::CancelDownloadRequest() { 87 void DownloadFileImpl::CancelDownloadRequest() {
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
84 request_handle_->CancelRequest(); 89 request_handle_->CancelRequest();
85 } 90 }
86 91
87 int DownloadFileImpl::Id() const { 92 int DownloadFileImpl::Id() const {
88 return id_.local(); 93 return id_.local();
89 } 94 }
90 95
91 DownloadManager* DownloadFileImpl::GetDownloadManager() { 96 DownloadManager* DownloadFileImpl::GetDownloadManager() {
92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
93 return download_manager_.get(); 98 return download_manager_.get();
94 } 99 }
95 100
96 const DownloadId& DownloadFileImpl::GlobalId() const { 101 const DownloadId& DownloadFileImpl::GlobalId() const {
97 return id_; 102 return id_;
98 } 103 }
99 104
100 std::string DownloadFileImpl::DebugString() const { 105 std::string DownloadFileImpl::DebugString() const {
101 return base::StringPrintf("{" 106 return base::StringPrintf("{"
102 " id_ = " "%d" 107 " id_ = " "%d"
103 " request_handle = %s" 108 " request_handle = %s"
104 " Base File = %s" 109 " Base File = %s"
105 " }", 110 " }",
106 id_.local(), 111 id_.local(),
107 request_handle_->DebugString().c_str(), 112 request_handle_->DebugString().c_str(),
108 file_.DebugString().c_str()); 113 file_.DebugString().c_str());
109 } 114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698