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

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

Issue 2752603002: Propagate server response error and interrupt the download. (Closed)
Patch Set: Merge recent changes in the tree. Created 3 years, 9 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
« no previous file with comments | « content/browser/download/download_job.h ('k') | content/browser/download/download_worker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_job.h" 5 #include "content/browser/download/download_job.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "content/browser/download/download_file.h" 8 #include "content/browser/download/download_file.h"
9 #include "content/browser/download/download_item_impl.h" 9 #include "content/browser/download/download_item_impl.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 void DownloadJob::Resume(bool resume_request) { 23 void DownloadJob::Resume(bool resume_request) {
24 is_paused_ = false; 24 is_paused_ = false;
25 } 25 }
26 26
27 void DownloadJob::StartDownload() const { 27 void DownloadJob::StartDownload() const {
28 download_item_->StartDownload(); 28 download_item_->StartDownload();
29 } 29 }
30 30
31 void DownloadJob::Interrupt(DownloadInterruptReason reason) {
32 download_item_->InterruptAndDiscardPartialState(reason);
33 download_item_->UpdateObservers();
34 }
35
31 void DownloadJob::AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader, 36 void DownloadJob::AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader,
32 int64_t offset, 37 int64_t offset,
33 int64_t length) { 38 int64_t length) {
34 DCHECK_CURRENTLY_ON(BrowserThread::UI); 39 DCHECK_CURRENTLY_ON(BrowserThread::UI);
35 DownloadFile* download_file = download_item_->download_file_.get(); 40 DownloadFile* download_file = download_item_->download_file_.get();
36 if (!download_file) { 41 if (!download_file) {
37 // TODO(xingliu): Handle early and late incoming streams, see crbug/702683. 42 // TODO(xingliu): Handle early and late incoming streams, see crbug/702683.
38 VLOG(1) << "Download file is released when byte stream arrived. Discard " 43 VLOG(1) << "Download file is released when byte stream arrived. Discard "
39 "the byte stream."; 44 "the byte stream.";
40 return; 45 return;
41 } 46 }
42 47
43 // download_file_ is owned by download_item_ on the UI thread and is always 48 // download_file_ is owned by download_item_ on the UI thread and is always
44 // deleted on the FILE thread after download_file_ is nulled out. 49 // deleted on the FILE thread after download_file_ is nulled out.
45 // So it's safe to use base::Unretained here. 50 // So it's safe to use base::Unretained here.
46 BrowserThread::PostTask( 51 BrowserThread::PostTask(
47 BrowserThread::FILE, FROM_HERE, 52 BrowserThread::FILE, FROM_HERE,
48 base::Bind(&DownloadFile::AddByteStream, base::Unretained(download_file), 53 base::Bind(&DownloadFile::AddByteStream, base::Unretained(download_file),
49 base::Passed(&stream_reader), offset, length)); 54 base::Passed(&stream_reader), offset, length));
50 } 55 }
51 56
52 } // namespace content 57 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_job.h ('k') | content/browser/download/download_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698