Chromium Code Reviews| 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_job.h" | 5 #include "content/browser/download/download_job.h" |
| 6 | 6 |
| 7 #include "content/browser/download/download_item_impl.h" | |
| 8 | |
| 7 namespace content { | 9 namespace content { |
| 8 | 10 |
| 9 // Unknown download progress. | 11 DownloadJob::DownloadJob() : download_item_(nullptr) {} |
| 10 const int kDownloadProgressUnknown = -1; | |
| 11 | |
| 12 // Unknown download speed. | |
| 13 const int kDownloadSpeedUnknown = -1; | |
| 14 | |
| 15 DownloadJob::DownloadJob() : manager_(nullptr) {} | |
| 16 | 12 |
| 17 DownloadJob::~DownloadJob() = default; | 13 DownloadJob::~DownloadJob() = default; |
| 18 | 14 |
| 19 void DownloadJob::OnAttached(DownloadJob::Manager* manager) { | 15 void DownloadJob::Attach(DownloadItemImpl* download_item) { |
| 20 DCHECK(!manager_) << "DownloadJob::Manager has already been attached."; | 16 download_item_ = download_item; |
| 21 manager_ = manager; | |
| 22 } | 17 } |
| 23 | 18 |
| 24 void DownloadJob::OnBeforeDetach() { | 19 void DownloadJob::InitializeDownloadFile() const { |
| 25 manager_ = nullptr; | 20 download_item_->InitializeDownloadFile(); |
|
asanka
2017/02/16 16:27:39
It would be great if we could have calls going one
xingliu
2017/02/20 18:59:10
Ideally the file should live with DownloadJob subc
| |
| 26 } | |
| 27 | |
| 28 void DownloadJob::StartedSavingResponse() { | |
| 29 if (manager_) | |
| 30 manager_->OnSavingStarted(this); | |
| 31 } | |
| 32 | |
| 33 void DownloadJob::Interrupt(DownloadInterruptReason reason) { | |
| 34 if (manager_) | |
| 35 manager_->OnDownloadInterrupted(this, reason); | |
| 36 } | |
| 37 | |
| 38 void DownloadJob::Complete() { | |
| 39 if (manager_) | |
| 40 manager_->OnDownloadComplete(this); | |
| 41 } | 21 } |
| 42 | 22 |
| 43 } // namespace content | 23 } // namespace content |
| OLD | NEW |