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

Side by Side Diff: components/download/public/background_download_service.h

Issue 2851303003: Add the download component and initial setup (Closed)
Patch Set: Removed accidental rename 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_PUBLIC_BACKGROUND_DOWNLOAD_SERVICE_H_
6 #define COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_DOWNLOAD_SERVICE_H_
7
8 #include <string>
9
10 #include "base/files/file_path.h"
11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/sequenced_task_runner.h"
15 #include "components/keyed_service/core/keyed_service.h"
16
17 namespace download {
18
19 struct DownloadParams;
20 struct SchedulingParams;
21
22 // A service responsible for helping facilitate the scheduling and downloading
23 // of file content from the web. See |DownloadParams| for more details on the
24 // types of scheduling that can be achieved and the required input parameters
25 // for starting a download. Note that BackgroundDownloadServices with a valid
26 // storage directory will persist the requests across restarts. This means that
27 // any feature requesting a download will have to implement a download::Client
28 // interface so this class knows who to contact when a download completes after
29 // a process restart.
30 class BackgroundDownloadService : public KeyedService {
Peter Beverloo 2017/05/02 16:12:21 Why did you decide to go with BackgroundDownloadSe
David Trainor- moved to gerrit 2017/05/03 06:02:58 Will change to DownloadService once your other CL
31 public:
32 // |storage_dir| is a path to where all the local storage will be. This will
33 // hold the internal database as well as any temporary files on disk. If this
34 // is an empty path, the service will not persist any information to disk and
35 // will act as an in-memory only service (this means no auto-retries after
36 // restarts, no files written on completion, etc.).
37 // |background_task_runner| will be used for all disk reads and writes.
38 static BackgroundDownloadService* Create(
39 const base::FilePath& storage_dir,
40 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner);
41
42 // Sends the download to the service. A callback to
43 // |DownloadParams::callback| will be triggered once the download has been
44 // persisted and saved in the service
45 virtual void StartDownload(const DownloadParams& download_params) = 0;
46
47 // Allows any feature to pause or resume downloads at will. Paused downloads
48 // will not start or stop based on scheduling criteria. They will be
49 // effectively frozen.
50 virtual void PauseDownload(const std::string& guid) = 0;
51 virtual void ResumeDownload(const std::string& guid) = 0;
52
53 // Cancels a download in this service. The canceled download will be
54 // interrupted if it is running.
55 virtual void CancelDownload(const std::string& guid) = 0;
56
57 // Changes the current scheduling criteria for a download. This is useful if
58 // a user action might constrain or loosen the device state during which this
59 // download can run.
60 virtual void ChangeDownloadCriteria(const std::string& guid,
61 const SchedulingParams& params) = 0;
62
63 protected:
64 BackgroundDownloadService() = default;
65
66 private:
67 DISALLOW_COPY_AND_ASSIGN(BackgroundDownloadService);
68 };
69
70 } // namespace download
71
72 #endif // COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_DOWNLOAD_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698