OLD | NEW |
---|---|
(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_PUBLIC_CLIENT_H_ | |
6 #define COMPONENTS_DOWNLOAD_PUBLIC_CLIENT_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/files/file_path.h" | |
12 #include "net/http/http_response_headers.h" | |
13 #include "url/gurl.h" | |
14 | |
15 namespace download { | |
16 | |
17 // The Client interface required by any feature that wants to start a download | |
18 // through the BackgroundDownloadService. Should be registered immediately at | |
19 // startup when the BackgroundDownloadService is created (see the factory). | |
20 class Client { | |
21 public: | |
22 // Used by OnDownloadStarted to determine whether or not the DownloadService | |
23 // should continue downloading the file or abort the attempt. | |
24 enum ShouldDownload { | |
25 CONTINUE, | |
26 ABORT, | |
27 }; | |
28 | |
29 // Called when the DownloadService is initialized and ready to be interacted | |
30 // with. |outstanding_download_guids| is a list of all downloads the | |
31 // DownloadService is aware of that are associated with this Client. | |
32 void OnServiceInitialized( | |
Peter Beverloo
2017/05/02 16:12:21
Are the `virtual` keywords missing everywhere?
David Trainor- moved to gerrit
2017/05/03 06:02:58
O_o
| |
33 const std::vector<std::string>& outstanding_download_guids); | |
Peter Beverloo
2017/05/02 16:12:21
= 0?
It'd be good to have either everything be pu
David Trainor- moved to gerrit
2017/05/03 06:02:58
Done.
| |
34 | |
35 // Return whether or not the download should be aborted (potentially in | |
36 // response to |headers|). The download will be downloading at the time this | |
37 // call is made. | |
38 ShouldDownload OnDownloadStarted( | |
39 const std::string& guid, | |
40 const GURL& final_url, | |
Peter Beverloo
2017/05/02 16:12:21
Why not an std::vector<GURL> with the entire URL c
David Trainor- moved to gerrit
2017/05/03 06:02:58
Done.
| |
41 const scoped_refptr<const net::HttpResponseHeaders> headers) = 0; | |
Peter Beverloo
2017/05/02 16:12:21
const&?
David Trainor- moved to gerrit
2017/05/03 06:02:58
Done.
| |
42 | |
43 void OnDownloadUpdated(const std::string& guid, | |
Peter Beverloo
2017/05/02 16:12:21
docs? Especially the frequency would be interestin
David Trainor- moved to gerrit
2017/05/03 06:02:58
Done.
| |
44 uint64_t bytes_downloaded) = 0; | |
45 | |
46 // TODO(dtrainor): Expose a useful error message with the failed download. | |
47 void OnDownloadFailed(const std::string& guid) = 0; | |
48 | |
49 // Called when the download was not completed before the | |
50 // DownloadParams::cancel_after timeout. | |
51 void OnDownloadTimedOut(const std::string& guid) = 0; | |
52 | |
53 // Called when the download has been aborted due to a specific number of | |
54 // retries or a specific number of bytes wasted. | |
Peter Beverloo
2017/05/02 16:12:21
"or a specific number of bytes wasted" what does t
David Trainor- moved to gerrit
2017/05/03 06:02:58
Failing only based on retry count is probably not
| |
55 void OnDownloadAborted(const std::string& guid) = 0; | |
56 | |
57 // Called when a download has been successfully completed. After this call | |
58 // the download entry will be purged from the database. The file will be | |
59 // automatically removed if it is not renamed or deleted after a window of | |
60 // time (hours). | |
Peter Beverloo
2017/05/02 16:12:21
define "time (hours)"
David Trainor- moved to gerrit
2017/05/03 06:02:58
Done.
| |
61 // TODO(dtrainor): Investigate alternate output formats. | |
62 void OnDownloadSucceeded(const std::string& guid, | |
63 const base::FilePath& path, | |
64 uint64_t size) = 0; | |
65 }; | |
Peter Beverloo
2017/05/02 16:12:21
+virtual dtor
David Trainor- moved to gerrit
2017/05/03 06:02:58
Done.
| |
66 | |
67 } // namespace download | |
68 | |
69 #endif // COMPONENTS_DOWNLOAD_PUBLIC_CLIENT_H_ | |
OLD | NEW |