|
@@ -126,18 +126,37 @@ static int downloader_ensure_size ( struct downloader *downloader,
|
126
|
126
|
* @v job Downloader job control interface
|
127
|
127
|
*/
|
128
|
128
|
static void downloader_job_kill ( struct job_interface *job ) {
|
129
|
|
- struct downloader *downloader =
|
|
129
|
+ struct downloader *downloader =
|
130
|
130
|
container_of ( job, struct downloader, job );
|
131
|
131
|
|
132
|
132
|
/* Terminate download */
|
133
|
133
|
downloader_finished ( downloader, -ECANCELED );
|
134
|
134
|
}
|
135
|
135
|
|
|
136
|
+/**
|
|
137
|
+ * Report progress of download job
|
|
138
|
+ *
|
|
139
|
+ * @v job Downloader job control interface
|
|
140
|
+ * @v progress Progress report to fill in
|
|
141
|
+ */
|
|
142
|
+static void downloader_job_progress ( struct job_interface *job,
|
|
143
|
+ struct job_progress *progress ) {
|
|
144
|
+ struct downloader *downloader =
|
|
145
|
+ container_of ( job, struct downloader, job );
|
|
146
|
+
|
|
147
|
+ /* This is not entirely accurate, since downloaded data may
|
|
148
|
+ * arrive out of order (e.g. with multicast protocols), but
|
|
149
|
+ * it's a reasonable first approximation.
|
|
150
|
+ */
|
|
151
|
+ progress->completed = downloader->pos;
|
|
152
|
+ progress->total = downloader->image->len;
|
|
153
|
+}
|
|
154
|
+
|
136
|
155
|
/** Downloader job control interface operations */
|
137
|
156
|
static struct job_interface_operations downloader_job_operations = {
|
138
|
157
|
.done = ignore_job_done,
|
139
|
158
|
.kill = downloader_job_kill,
|
140
|
|
- .progress = ignore_job_progress,
|
|
159
|
+ .progress = downloader_job_progress,
|
141
|
160
|
};
|
142
|
161
|
|
143
|
162
|
/****************************************************************************
|