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

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

Issue 2880933002: Download driver for components/download. (Closed)
Patch Set: Polish comment. 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
« no previous file with comments | « components/download/internal/DEPS ('k') | components/download/internal/driver_entry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..88247d18d5d0ba8f7e2f8184346dcee5e6765599
--- /dev/null
+++ b/components/download/internal/download_driver.h
@@ -0,0 +1,76 @@
+// 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>
+
+#include "base/optional.h"
+#include "components/download/internal/driver_entry.h"
+
+namespace base {
+class FilePath;
+} // namespace base
+
+namespace download {
+
+struct DownloadParams;
+
+// The interface that includes all the operations to interact with low level
+// download library functionalities.
+class DownloadDriver {
+ public:
+ // The client to receive updates from content download library.
+ // The update events for all downloads will pass through, so it's the
+ // client's responsibility to filter the events it needs to handle.
+ class Client {
+ public:
+ // Called when the low level download library is ready. |success| is true
+ // when the low level download library is ready.
+ virtual void OnDriverReady(bool success) = 0;
+
+ // Called when any download is created.
+ virtual void OnDownloadCreated(const DriverEntry& download) = 0;
+
+ // Called when any download is failed. |reason| is propagated from low level
+ // download library.
+ virtual void OnDownloadFailed(const DriverEntry& download, int reason) = 0;
+
+ // Called when any download is successfully completed.
+ virtual void OnDownloadSucceeded(const DriverEntry& download,
+ const base::FilePath& path) = 0;
+
+ // Called when any download is updated.
+ virtual void OnDownloadUpdated(const DriverEntry& download) = 0;
+ };
+
+ // Initialize the driver to receive download updates.
+ virtual void Initialize(Client* client) = 0;
+
+ // Returns if the driver is ready. Returns false when the driver is not
+ // initialized by the client, or low level download library has been shut
+ // down.
+ virtual bool IsReady() const = 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;
+
+ // Find a download record from low level download library.
+ virtual base::Optional<DriverEntry> Find(const std::string& guid) = 0;
+};
+
+} // namespace download
+
+#endif // COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_
« no previous file with comments | « components/download/internal/DEPS ('k') | components/download/internal/driver_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698