OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/service_worker/embedded_worker_test_helper.h" | 5 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 void DispatchFetchEvent(int fetch_event_id, | 152 void DispatchFetchEvent(int fetch_event_id, |
153 const ServiceWorkerFetchRequest& request, | 153 const ServiceWorkerFetchRequest& request, |
154 mojom::FetchEventPreloadHandlePtr preload_handle, | 154 mojom::FetchEventPreloadHandlePtr preload_handle, |
155 const DispatchFetchEventCallback& callback) override { | 155 const DispatchFetchEventCallback& callback) override { |
156 if (!helper_) | 156 if (!helper_) |
157 return; | 157 return; |
158 helper_->OnFetchEventStub(thread_id_, fetch_event_id, request, | 158 helper_->OnFetchEventStub(thread_id_, fetch_event_id, request, |
159 std::move(preload_handle), callback); | 159 std::move(preload_handle), callback); |
160 } | 160 } |
161 | 161 |
| 162 void DispatchNotificationClickEvent( |
| 163 const std::string& notification_id, |
| 164 const PlatformNotificationData& notification_data, |
| 165 int action_index, |
| 166 const base::Optional<base::string16>& reply, |
| 167 const DispatchNotificationClickEventCallback& callback) override { |
| 168 if (!helper_) |
| 169 return; |
| 170 helper_->OnNotificationClickEventStub(notification_id, notification_data, |
| 171 action_index, reply, callback); |
| 172 } |
| 173 |
| 174 void DispatchNotificationCloseEvent( |
| 175 const std::string& notification_id, |
| 176 const PlatformNotificationData& notification_data, |
| 177 const DispatchNotificationCloseEventCallback& callback) override { |
| 178 if (!helper_) |
| 179 return; |
| 180 helper_->OnNotificationCloseEventStub(notification_id, notification_data, |
| 181 callback); |
| 182 } |
| 183 |
162 void DispatchPushEvent(const PushEventPayload& payload, | 184 void DispatchPushEvent(const PushEventPayload& payload, |
163 const DispatchPushEventCallback& callback) override { | 185 const DispatchPushEventCallback& callback) override { |
164 if (!helper_) | 186 if (!helper_) |
165 return; | 187 return; |
166 helper_->OnPushEventStub(payload, callback); | 188 helper_->OnPushEventStub(payload, callback); |
167 } | 189 } |
168 | 190 |
169 void DispatchSyncEvent( | 191 void DispatchSyncEvent( |
170 const std::string& tag, | 192 const std::string& tag, |
171 blink::mojom::BackgroundSyncEventLastChance last_chance, | 193 blink::mojom::BackgroundSyncEventLastChance last_chance, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 callback.Run(SERVICE_WORKER_OK, base::Time::Now()); | 399 callback.Run(SERVICE_WORKER_OK, base::Time::Now()); |
378 } | 400 } |
379 | 401 |
380 void EmbeddedWorkerTestHelper::OnPushEvent( | 402 void EmbeddedWorkerTestHelper::OnPushEvent( |
381 const PushEventPayload& payload, | 403 const PushEventPayload& payload, |
382 const mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback& | 404 const mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback& |
383 callback) { | 405 callback) { |
384 callback.Run(SERVICE_WORKER_OK, base::Time::Now()); | 406 callback.Run(SERVICE_WORKER_OK, base::Time::Now()); |
385 } | 407 } |
386 | 408 |
| 409 void EmbeddedWorkerTestHelper::OnNotificationClickEvent( |
| 410 const std::string& notification_id, |
| 411 const PlatformNotificationData& notification_data, |
| 412 int action_index, |
| 413 const base::Optional<base::string16>& reply, |
| 414 const mojom::ServiceWorkerEventDispatcher:: |
| 415 DispatchNotificationClickEventCallback& callback) { |
| 416 callback.Run(SERVICE_WORKER_OK, base::Time::Now()); |
| 417 } |
| 418 |
| 419 void EmbeddedWorkerTestHelper::OnNotificationCloseEvent( |
| 420 const std::string& notification_id, |
| 421 const PlatformNotificationData& notification_data, |
| 422 const mojom::ServiceWorkerEventDispatcher:: |
| 423 DispatchNotificationCloseEventCallback& callback) { |
| 424 callback.Run(SERVICE_WORKER_OK, base::Time::Now()); |
| 425 } |
| 426 |
387 void EmbeddedWorkerTestHelper::OnPaymentRequestEvent( | 427 void EmbeddedWorkerTestHelper::OnPaymentRequestEvent( |
388 payments::mojom::PaymentAppRequestPtr app_request, | 428 payments::mojom::PaymentAppRequestPtr app_request, |
389 const mojom::ServiceWorkerEventDispatcher:: | 429 const mojom::ServiceWorkerEventDispatcher:: |
390 DispatchPaymentRequestEventCallback& callback) { | 430 DispatchPaymentRequestEventCallback& callback) { |
391 callback.Run(SERVICE_WORKER_OK, base::Time::Now()); | 431 callback.Run(SERVICE_WORKER_OK, base::Time::Now()); |
392 } | 432 } |
393 | 433 |
394 void EmbeddedWorkerTestHelper::SimulateWorkerReadyForInspection( | 434 void EmbeddedWorkerTestHelper::SimulateWorkerReadyForInspection( |
395 int embedded_worker_id) { | 435 int embedded_worker_id) { |
396 EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id); | 436 EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 const ServiceWorkerFetchRequest& request, | 573 const ServiceWorkerFetchRequest& request, |
534 mojom::FetchEventPreloadHandlePtr preload_handle, | 574 mojom::FetchEventPreloadHandlePtr preload_handle, |
535 const FetchCallback& callback) { | 575 const FetchCallback& callback) { |
536 base::ThreadTaskRunnerHandle::Get()->PostTask( | 576 base::ThreadTaskRunnerHandle::Get()->PostTask( |
537 FROM_HERE, | 577 FROM_HERE, |
538 base::Bind(&EmbeddedWorkerTestHelper::OnFetchEvent, AsWeakPtr(), | 578 base::Bind(&EmbeddedWorkerTestHelper::OnFetchEvent, AsWeakPtr(), |
539 thread_id_embedded_worker_id_map_[thread_id], fetch_event_id, | 579 thread_id_embedded_worker_id_map_[thread_id], fetch_event_id, |
540 request, base::Passed(&preload_handle), callback)); | 580 request, base::Passed(&preload_handle), callback)); |
541 } | 581 } |
542 | 582 |
| 583 void EmbeddedWorkerTestHelper::OnNotificationClickEventStub( |
| 584 const std::string& notification_id, |
| 585 const PlatformNotificationData& notification_data, |
| 586 int action_index, |
| 587 const base::Optional<base::string16>& reply, |
| 588 const mojom::ServiceWorkerEventDispatcher:: |
| 589 DispatchNotificationClickEventCallback& callback) { |
| 590 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 591 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnNotificationClickEvent, |
| 592 AsWeakPtr(), notification_id, notification_data, |
| 593 action_index, reply, callback)); |
| 594 } |
| 595 |
| 596 void EmbeddedWorkerTestHelper::OnNotificationCloseEventStub( |
| 597 const std::string& notification_id, |
| 598 const PlatformNotificationData& notification_data, |
| 599 const mojom::ServiceWorkerEventDispatcher:: |
| 600 DispatchNotificationCloseEventCallback& callback) { |
| 601 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 602 FROM_HERE, |
| 603 base::Bind(&EmbeddedWorkerTestHelper::OnNotificationCloseEvent, |
| 604 AsWeakPtr(), notification_id, notification_data, callback)); |
| 605 } |
| 606 |
543 void EmbeddedWorkerTestHelper::OnPushEventStub( | 607 void EmbeddedWorkerTestHelper::OnPushEventStub( |
544 const PushEventPayload& payload, | 608 const PushEventPayload& payload, |
545 const mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback& | 609 const mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback& |
546 callback) { | 610 callback) { |
547 base::ThreadTaskRunnerHandle::Get()->PostTask( | 611 base::ThreadTaskRunnerHandle::Get()->PostTask( |
548 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnPushEvent, AsWeakPtr(), | 612 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnPushEvent, AsWeakPtr(), |
549 payload, callback)); | 613 payload, callback)); |
550 } | 614 } |
551 | 615 |
552 void EmbeddedWorkerTestHelper::OnPaymentRequestEventStub( | 616 void EmbeddedWorkerTestHelper::OnPaymentRequestEventStub( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 service_manager::InterfaceProviderSpec()); | 650 service_manager::InterfaceProviderSpec()); |
587 | 651 |
588 std::unique_ptr<service_manager::InterfaceProvider> remote_interfaces( | 652 std::unique_ptr<service_manager::InterfaceProvider> remote_interfaces( |
589 new service_manager::InterfaceProvider); | 653 new service_manager::InterfaceProvider); |
590 remote_interfaces->Bind(std::move(interfaces)); | 654 remote_interfaces->Bind(std::move(interfaces)); |
591 rph->SetRemoteInterfaces(std::move(remote_interfaces)); | 655 rph->SetRemoteInterfaces(std::move(remote_interfaces)); |
592 return registry; | 656 return registry; |
593 } | 657 } |
594 | 658 |
595 } // namespace content | 659 } // namespace content |
OLD | NEW |