| 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 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_RESPONSE_DATA_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_RESPONSE_DATA_H_ |
| 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_RESPONSE_DATA_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_RESPONSE_DATA_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
| 16 #include "content/common/service_worker/service_worker_types.h" |
| 15 #include "content/public/browser/blob_handle.h" | 17 #include "content/public/browser/blob_handle.h" |
| 16 | 18 |
| 17 namespace content { | 19 namespace content { |
| 18 | 20 |
| 21 class BackgroundFetchRequestInfo; |
| 22 |
| 19 using BackgroundFetchResponseCompleteCallback = | 23 using BackgroundFetchResponseCompleteCallback = |
| 20 base::Callback<void(std::vector<std::unique_ptr<BlobHandle>>)>; | 24 base::Callback<void(std::vector<ServiceWorkerResponse>, |
| 25 std::vector<std::unique_ptr<BlobHandle>>)>; |
| 21 | 26 |
| 22 // Temporary holding class to aggregate the response data for requests | 27 // Temporary holding class to aggregate the response data for requests |
| 23 // associated with a given BackgroundFetch job. | 28 // associated with a given BackgroundFetch job. |
| 24 class BackgroundFetchJobResponseData { | 29 class BackgroundFetchJobResponseData { |
| 25 public: | 30 public: |
| 26 BackgroundFetchJobResponseData( | 31 BackgroundFetchJobResponseData( |
| 27 size_t num_requests, | 32 size_t num_requests, |
| 28 const BackgroundFetchResponseCompleteCallback& completion_callback); | 33 const BackgroundFetchResponseCompleteCallback& completion_callback); |
| 29 ~BackgroundFetchJobResponseData(); | 34 ~BackgroundFetchJobResponseData(); |
| 30 | 35 |
| 31 void AddResponse(int request_num, std::unique_ptr<BlobHandle> response); | 36 void AddResponse(const BackgroundFetchRequestInfo& request_info, |
| 37 std::unique_ptr<BlobHandle> response); |
| 32 bool IsComplete(); | 38 bool IsComplete(); |
| 33 | 39 |
| 34 private: | 40 private: |
| 35 std::vector<std::unique_ptr<BlobHandle>> blobs_; | 41 std::vector<std::unique_ptr<BlobHandle>> blobs_; |
| 42 std::vector<ServiceWorkerResponse> responses_; |
| 36 size_t num_requests_ = 0; | 43 size_t num_requests_ = 0; |
| 37 size_t completed_requests_ = 0; | 44 size_t completed_requests_ = 0; |
| 38 const std::string job_guid_; | 45 const std::string job_guid_; |
| 39 BackgroundFetchResponseCompleteCallback completion_callback_; | 46 BackgroundFetchResponseCompleteCallback completion_callback_; |
| 40 | 47 |
| 41 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobResponseData); | 48 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobResponseData); |
| 42 }; | 49 }; |
| 43 | 50 |
| 44 } // namespace content | 51 } // namespace content |
| 45 | 52 |
| 46 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_RESPONSE_DATA_H
_ | 53 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_RESPONSE_DATA_H
_ |
| OLD | NEW |