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

Unified Diff: components/download/content/download_driver_impl.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/content/DEPS ('k') | components/download/content/download_driver_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/download/content/download_driver_impl.h
diff --git a/components/download/content/download_driver_impl.h b/components/download/content/download_driver_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..c7c5b1ce1b2a66e07658cd9224b7633270fe040c
--- /dev/null
+++ b/components/download/content/download_driver_impl.h
@@ -0,0 +1,67 @@
+// 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_CONTENT_DOWNLOAD_DRIVER_IMPL_H_
+#define COMPONENTS_DOWNLOAD_CONTENT_DOWNLOAD_DRIVER_IMPL_H_
+
+#include <string>
+
+#include "base/files/file_path.h"
+#include "components/download/internal/download_driver.h"
+#include "components/download/public/download_params.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/download_manager.h"
+
+namespace download {
+
+struct DriverEntry;
+
+// Aggregates and handles all interaction between download service and content
+// download logic.
+class DownloadDriverImpl : public DownloadDriver,
+ public content::DownloadManager::Observer,
+ public content::DownloadItem::Observer {
+ public:
+ // Creates a driver entry based on a download item.
+ static DriverEntry CreateDriverEntry(const content::DownloadItem* item);
+
+ // Create the driver. All files downloaded will be saved to |dir|.
+ DownloadDriverImpl(content::DownloadManager* manager,
+ const base::FilePath& dir);
+ ~DownloadDriverImpl() override;
+
+ // DownloadDriver implementation.
+ void Initialize(DownloadDriver::Client* client) override;
+ bool IsReady() const override;
+ void Start(const DownloadParams& params) override;
+ void Cancel(const std::string& guid) override;
+ void Pause(const std::string& guid) override;
+ void Resume(const std::string& guid) override;
+ base::Optional<DriverEntry> Find(const std::string& guid) override;
+
+ private:
+ // content::DownloadItem::Observer implementation.
+ void OnDownloadUpdated(content::DownloadItem* item) override;
+
+ // content::DownloadManager::Observer implementation.
+ void OnDownloadCreated(content::DownloadManager* manager,
+ content::DownloadItem* item) override;
+ void OnManagerInitialized() override;
+ void ManagerGoingDown(content::DownloadManager* manager) override;
+
+ // Low level download handle.
+ content::DownloadManager* download_manager_;
+
+ // Target directory of download files.
+ base::FilePath file_dir_;
+
+ // The client that receives updates from low level download logic.
+ DownloadDriver::Client* client_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadDriverImpl);
+};
+
+} // namespace download
+
+#endif // COMPONENTS_DOWNLOAD_CONTENT_DOWNLOAD_DRIVER_IMPL_H_
« no previous file with comments | « components/download/content/DEPS ('k') | components/download/content/download_driver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698