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

Unified Diff: content/browser/background_fetch/background_fetch_data_manager.cc

Issue 2814683003: Pass through the response code and headers in Background Fetch (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_job_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/background_fetch/background_fetch_data_manager.cc
diff --git a/content/browser/background_fetch/background_fetch_data_manager.cc b/content/browser/background_fetch/background_fetch_data_manager.cc
index b5d4ab47117293ead43117003cd3af8a993bfedc..bc8210ed24daab274e8006574df6ef39f18a94ff 100644
--- a/content/browser/background_fetch/background_fetch_data_manager.cc
+++ b/content/browser/background_fetch/background_fetch_data_manager.cc
@@ -211,40 +211,31 @@ void BackgroundFetchDataManager::GetSettledFetchesForRegistration(
url::Origin(request->GetURLChain().back().GetOrigin()));
settled_fetch.response.url_list = request->GetURLChain();
-
- // TODO(peter): The |status_code| should match what the download manager ran
- // in to in the BackgroundFetchResponseInfo.
- settled_fetch.response.status_code = 200;
- // TODO: settled_fetch.response.status_text
-
settled_fetch.response.response_type =
blink::kWebServiceWorkerResponseTypeDefault;
- // TODO(peter): The |headers| should be set to the real response headers,
- // but the download manager does not relay those to us yet.
- if (!request->GetResponseType().empty() && !opaque) {
- settled_fetch.response.headers["Content-Type"] =
- request->GetResponseType();
- }
-
- if (request->GetFileSize() > 0 && !opaque) {
- DCHECK(!request->GetFilePath().empty());
-
- std::unique_ptr<BlobHandle> blob_handle =
- blob_storage_context_->CreateFileBackedBlob(
- request->GetFilePath(), 0 /* offset */, request->GetFileSize(),
- base::Time() /* expected_modification_time */);
-
- // TODO(peter): Appropriately handle !blob_handle
- if (blob_handle) {
- settled_fetch.response.blob_uuid = blob_handle->GetUUID();
- settled_fetch.response.blob_size = request->GetFileSize();
-
- // TODO(peter): Remove when we relay the real response headers.
- settled_fetch.response.headers["Content-Length"] =
- std::to_string(request->GetFileSize());
-
- blob_handles.push_back(std::move(blob_handle));
+ if (!opaque) {
+ settled_fetch.response.status_code = request->GetResponseCode();
+ settled_fetch.response.status_text = request->GetResponseText();
+ settled_fetch.response.headers.insert(
+ request->GetResponseHeaders().begin(),
+ request->GetResponseHeaders().end());
+
+ // Include the response data as a blob backed by the downloaded file.
+ if (request->GetFileSize() > 0) {
+ DCHECK(!request->GetFilePath().empty());
+ std::unique_ptr<BlobHandle> blob_handle =
+ blob_storage_context_->CreateFileBackedBlob(
+ request->GetFilePath(), 0 /* offset */, request->GetFileSize(),
+ base::Time() /* expected_modification_time */);
+
+ // TODO(peter): Appropriately handle !blob_handle
+ if (blob_handle) {
+ settled_fetch.response.blob_uuid = blob_handle->GetUUID();
+ settled_fetch.response.blob_size = request->GetFileSize();
+
+ blob_handles.push_back(std::move(blob_handle));
+ }
}
}
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_job_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698