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

Side by Side Diff: content/browser/background_fetch/background_fetch_data_manager.cc

Issue 2805813006: Set the Content-Type and Content-Length headers for BG Fetch (Closed)
Patch Set: Set the Content-Type and Content-Length headers for BG Fetch Created 3 years, 8 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 | « no previous file | content/browser/background_fetch/background_fetch_request_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/background_fetch/background_fetch_data_manager.h" 5 #include "content/browser/background_fetch/background_fetch_data_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 std::vector<BackgroundFetchSettledFetch> settled_fetches; 200 std::vector<BackgroundFetchSettledFetch> settled_fetches;
201 settled_fetches.reserve(requests.size()); 201 settled_fetches.reserve(requests.size());
202 202
203 std::vector<std::unique_ptr<BlobHandle>> blob_handles; 203 std::vector<std::unique_ptr<BlobHandle>> blob_handles;
204 204
205 for (const auto& request : requests) { 205 for (const auto& request : requests) {
206 BackgroundFetchSettledFetch settled_fetch; 206 BackgroundFetchSettledFetch settled_fetch;
207 settled_fetch.request = request->fetch_request(); 207 settled_fetch.request = request->fetch_request();
208 208
209 settled_fetch.response.url_list = request->GetURLChain(); 209 settled_fetch.response.url_list = request->GetURLChain();
210 // TODO: settled_fetch.response.status_code 210
211 // TODO(peter): The |status_code| should match what the download manager ran
212 // in to in the BackgroundFetchResponseInfo.
213 settled_fetch.response.status_code = 200;
211 // TODO: settled_fetch.response.status_text 214 // TODO: settled_fetch.response.status_text
215
212 settled_fetch.response.response_type = 216 settled_fetch.response.response_type =
213 blink::WebServiceWorkerResponseTypeDefault; 217 blink::WebServiceWorkerResponseTypeDefault;
214 // TODO: settled_fetch.response.headers 218
219 // TODO(peter): The |headers| should be set to the real response headers,
220 // but the download manager does not relay those to us yet.
221 if (!request->GetResponseType().empty()) {
222 settled_fetch.response.headers["Content-Type"] =
223 request->GetResponseType();
224 }
215 225
216 if (request->GetFileSize() > 0) { 226 if (request->GetFileSize() > 0) {
217 DCHECK(!request->GetFilePath().empty()); 227 DCHECK(!request->GetFilePath().empty());
218 228
219 std::unique_ptr<BlobHandle> blob_handle = 229 std::unique_ptr<BlobHandle> blob_handle =
220 blob_storage_context_->CreateFileBackedBlob( 230 blob_storage_context_->CreateFileBackedBlob(
221 request->GetFilePath(), 0 /* offset */, request->GetFileSize(), 231 request->GetFilePath(), 0 /* offset */, request->GetFileSize(),
222 base::Time() /* expected_modification_time */); 232 base::Time() /* expected_modification_time */);
223 233
224 // TODO(peter): Appropriately handle !blob_handle 234 // TODO(peter): Appropriately handle !blob_handle
225 if (blob_handle) { 235 if (blob_handle) {
226 settled_fetch.response.blob_uuid = blob_handle->GetUUID(); 236 settled_fetch.response.blob_uuid = blob_handle->GetUUID();
227 settled_fetch.response.blob_size = request->GetFileSize(); 237 settled_fetch.response.blob_size = request->GetFileSize();
228 238
239 // TODO(peter): Remove when we relay the real response headers.
240 settled_fetch.response.headers["Content-Length"] =
241 std::to_string(request->GetFileSize());
242
229 blob_handles.push_back(std::move(blob_handle)); 243 blob_handles.push_back(std::move(blob_handle));
230 } 244 }
231 } 245 }
232 246
233 // TODO: settled_fetch.response.error 247 // TODO: settled_fetch.response.error
234 settled_fetch.response.response_time = request->GetResponseTime(); 248 settled_fetch.response.response_time = request->GetResponseTime();
235 // TODO: settled_fetch.response.cors_exposed_header_names 249 // TODO: settled_fetch.response.cors_exposed_header_names
236 250
237 settled_fetches.push_back(settled_fetch); 251 settled_fetches.push_back(settled_fetch);
238 } 252 }
(...skipping 10 matching lines...) Expand all
249 std::move(callback).Run(blink::mojom::BackgroundFetchError::INVALID_TAG); 263 std::move(callback).Run(blink::mojom::BackgroundFetchError::INVALID_TAG);
250 return; 264 return;
251 } 265 }
252 266
253 registrations_.erase(iter); 267 registrations_.erase(iter);
254 268
255 std::move(callback).Run(blink::mojom::BackgroundFetchError::NONE); 269 std::move(callback).Run(blink::mojom::BackgroundFetchError::NONE);
256 } 270 }
257 271
258 } // namespace content 272 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_request_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698