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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « components/download/internal/DEPS ('k') | components/download/internal/driver_entry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_INTERNAL_DOWNLOAD_DRIVER_H_
6 #define COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_
7
8 #include <string>
9
10 #include "base/optional.h"
11 #include "components/download/internal/driver_entry.h"
12
13 namespace base {
14 class FilePath;
15 } // namespace base
16
17 namespace download {
18
19 struct DownloadParams;
20
21 // The interface that includes all the operations to interact with low level
22 // download library functionalities.
23 class DownloadDriver {
24 public:
25 // The client to receive updates from content download library.
26 // The update events for all downloads will pass through, so it's the
27 // client's responsibility to filter the events it needs to handle.
28 class Client {
29 public:
30 // Called when the low level download library is ready. |success| is true
31 // when the low level download library is ready.
32 virtual void OnDriverReady(bool success) = 0;
33
34 // Called when any download is created.
35 virtual void OnDownloadCreated(const DriverEntry& download) = 0;
36
37 // Called when any download is failed. |reason| is propagated from low level
38 // download library.
39 virtual void OnDownloadFailed(const DriverEntry& download, int reason) = 0;
40
41 // Called when any download is successfully completed.
42 virtual void OnDownloadSucceeded(const DriverEntry& download,
43 const base::FilePath& path) = 0;
44
45 // Called when any download is updated.
46 virtual void OnDownloadUpdated(const DriverEntry& download) = 0;
47 };
48
49 // Initialize the driver to receive download updates.
50 virtual void Initialize(Client* client) = 0;
51
52 // Returns if the driver is ready. Returns false when the driver is not
53 // initialized by the client, or low level download library has been shut
54 // down.
55 virtual bool IsReady() const = 0;
56
57 // Starts a new download.
58 virtual void Start(const DownloadParams& params) = 0;
59
60 // Cancels an existing download, all data associated with this download should
61 // be removed.
62 virtual void Cancel(const std::string& guid) = 0;
63
64 // Pauses the download.
65 virtual void Pause(const std::string& guid) = 0;
66
67 // Resumes the download
68 virtual void Resume(const std::string& guid) = 0;
69
70 // Find a download record from low level download library.
71 virtual base::Optional<DriverEntry> Find(const std::string& guid) = 0;
72 };
73
74 } // namespace download
75
76 #endif // COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_
OLDNEW
« 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