| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/power_monitor/power_monitor.h" | 13 #include "base/power_monitor/power_monitor.h" |
| 13 #include "base/power_monitor/power_monitor_source.h" | 14 #include "base/power_monitor/power_monitor_source.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "content/browser/background_sync/background_sync_context_impl.h" | 16 #include "content/browser/background_sync/background_sync_context_impl.h" |
| 16 #include "content/browser/background_sync/background_sync_network_observer.h" | 17 #include "content/browser/background_sync/background_sync_network_observer.h" |
| 17 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 18 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 base::RunLoop().RunUntilIdle(); | 173 base::RunLoop().RunUntilIdle(); |
| 173 EXPECT_TRUE(sw_registration_); | 174 EXPECT_TRUE(sw_registration_); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void CreateBackgroundSyncServiceImpl() { | 177 void CreateBackgroundSyncServiceImpl() { |
| 177 // Create a dummy mojo channel so that the BackgroundSyncServiceImpl can be | 178 // Create a dummy mojo channel so that the BackgroundSyncServiceImpl can be |
| 178 // instantiated | 179 // instantiated |
| 179 mojo::InterfaceRequest<BackgroundSyncService> service_request = | 180 mojo::InterfaceRequest<BackgroundSyncService> service_request = |
| 180 mojo::GetProxy(&service_ptr_); | 181 mojo::GetProxy(&service_ptr_); |
| 181 // Create a new BackgroundSyncServiceImpl bound to the dummy channel | 182 // Create a new BackgroundSyncServiceImpl bound to the dummy channel |
| 182 background_sync_context_->CreateService(service_request.Pass()); | 183 background_sync_context_->CreateService(std::move(service_request)); |
| 183 base::RunLoop().RunUntilIdle(); | 184 base::RunLoop().RunUntilIdle(); |
| 184 | 185 |
| 185 service_impl_ = *background_sync_context_->services_.begin(); | 186 service_impl_ = *background_sync_context_->services_.begin(); |
| 186 ASSERT_TRUE(service_impl_); | 187 ASSERT_TRUE(service_impl_); |
| 187 } | 188 } |
| 188 | 189 |
| 189 // Helpers for testing BackgroundSyncServiceImpl methods | 190 // Helpers for testing BackgroundSyncServiceImpl methods |
| 190 void RegisterOneShot( | 191 void RegisterOneShot( |
| 191 SyncRegistrationPtr sync, | 192 SyncRegistrationPtr sync, |
| 192 const BackgroundSyncService::RegisterCallback& callback) { | 193 const BackgroundSyncService::RegisterCallback& callback) { |
| 193 service_impl_->Register(sync.Pass(), sw_registration_id_, | 194 service_impl_->Register(std::move(sync), sw_registration_id_, |
| 194 false /* requested_from_service_worker */, | 195 false /* requested_from_service_worker */, |
| 195 callback); | 196 callback); |
| 196 base::RunLoop().RunUntilIdle(); | 197 base::RunLoop().RunUntilIdle(); |
| 197 } | 198 } |
| 198 | 199 |
| 199 void UnregisterOneShot( | 200 void UnregisterOneShot( |
| 200 int32_t handle_id, | 201 int32_t handle_id, |
| 201 const BackgroundSyncService::UnregisterCallback& callback) { | 202 const BackgroundSyncService::UnregisterCallback& callback) { |
| 202 service_impl_->Unregister( | 203 service_impl_->Unregister( |
| 203 handle_id, sw_registration_id_, callback); | 204 handle_id, sw_registration_id_, callback); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 376 |
| 376 NotifyWhenDone(reg->handle_id, | 377 NotifyWhenDone(reg->handle_id, |
| 377 base::Bind(&ErrorAndStateCallback, ¬ify_done_called, | 378 base::Bind(&ErrorAndStateCallback, ¬ify_done_called, |
| 378 ¬ify_done_error, ¬ify_done_sync_state)); | 379 ¬ify_done_error, ¬ify_done_sync_state)); |
| 379 EXPECT_TRUE(notify_done_called); | 380 EXPECT_TRUE(notify_done_called); |
| 380 EXPECT_EQ(BACKGROUND_SYNC_ERROR_NONE, notify_done_error); | 381 EXPECT_EQ(BACKGROUND_SYNC_ERROR_NONE, notify_done_error); |
| 381 EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, notify_done_sync_state); | 382 EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, notify_done_sync_state); |
| 382 } | 383 } |
| 383 | 384 |
| 384 } // namespace content | 385 } // namespace content |
| OLD | NEW |