OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_sync/background_sync_manager.h" | 5 #include "content/browser/background_sync/background_sync_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 void TearDown() override { | 152 void TearDown() override { |
153 // Restore the network observer functionality for subsequent tests | 153 // Restore the network observer functionality for subsequent tests |
154 background_sync_test_util::SetIgnoreNetworkChangeNotifier(false); | 154 background_sync_test_util::SetIgnoreNetworkChangeNotifier(false); |
155 } | 155 } |
156 | 156 |
157 void RegisterServiceWorkers() { | 157 void RegisterServiceWorkers() { |
158 bool called_1 = false; | 158 bool called_1 = false; |
159 bool called_2 = false; | 159 bool called_2 = false; |
160 helper_->context()->RegisterServiceWorker( | 160 helper_->context()->RegisterServiceWorker( |
161 GURL(kPattern1), GURL(kScript1), NULL, | 161 GURL(kScript1), ServiceWorkerRegistrationOptions(GURL(kPattern1)), |
| 162 nullptr, |
162 base::Bind(&RegisterServiceWorkerCallback, &called_1, | 163 base::Bind(&RegisterServiceWorkerCallback, &called_1, |
163 &sw_registration_id_1_)); | 164 &sw_registration_id_1_)); |
164 | 165 |
165 helper_->context()->RegisterServiceWorker( | 166 helper_->context()->RegisterServiceWorker( |
166 GURL(kPattern2), GURL(kScript2), NULL, | 167 GURL(kScript2), ServiceWorkerRegistrationOptions(GURL(kPattern2)), |
| 168 nullptr, |
167 base::Bind(&RegisterServiceWorkerCallback, &called_2, | 169 base::Bind(&RegisterServiceWorkerCallback, &called_2, |
168 &sw_registration_id_2_)); | 170 &sw_registration_id_2_)); |
169 base::RunLoop().RunUntilIdle(); | 171 base::RunLoop().RunUntilIdle(); |
170 EXPECT_TRUE(called_1); | 172 EXPECT_TRUE(called_1); |
171 EXPECT_TRUE(called_2); | 173 EXPECT_TRUE(called_2); |
172 | 174 |
173 // Hang onto the registrations as they need to be "live" when | 175 // Hang onto the registrations as they need to be "live" when |
174 // calling BackgroundSyncManager::Register. | 176 // calling BackgroundSyncManager::Register. |
175 helper_->context_wrapper()->FindReadyRegistrationForId( | 177 helper_->context_wrapper()->FindReadyRegistrationForId( |
176 sw_registration_id_1_, GURL(kPattern1).GetOrigin(), | 178 sw_registration_id_1_, GURL(kPattern1).GetOrigin(), |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 // Run it again. | 1316 // Run it again. |
1315 test_clock_->Advance(test_background_sync_manager_->delayed_task_delta()); | 1317 test_clock_->Advance(test_background_sync_manager_->delayed_task_delta()); |
1316 test_background_sync_manager_->delayed_task().Run(); | 1318 test_background_sync_manager_->delayed_task().Run(); |
1317 base::RunLoop().RunUntilIdle(); | 1319 base::RunLoop().RunUntilIdle(); |
1318 EXPECT_FALSE(GetRegistration(sync_options_1_)); | 1320 EXPECT_FALSE(GetRegistration(sync_options_1_)); |
1319 EXPECT_EQ(blink::mojom::BackgroundSyncEventLastChance::IS_LAST_CHANCE, | 1321 EXPECT_EQ(blink::mojom::BackgroundSyncEventLastChance::IS_LAST_CHANCE, |
1320 test_background_sync_manager_->last_chance()); | 1322 test_background_sync_manager_->last_chance()); |
1321 } | 1323 } |
1322 | 1324 |
1323 } // namespace content | 1325 } // namespace content |
OLD | NEW |