OLD | NEW |
---|---|
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" | |
8 #include "content/browser/background_fetch/background_fetch_request_info.h" | |
9 #include "url/gurl.h" | |
10 | |
7 namespace content { | 11 namespace content { |
8 | 12 |
9 BackgroundFetchJobResponseData::BackgroundFetchJobResponseData( | 13 BackgroundFetchJobResponseData::BackgroundFetchJobResponseData( |
10 size_t num_requests, | 14 size_t num_requests, |
11 const BackgroundFetchResponseCompleteCallback& completion_callback) | 15 const BackgroundFetchResponseCompleteCallback& completion_callback) |
12 : blobs_(num_requests), | 16 : num_requests_(num_requests), |
13 num_requests_(num_requests), | |
14 completion_callback_(std::move(completion_callback)) {} | 17 completion_callback_(std::move(completion_callback)) {} |
15 | 18 |
16 BackgroundFetchJobResponseData::~BackgroundFetchJobResponseData() {} | 19 BackgroundFetchJobResponseData::~BackgroundFetchJobResponseData() {} |
17 | 20 |
18 void BackgroundFetchJobResponseData::AddResponse( | 21 void BackgroundFetchJobResponseData::AddResponse( |
19 int request_num, | 22 const BackgroundFetchRequestInfo& request_info, |
20 std::unique_ptr<BlobHandle> response) { | 23 std::unique_ptr<BlobHandle> response) { |
21 blobs_[request_num] = std::move(response); | 24 auto urls = base::MakeUnique<std::vector<GURL>>(std::vector<GURL>()); |
25 urls->push_back(request_info.url()); | |
26 | |
27 // TODO(harkness): Fill in headers and status code/text. | |
28 auto headers = base::MakeUnique<ServiceWorkerHeaderMap>(); | |
29 responses_.emplace_back(ServiceWorkerResponse( | |
Peter Beverloo
2017/03/27 11:05:16
You're now invoking the copy constructor. The argu
Peter Beverloo
2017/03/27 11:05:16
To confirm, we still plan on getting rid of Backgr
harkness
2017/03/27 12:23:19
Done.
harkness
2017/03/27 12:23:19
I have questions about how we're going to update t
| |
30 std::move(urls), 0 /* status code */, std::string("") /* status text */, | |
31 blink::WebServiceWorkerResponseTypeBasic, std::move(headers), | |
32 response->GetUUID(), request_info.received_bytes(), GURL(), | |
33 blink::WebServiceWorkerResponseErrorUnknown, | |
34 base::Time() /* response time */, false /* is_in_cache_storage */, | |
35 std::string("") /* cache_storage_cache_name */, | |
36 base::MakeUnique<ServiceWorkerHeaderList>())); | |
37 | |
38 blobs_.push_back(std::move(response)); | |
22 completed_requests_++; | 39 completed_requests_++; |
23 | 40 |
24 if (completed_requests_ == num_requests_) { | 41 if (completed_requests_ == num_requests_) { |
25 std::move(completion_callback_).Run(std::move(blobs_)); | 42 std::move(completion_callback_) |
43 .Run(std::move(responses_), std::move(blobs_)); | |
26 } | 44 } |
27 } | 45 } |
28 | 46 |
29 bool BackgroundFetchJobResponseData::IsComplete() { | 47 bool BackgroundFetchJobResponseData::IsComplete() { |
30 return completed_requests_ == num_requests_; | 48 return completed_requests_ == num_requests_; |
31 } | 49 } |
32 | 50 |
33 } // namespace content | 51 } // namespace content |
OLD | NEW |