| 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_test_base.h" | 5 #include "content/browser/background_fetch/background_fetch_test_base.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 // Responds to requests to |url| with the given |response|. | 119 // Responds to requests to |url| with the given |response|. |
| 120 void RegisterResponse(const GURL& url, | 120 void RegisterResponse(const GURL& url, |
| 121 std::unique_ptr<TestResponse> response) { | 121 std::unique_ptr<TestResponse> response) { |
| 122 DCHECK_EQ(registered_responses_.count(url), 0u); | 122 DCHECK_EQ(registered_responses_.count(url), 0u); |
| 123 registered_responses_[url] = std::move(response); | 123 registered_responses_[url] = std::move(response); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Called when the Background Fetch system starts a download, all information | 126 // Called when the Background Fetch system starts a download, all information |
| 127 // for which is contained in the |params|. | 127 // for which is contained in the |params|. |
| 128 void DownloadUrl(std::unique_ptr<DownloadUrlParameters> params) override { | 128 void DownloadUrl( |
| 129 std::unique_ptr<DownloadUrlParameters> params, |
| 130 const net::NetworkTrafficAnnotationTag& traffic_annotation) override { |
| 129 auto iter = registered_responses_.find(params->url()); | 131 auto iter = registered_responses_.find(params->url()); |
| 130 if (iter == registered_responses_.end()) | 132 if (iter == registered_responses_.end()) |
| 131 return; | 133 return; |
| 132 | 134 |
| 133 TestResponse* response = iter->second.get(); | 135 TestResponse* response = iter->second.get(); |
| 134 | 136 |
| 135 std::unique_ptr<FakeDownloadItem> download_item = | 137 std::unique_ptr<FakeDownloadItem> download_item = |
| 136 base::MakeUnique<FakeDownloadItem>(); | 138 base::MakeUnique<FakeDownloadItem>(); |
| 137 | 139 |
| 138 download_item->SetURL(params->url()); | 140 download_item->SetURL(params->url()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // Create a ServiceWorkerFetchRequest request with the same information. | 295 // Create a ServiceWorkerFetchRequest request with the same information. |
| 294 return ServiceWorkerFetchRequest(gurl, method, ServiceWorkerHeaderMap(), | 296 return ServiceWorkerFetchRequest(gurl, method, ServiceWorkerHeaderMap(), |
| 295 Referrer(), false /* is_reload */); | 297 Referrer(), false /* is_reload */); |
| 296 } | 298 } |
| 297 | 299 |
| 298 MockDownloadManager* BackgroundFetchTestBase::download_manager() { | 300 MockDownloadManager* BackgroundFetchTestBase::download_manager() { |
| 299 return download_manager_; | 301 return download_manager_; |
| 300 } | 302 } |
| 301 | 303 |
| 302 } // namespace content | 304 } // namespace content |
| OLD | NEW |