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

Side by Side 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 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_INTERNAL_DOWNLOAD_DRIVER_H_
6 #define COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_
7
8 #include <string>
9
10 namespace base {
11
12 class FilePath;
13
14 } // namespace base
15
16 namespace download {
17
18 struct DownloadParams;
19
20 // The interface that includes all the operations to interact with content
21 // download functionalities.
22 class DownloadDriver {
23 public:
24 // Observer to receive updates from content download library.
25 // The update events for all downloads will pass through, so it's the
26 // observer's responsibility to filter the events it needs to handle.
27 class Observer {
28 public:
29 // Called when the driver finishes initialization.
30 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
31
32 // Called when any download is created.
33 virtual void OnDownloadCreated(const std::string& guid) = 0;
34
35 // Called when any download is failed.
36 virtual void OnDownloadFailed(const std::string& guid, int reason) = 0;
37
38 // Called when any download is successfully completed.
39 virtual void OnDownloadSucceeded(const std::string& guid,
40 const base::FilePath& path,
41 uint64_t size) = 0;
42
43 // Called when any download is updated.
44 virtual void OnDownloadUpdated(const std::string& guid,
45 uint64_t bytes_downloaded) = 0;
46 };
47
48 // Starts a new download.
49 virtual void Start(const DownloadParams& params) = 0;
50
51 // Cancels an existing download, all data associated with this download should
52 // be removed.
53 virtual void Cancel(const std::string& guid) = 0;
54
55 // Pauses the download.
56 virtual void Pause(const std::string& guid) = 0;
57
58 // Resumes the download
59 virtual void Resume(const std::string& guid) = 0;
60
61 // If the download driver is ready to accept download operation calls.
62 virtual bool IsReady() const = 0;
63
64 // Set the observer to receive download updates. Can set to nullptr to stop
65 // listening to download updates.
66 virtual void SetObserver(Observer* observer) = 0;
67 };
68
69 } // namespace download
70
71 #endif // COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698