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

Side by Side Diff: components/download/content/download_driver_impl.h

Issue 2880933002: Download driver for components/download. (Closed)
Patch Set: Work on feedback. 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_DOWNLOAD_CONTENT_DOWNLOAD_DRIVER_IMPL_H_
6 #define COMPONENTS_DOWNLOAD_CONTENT_DOWNLOAD_DRIVER_IMPL_H_
7
8 #include <string>
9
10 #include "base/files/file_path.h"
11 #include "components/download/internal/download_driver.h"
12 #include "components/download/public/download_params.h"
13 #include "content/public/browser/browser_context.h"
14 #include "content/public/browser/download_manager.h"
15
16 namespace download {
17
18 struct DriverEntry;
19
20 // Aggregates and handles all interaction between download service and content
21 // download logic.
22 class DownloadDriverImpl : public DownloadDriver,
23 public content::DownloadManager::Observer,
24 public content::DownloadItem::Observer {
25 public:
26 // Creates a driver entry based on a download item.
27 static DriverEntry CreateDriverEntry(const content::DownloadItem* item);
28
29 // Create the driver. All files downloaded will be saved to |dir|.
30 DownloadDriverImpl(content::DownloadManager* manager,
31 const base::FilePath& dir);
32 ~DownloadDriverImpl() override;
33
34 // DownloadDriver implementation.
35 void Initialize(DownloadDriver::Client* client) override;
36 void Start(const DownloadParams& params) override;
37 void Cancel(const std::string& guid) override;
38 void Pause(const std::string& guid) override;
39 void Resume(const std::string& guid) override;
40 DriverEntry Find(const std::string& guid) override;
41
42 private:
43 // content::DownloadItem::Observer implementation.
44 void OnDownloadUpdated(content::DownloadItem* item) override;
45
46 // content::DownloadManager::Observer implementation.
47 void OnDownloadCreated(content::DownloadManager* manager,
48 content::DownloadItem* item) override;
49 void OnManagerInitialized() override;
50 void ManagerGoingDown(content::DownloadManager* manager) override;
51
52 // Low level download handle.
53 content::DownloadManager* download_manager_;
54
55 // Target directory of download files.
56 base::FilePath file_dir_;
57
58 // The client that receives updates from low level download logic.
59 DownloadDriver::Client* client_;
60
61 DISALLOW_COPY_AND_ASSIGN(DownloadDriverImpl);
62 };
63
64 } // namespace download
65
66 #endif // COMPONENTS_DOWNLOAD_CONTENT_DOWNLOAD_DRIVER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698