| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 void DispatchSyncEvent( | 249 void DispatchSyncEvent( |
| 250 const std::string& tag, | 250 const std::string& tag, |
| 251 blink::mojom::BackgroundSyncEventLastChance last_chance, | 251 blink::mojom::BackgroundSyncEventLastChance last_chance, |
| 252 DispatchSyncEventCallback callback) override { | 252 DispatchSyncEventCallback callback) override { |
| 253 NOTIMPLEMENTED(); | 253 NOTIMPLEMENTED(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void DispatchPaymentRequestEvent( | 256 void DispatchPaymentRequestEvent( |
| 257 int payment_request_id, | 257 int payment_request_id, |
| 258 payments::mojom::PaymentAppRequestPtr app_request, | 258 payments::mojom::PaymentRequestEventDataPtr event_data, |
| 259 payments::mojom::PaymentAppResponseCallbackPtr response_callback, | 259 payments::mojom::PaymentAppResponseCallbackPtr response_callback, |
| 260 DispatchPaymentRequestEventCallback callback) override { | 260 DispatchPaymentRequestEventCallback callback) override { |
| 261 if (!helper_) | 261 if (!helper_) |
| 262 return; | 262 return; |
| 263 helper_->OnPaymentRequestEventStub(std::move(app_request), | 263 helper_->OnPaymentRequestEventStub(std::move(event_data), |
| 264 std::move(response_callback), | 264 std::move(response_callback), |
| 265 std::move(callback)); | 265 std::move(callback)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void DispatchExtendableMessageEvent( | 268 void DispatchExtendableMessageEvent( |
| 269 mojom::ExtendableMessageEventPtr event, | 269 mojom::ExtendableMessageEventPtr event, |
| 270 DispatchExtendableMessageEventCallback callback) override { | 270 DispatchExtendableMessageEventCallback callback) override { |
| 271 if (!helper_) | 271 if (!helper_) |
| 272 return; | 272 return; |
| 273 helper_->OnExtendableMessageEventStub(std::move(event), | 273 helper_->OnExtendableMessageEventStub(std::move(event), |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 | 513 |
| 514 void EmbeddedWorkerTestHelper::OnNotificationCloseEvent( | 514 void EmbeddedWorkerTestHelper::OnNotificationCloseEvent( |
| 515 const std::string& notification_id, | 515 const std::string& notification_id, |
| 516 const PlatformNotificationData& notification_data, | 516 const PlatformNotificationData& notification_data, |
| 517 mojom::ServiceWorkerEventDispatcher::DispatchNotificationCloseEventCallback | 517 mojom::ServiceWorkerEventDispatcher::DispatchNotificationCloseEventCallback |
| 518 callback) { | 518 callback) { |
| 519 std::move(callback).Run(SERVICE_WORKER_OK, base::Time::Now()); | 519 std::move(callback).Run(SERVICE_WORKER_OK, base::Time::Now()); |
| 520 } | 520 } |
| 521 | 521 |
| 522 void EmbeddedWorkerTestHelper::OnPaymentRequestEvent( | 522 void EmbeddedWorkerTestHelper::OnPaymentRequestEvent( |
| 523 payments::mojom::PaymentAppRequestPtr app_request, | 523 payments::mojom::PaymentRequestEventDataPtr event_data, |
| 524 payments::mojom::PaymentAppResponseCallbackPtr response_callback, | 524 payments::mojom::PaymentAppResponseCallbackPtr response_callback, |
| 525 mojom::ServiceWorkerEventDispatcher::DispatchPaymentRequestEventCallback | 525 mojom::ServiceWorkerEventDispatcher::DispatchPaymentRequestEventCallback |
| 526 callback) { | 526 callback) { |
| 527 response_callback->OnPaymentAppResponse( | 527 response_callback->OnPaymentAppResponse( |
| 528 payments::mojom::PaymentAppResponse::New(), base::Time::Now()); | 528 payments::mojom::PaymentAppResponse::New(), base::Time::Now()); |
| 529 std::move(callback).Run(SERVICE_WORKER_OK, base::Time::Now()); | 529 std::move(callback).Run(SERVICE_WORKER_OK, base::Time::Now()); |
| 530 } | 530 } |
| 531 | 531 |
| 532 void EmbeddedWorkerTestHelper::SimulateWorkerReadyForInspection( | 532 void EmbeddedWorkerTestHelper::SimulateWorkerReadyForInspection( |
| 533 int embedded_worker_id) { | 533 int embedded_worker_id) { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 776 |
| 777 void EmbeddedWorkerTestHelper::OnPushEventStub( | 777 void EmbeddedWorkerTestHelper::OnPushEventStub( |
| 778 const PushEventPayload& payload, | 778 const PushEventPayload& payload, |
| 779 mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback callback) { | 779 mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback callback) { |
| 780 base::ThreadTaskRunnerHandle::Get()->PostTask( | 780 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 781 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnPushEvent, AsWeakPtr(), | 781 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnPushEvent, AsWeakPtr(), |
| 782 payload, base::Passed(&callback))); | 782 payload, base::Passed(&callback))); |
| 783 } | 783 } |
| 784 | 784 |
| 785 void EmbeddedWorkerTestHelper::OnPaymentRequestEventStub( | 785 void EmbeddedWorkerTestHelper::OnPaymentRequestEventStub( |
| 786 payments::mojom::PaymentAppRequestPtr app_request, | 786 payments::mojom::PaymentRequestEventDataPtr event_data, |
| 787 payments::mojom::PaymentAppResponseCallbackPtr response_callback, | 787 payments::mojom::PaymentAppResponseCallbackPtr response_callback, |
| 788 mojom::ServiceWorkerEventDispatcher::DispatchPaymentRequestEventCallback | 788 mojom::ServiceWorkerEventDispatcher::DispatchPaymentRequestEventCallback |
| 789 callback) { | 789 callback) { |
| 790 base::ThreadTaskRunnerHandle::Get()->PostTask( | 790 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 791 FROM_HERE, | 791 FROM_HERE, |
| 792 base::Bind(&EmbeddedWorkerTestHelper::OnPaymentRequestEvent, AsWeakPtr(), | 792 base::Bind(&EmbeddedWorkerTestHelper::OnPaymentRequestEvent, AsWeakPtr(), |
| 793 base::Passed(&app_request), base::Passed(&response_callback), | 793 base::Passed(&event_data), base::Passed(&response_callback), |
| 794 base::Passed(&callback))); | 794 base::Passed(&callback))); |
| 795 } | 795 } |
| 796 | 796 |
| 797 EmbeddedWorkerRegistry* EmbeddedWorkerTestHelper::registry() { | 797 EmbeddedWorkerRegistry* EmbeddedWorkerTestHelper::registry() { |
| 798 DCHECK(context()); | 798 DCHECK(context()); |
| 799 return context()->embedded_worker_registry(); | 799 return context()->embedded_worker_registry(); |
| 800 } | 800 } |
| 801 | 801 |
| 802 } // namespace content | 802 } // namespace content |
| OLD | NEW |