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

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

Issue 2778793002: Start aligning BackgroundFetchRequestInfo with the passed in request object. (Closed)
Patch Set: Rebase 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
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_job_response_data.h" 5 #include "content/browser/background_fetch/background_fetch_job_response_data.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/background_fetch/background_fetch_request_info.h" 8 #include "content/browser/background_fetch/background_fetch_request_info.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 BackgroundFetchJobResponseData::BackgroundFetchJobResponseData( 13 BackgroundFetchJobResponseData::BackgroundFetchJobResponseData(
14 size_t num_requests, 14 size_t num_requests,
15 const BackgroundFetchResponseCompleteCallback& completion_callback) 15 const BackgroundFetchResponseCompleteCallback& completion_callback)
16 : num_requests_(num_requests), 16 : num_requests_(num_requests),
17 completion_callback_(std::move(completion_callback)) {} 17 completion_callback_(std::move(completion_callback)) {}
18 18
19 BackgroundFetchJobResponseData::~BackgroundFetchJobResponseData() {} 19 BackgroundFetchJobResponseData::~BackgroundFetchJobResponseData() {}
20 20
21 void BackgroundFetchJobResponseData::AddResponse( 21 void BackgroundFetchJobResponseData::AddResponse(
22 const BackgroundFetchRequestInfo& request_info, 22 const BackgroundFetchRequestInfo& request_info,
23 std::unique_ptr<BlobHandle> response) { 23 std::unique_ptr<BlobHandle> response) {
24 auto urls = base::MakeUnique<std::vector<GURL>>(std::vector<GURL>()); 24 auto urls = base::MakeUnique<std::vector<GURL>>(std::vector<GURL>());
25 urls->push_back(request_info.url()); 25 urls->push_back(request_info.GetURL());
26 26
27 // TODO(harkness): Fill in headers and status code/text. 27 // TODO(harkness): Fill in headers and status code/text.
28 auto headers = base::MakeUnique<ServiceWorkerHeaderMap>(); 28 auto headers = base::MakeUnique<ServiceWorkerHeaderMap>();
29 responses_.emplace_back( 29 responses_.emplace_back(
30 std::move(urls), 0 /* status code */, std::string("") /* status text */, 30 std::move(urls), 0 /* status code */, std::string("") /* status text */,
31 blink::WebServiceWorkerResponseTypeBasic, std::move(headers), 31 blink::WebServiceWorkerResponseTypeBasic, std::move(headers),
32 response->GetUUID(), request_info.received_bytes(), GURL(), 32 response->GetUUID(), request_info.received_bytes(), GURL(),
33 blink::WebServiceWorkerResponseErrorUnknown, 33 blink::WebServiceWorkerResponseErrorUnknown,
34 base::Time() /* response time */, false /* is_in_cache_storage */, 34 base::Time() /* response time */, false /* is_in_cache_storage */,
35 std::string("") /* cache_storage_cache_name */, 35 std::string("") /* cache_storage_cache_name */,
36 base::MakeUnique<ServiceWorkerHeaderList>()); 36 base::MakeUnique<ServiceWorkerHeaderList>());
37 37
38 blobs_.push_back(std::move(response)); 38 blobs_.push_back(std::move(response));
39 completed_requests_++; 39 completed_requests_++;
40 40
41 if (completed_requests_ == num_requests_) { 41 if (completed_requests_ == num_requests_) {
42 std::move(completion_callback_) 42 std::move(completion_callback_)
43 .Run(std::move(responses_), std::move(blobs_)); 43 .Run(std::move(responses_), std::move(blobs_));
44 } 44 }
45 } 45 }
46 46
47 bool BackgroundFetchJobResponseData::IsComplete() { 47 bool BackgroundFetchJobResponseData::IsComplete() {
48 return completed_requests_ == num_requests_; 48 return completed_requests_ == num_requests_;
49 } 49 }
50 50
51 } // namespace content 51 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698