| 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_service_impl.h" | 5 #include "content/browser/background_sync/background_sync_service_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/power_monitor/power_monitor.h" | 10 #include "base/power_monitor/power_monitor.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // Tests do not expect the sync event to fire immediately after | 146 // Tests do not expect the sync event to fire immediately after |
| 147 // register (and cleanup up the sync registrations). Prevent the sync | 147 // register (and cleanup up the sync registrations). Prevent the sync |
| 148 // event from firing by setting the network state to have no connection. | 148 // event from firing by setting the network state to have no connection. |
| 149 // NOTE: The setup of the network connection must happen after the | 149 // NOTE: The setup of the network connection must happen after the |
| 150 // BackgroundSyncManager has been setup, including any asynchronous | 150 // BackgroundSyncManager has been setup, including any asynchronous |
| 151 // initialization. | 151 // initialization. |
| 152 base::RunLoop().RunUntilIdle(); | 152 base::RunLoop().RunUntilIdle(); |
| 153 BackgroundSyncNetworkObserver* network_observer = | 153 BackgroundSyncNetworkObserver* network_observer = |
| 154 background_sync_context_->background_sync_manager() | 154 background_sync_context_->background_sync_manager() |
| 155 ->GetNetworkObserverForTesting(); | 155 ->GetNetworkObserverForTesting(); |
| 156 network_observer->NotifyManagerIfNetworkChanged( | 156 network_observer->NotifyManagerIfNetworkChangedForTesting( |
| 157 net::NetworkChangeNotifier::CONNECTION_NONE); | 157 net::NetworkChangeNotifier::CONNECTION_NONE); |
| 158 base::RunLoop().RunUntilIdle(); | 158 base::RunLoop().RunUntilIdle(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void CreateServiceWorkerRegistration() { | 161 void CreateServiceWorkerRegistration() { |
| 162 bool called = false; | 162 bool called = false; |
| 163 embedded_worker_helper_->context()->RegisterServiceWorker( | 163 embedded_worker_helper_->context()->RegisterServiceWorker( |
| 164 GURL(kServiceWorkerPattern), GURL(kServiceWorkerScript), NULL, | 164 GURL(kServiceWorkerPattern), GURL(kServiceWorkerScript), NULL, |
| 165 base::Bind(&RegisterServiceWorkerCallback, &called, | 165 base::Bind(&RegisterServiceWorkerCallback, &called, |
| 166 &sw_registration_id_)); | 166 &sw_registration_id_)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 446 |
| 447 NotifyWhenDone(reg->handle_id, | 447 NotifyWhenDone(reg->handle_id, |
| 448 base::Bind(&ErrorAndStateCallback, ¬ify_done_called, | 448 base::Bind(&ErrorAndStateCallback, ¬ify_done_called, |
| 449 ¬ify_done_error, ¬ify_done_sync_state)); | 449 ¬ify_done_error, ¬ify_done_sync_state)); |
| 450 EXPECT_TRUE(notify_done_called); | 450 EXPECT_TRUE(notify_done_called); |
| 451 EXPECT_EQ(BACKGROUND_SYNC_ERROR_NONE, notify_done_error); | 451 EXPECT_EQ(BACKGROUND_SYNC_ERROR_NONE, notify_done_error); |
| 452 EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, notify_done_sync_state); | 452 EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, notify_done_sync_state); |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace content | 455 } // namespace content |
| OLD | NEW |