| 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::AdaptCallbackForRepeating( | 163 base::AdaptCallbackForRepeating( |
| 163 base::BindOnce(&RegisterServiceWorkerCallback, &called_1, | 164 base::BindOnce(&RegisterServiceWorkerCallback, &called_1, |
| 164 &sw_registration_id_1_))); | 165 &sw_registration_id_1_))); |
| 165 | 166 |
| 166 helper_->context()->RegisterServiceWorker( | 167 helper_->context()->RegisterServiceWorker( |
| 167 GURL(kPattern2), GURL(kScript2), NULL, | 168 GURL(kScript2), ServiceWorkerRegistrationOptions(GURL(kPattern2)), |
| 169 nullptr, |
| 168 base::AdaptCallbackForRepeating( | 170 base::AdaptCallbackForRepeating( |
| 169 base::BindOnce(&RegisterServiceWorkerCallback, &called_2, | 171 base::BindOnce(&RegisterServiceWorkerCallback, &called_2, |
| 170 &sw_registration_id_2_))); | 172 &sw_registration_id_2_))); |
| 171 base::RunLoop().RunUntilIdle(); | 173 base::RunLoop().RunUntilIdle(); |
| 172 EXPECT_TRUE(called_1); | 174 EXPECT_TRUE(called_1); |
| 173 EXPECT_TRUE(called_2); | 175 EXPECT_TRUE(called_2); |
| 174 | 176 |
| 175 // Hang onto the registrations as they need to be "live" when | 177 // Hang onto the registrations as they need to be "live" when |
| 176 // calling BackgroundSyncManager::Register. | 178 // calling BackgroundSyncManager::Register. |
| 177 helper_->context_wrapper()->FindReadyRegistrationForId( | 179 helper_->context_wrapper()->FindReadyRegistrationForId( |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 // Run it again. | 1327 // Run it again. |
| 1326 test_clock_->Advance(test_background_sync_manager_->delayed_task_delta()); | 1328 test_clock_->Advance(test_background_sync_manager_->delayed_task_delta()); |
| 1327 test_background_sync_manager_->RunDelayedTask(); | 1329 test_background_sync_manager_->RunDelayedTask(); |
| 1328 base::RunLoop().RunUntilIdle(); | 1330 base::RunLoop().RunUntilIdle(); |
| 1329 EXPECT_FALSE(GetRegistration(sync_options_1_)); | 1331 EXPECT_FALSE(GetRegistration(sync_options_1_)); |
| 1330 EXPECT_EQ(blink::mojom::BackgroundSyncEventLastChance::IS_LAST_CHANCE, | 1332 EXPECT_EQ(blink::mojom::BackgroundSyncEventLastChance::IS_LAST_CHANCE, |
| 1331 test_background_sync_manager_->last_chance()); | 1333 test_background_sync_manager_->last_chance()); |
| 1332 } | 1334 } |
| 1333 | 1335 |
| 1334 } // namespace content | 1336 } // namespace content |
| OLD | NEW |