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