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

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

Issue 2774263003: Added ServiceWorkerResponses to GetJobResponse callback (Closed)
Patch Set: Move PostTask to correct thread Created 3 years, 9 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 | « content/browser/background_fetch/background_fetch_job_response_data.h ('k') | no next file » | 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_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(
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
OLDNEW
« no previous file with comments | « content/browser/background_fetch/background_fetch_job_response_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698