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

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

Issue 2854973003: Fix the Unthrottled download count for parallel download (Closed)
Patch Set: Created 3 years, 7 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/url_downloader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/url_downloader.h" 5 #include "content/browser/download/url_downloader.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/threading/sequenced_task_runner_handle.h" 10 #include "base/threading/sequenced_task_runner_handle.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 base::WeakPtr<UrlDownloader> downloader_; 58 base::WeakPtr<UrlDownloader> downloader_;
59 scoped_refptr<base::SequencedTaskRunner> downloader_task_runner_; 59 scoped_refptr<base::SequencedTaskRunner> downloader_task_runner_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(RequestHandle); 61 DISALLOW_COPY_AND_ASSIGN(RequestHandle);
62 }; 62 };
63 63
64 // static 64 // static
65 std::unique_ptr<UrlDownloader> UrlDownloader::BeginDownload( 65 std::unique_ptr<UrlDownloader> UrlDownloader::BeginDownload(
66 base::WeakPtr<UrlDownloader::Delegate> delegate, 66 base::WeakPtr<UrlDownloader::Delegate> delegate,
67 std::unique_ptr<net::URLRequest> request, 67 std::unique_ptr<net::URLRequest> request,
68 const Referrer& referrer) { 68 const Referrer& referrer,
69 bool is_parallel_request) {
69 Referrer::SetReferrerForRequest(request.get(), referrer); 70 Referrer::SetReferrerForRequest(request.get(), referrer);
70 71
71 if (request->url().SchemeIs(url::kBlobScheme)) 72 if (request->url().SchemeIs(url::kBlobScheme))
72 return nullptr; 73 return nullptr;
73 74
74 // From this point forward, the |UrlDownloader| is responsible for 75 // From this point forward, the |UrlDownloader| is responsible for
75 // |started_callback|. 76 // |started_callback|.
76 std::unique_ptr<UrlDownloader> downloader( 77 std::unique_ptr<UrlDownloader> downloader(
77 new UrlDownloader(std::move(request), delegate)); 78 new UrlDownloader(std::move(request), delegate, is_parallel_request));
78 downloader->Start(); 79 downloader->Start();
79 80
80 return downloader; 81 return downloader;
81 } 82 }
82 83
83 UrlDownloader::UrlDownloader(std::unique_ptr<net::URLRequest> request, 84 UrlDownloader::UrlDownloader(std::unique_ptr<net::URLRequest> request,
84 base::WeakPtr<Delegate> delegate) 85 base::WeakPtr<Delegate> delegate,
86 bool is_parallel_request)
85 : request_(std::move(request)), 87 : request_(std::move(request)),
86 delegate_(delegate), 88 delegate_(delegate),
87 core_(request_.get(), this), 89 core_(request_.get(), this, is_parallel_request),
88 weak_ptr_factory_(this) {} 90 weak_ptr_factory_(this) {}
89 91
90 UrlDownloader::~UrlDownloader() { 92 UrlDownloader::~UrlDownloader() {
91 } 93 }
92 94
93 void UrlDownloader::Start() { 95 void UrlDownloader::Start() {
94 DCHECK(!request_->is_pending()); 96 DCHECK(!request_->is_pending());
95 97
96 request_->set_delegate(this); 98 request_->set_delegate(this);
97 request_->Start(); 99 request_->Start();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 234 }
233 235
234 void UrlDownloader::Destroy() { 236 void UrlDownloader::Destroy() {
235 BrowserThread::PostTask( 237 BrowserThread::PostTask(
236 BrowserThread::UI, FROM_HERE, 238 BrowserThread::UI, FROM_HERE,
237 base::Bind(&UrlDownloader::Delegate::OnUrlDownloaderStopped, delegate_, 239 base::Bind(&UrlDownloader::Delegate::OnUrlDownloaderStopped, delegate_,
238 this)); 240 this));
239 } 241 }
240 242
241 } // namespace content 243 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/url_downloader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698