OLD | NEW |
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_worker.h" | 5 #include "content/browser/download/download_worker.h" |
6 | 6 |
7 #include "content/browser/download/download_create_info.h" | 7 #include "content/browser/download/download_create_info.h" |
8 #include "content/public/browser/download_interrupt_reasons.h" | 8 #include "content/public/browser/download_interrupt_reasons.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "net/traffic_annotation/network_traffic_annotation.h" | 10 #include "net/traffic_annotation/network_traffic_annotation.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 namespace { | 13 namespace { |
14 | 14 |
15 const int kVerboseLevel = 1; | 15 const int kVerboseLevel = 1; |
16 | 16 |
17 class CompletedByteStreamReader : public ByteStreamReader { | 17 class CompletedByteStreamReader : public ByteStreamReader { |
18 public: | 18 public: |
19 CompletedByteStreamReader(int status) : status_(status) {}; | 19 CompletedByteStreamReader(int status) : status_(status) {}; |
20 ~CompletedByteStreamReader() override = default; | 20 ~CompletedByteStreamReader() override = default; |
21 | 21 |
22 // ByteStreamReader implementations: | 22 // ByteStreamReader implementations: |
23 ByteStreamReader::StreamState Read(scoped_refptr<net::IOBuffer>* data, | 23 ByteStreamReader::StreamState Read(scoped_refptr<net::IOBuffer>* data, |
24 size_t* length) override { | 24 size_t* length) override { |
25 return ByteStreamReader::STREAM_COMPLETE; | 25 return ByteStreamReader::STREAM_COMPLETE; |
26 } | 26 } |
27 int GetStatus() const override { return status_; } | 27 int GetStatus() const override { return status_; } |
28 void RegisterCallback(const base::Closure& sink_callback) override {}; | 28 void RegisterCallback(const base::Closure& sink_callback) override {} |
29 | 29 |
30 private: | 30 private: |
31 int status_; | 31 int status_; |
32 }; | 32 }; |
33 | 33 |
34 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> | 34 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> |
35 CreateUrlDownloader(std::unique_ptr<DownloadUrlParameters> params, | 35 CreateUrlDownloader(std::unique_ptr<DownloadUrlParameters> params, |
36 base::WeakPtr<UrlDownloader::Delegate> delegate) { | 36 base::WeakPtr<UrlDownloader::Delegate> delegate) { |
37 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 37 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
38 | 38 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 url_downloader_.reset(); | 133 url_downloader_.reset(); |
134 } | 134 } |
135 | 135 |
136 void DownloadWorker::AddUrlDownloader( | 136 void DownloadWorker::AddUrlDownloader( |
137 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> | 137 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> |
138 downloader) { | 138 downloader) { |
139 url_downloader_ = std::move(downloader); | 139 url_downloader_ = std::move(downloader); |
140 } | 140 } |
141 | 141 |
142 } // namespace content | 142 } // namespace content |
OLD | NEW |