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

Unified Diff: components/download/internal/download_driver.h

Issue 2880933002: Download driver for components/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 side-by-side diff with in-line comments
Download patch
Index: components/download/internal/download_driver.h
diff --git a/components/download/internal/download_driver.h b/components/download/internal/download_driver.h
new file mode 100644
index 0000000000000000000000000000000000000000..9e614a5b7791ca3036771988e737b7f103c96d96
--- /dev/null
+++ b/components/download/internal/download_driver.h
@@ -0,0 +1,71 @@
+// 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.
+
+#ifndef COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_
+#define COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_
+
+#include <string>
+
+namespace base {
+
+class FilePath;
+
+} // namespace base
+
+namespace download {
+
+struct DownloadParams;
+
+// The interface that includes all the operations to interact with content
+// download functionalities.
+class DownloadDriver {
+ public:
+ // Observer to receive updates from content download library.
+ // The update events for all downloads will pass through, so it's the
+ // observer's responsibility to filter the events it needs to handle.
+ class Observer {
+ public:
+ // Called when the driver finishes initialization.
+ virtual void OnDriverReady() = 0;
David Trainor- moved to gerrit 2017/05/15 20:08:15 We will need a list of (at least) all in progress
xingliu 2017/05/17 19:34:52 I think get the vector of all downloads here is ki
+
+ // Called when any download is created.
+ virtual void OnDownloadCreated(const std::string& guid) = 0;
+
+ // Called when any download is failed.
+ virtual void OnDownloadFailed(const std::string& guid, int reason) = 0;
+
+ // Called when any download is successfully completed.
+ virtual void OnDownloadSucceeded(const std::string& guid,
+ const base::FilePath& path,
+ uint64_t size) = 0;
+
+ // Called when any download is updated.
+ virtual void OnDownloadUpdated(const std::string& guid,
+ uint64_t bytes_downloaded) = 0;
+ };
+
+ // Starts a new download.
+ virtual void Start(const DownloadParams& params) = 0;
+
+ // Cancels an existing download, all data associated with this download should
+ // be removed.
+ virtual void Cancel(const std::string& guid) = 0;
+
+ // Pauses the download.
+ virtual void Pause(const std::string& guid) = 0;
+
+ // Resumes the download
+ virtual void Resume(const std::string& guid) = 0;
+
+ // If the download driver is ready to accept download operation calls.
+ virtual bool IsReady() const = 0;
+
+ // Set the observer to receive download updates. Can set to nullptr to stop
+ // listening to download updates.
+ virtual void SetObserver(Observer* observer) = 0;
+};
+
+} // namespace download
+
+#endif // COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_

Powered by Google App Engine
This is Rietveld 408576698