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

Unified Diff: content/browser/download/download_job.cc

Issue 2645133003: Introduce DownloadJob for DownloadItem refactoring. (Closed)
Patch Set: Small tweak to inline getter. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_job.cc
diff --git a/content/browser/download/download_job.cc b/content/browser/download/download_job.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d5480018e303c03b84d2b57ce1ea992012dd9df6
--- /dev/null
+++ b/content/browser/download/download_job.cc
@@ -0,0 +1,42 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/download/download_job.h"
+
+namespace content {
+
+// Unknown download progress.
+const int kDownloadProgressUnknown = -1;
+
+// Unknown download speed.
+const int kDownloadSpeedUnknown = -1;
+
+DownloadJob::DownloadJob() : manager_(nullptr), type_(Type::FILE) {}
+
+DownloadJob::~DownloadJob() = default;
+
+void DownloadJob::OnAttached(DownloadJob::Manager* manager) {
+ manager_ = manager;
+}
+
+void DownloadJob::OnBeforeDetach() {
+ manager_ = nullptr;
+}
+
+void DownloadJob::StartedSavingResponse() {
+ DCHECK(manager_) << "DownloadJob::Manager is detached.";
+ manager_->StartSaving(this);
+}
+
+void DownloadJob::Interrupt(DownloadInterruptReason reason) {
+ DCHECK(manager_) << "DownloadJob::Manager is detached.";
+ manager_->OnDownloadInterrupted(this, reason);
+}
+
+void DownloadJob::Complete() {
+ DCHECK(manager_) << "DownloadJob::Manager is detached.";
+ manager_->OnDownloadComplete(this);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698