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 <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 MockFetchEventDispatcher( | 160 MockFetchEventDispatcher( |
161 const base::WeakPtr<EmbeddedWorkerTestHelper>& helper, | 161 const base::WeakPtr<EmbeddedWorkerTestHelper>& helper, |
162 int thread_id) | 162 int thread_id) |
163 : helper_(helper), thread_id_(thread_id) {} | 163 : helper_(helper), thread_id_(thread_id) {} |
164 | 164 |
165 ~MockFetchEventDispatcher() override {} | 165 ~MockFetchEventDispatcher() override {} |
166 | 166 |
167 void DispatchFetchEvent(int fetch_event_id, | 167 void DispatchFetchEvent(int fetch_event_id, |
168 const ServiceWorkerFetchRequest& request, | 168 const ServiceWorkerFetchRequest& request, |
| 169 mojom::FetchEventPreloadHandlePtr preload_handle, |
169 const DispatchFetchEventCallback& callback) override { | 170 const DispatchFetchEventCallback& callback) override { |
170 if (!helper_) | 171 if (!helper_) |
171 return; | 172 return; |
172 helper_->OnFetchEventStub(thread_id_, fetch_event_id, request, callback); | 173 helper_->OnFetchEventStub(thread_id_, fetch_event_id, request, |
| 174 std::move(preload_handle), callback); |
173 } | 175 } |
174 | 176 |
175 private: | 177 private: |
176 base::WeakPtr<EmbeddedWorkerTestHelper> helper_; | 178 base::WeakPtr<EmbeddedWorkerTestHelper> helper_; |
177 const int thread_id_; | 179 const int thread_id_; |
178 }; | 180 }; |
179 | 181 |
180 EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper( | 182 EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper( |
181 const base::FilePath& user_data_directory) | 183 const base::FilePath& user_data_directory) |
182 : browser_context_(new TestBrowserContext), | 184 : browser_context_(new TestBrowserContext), |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 return; | 332 return; |
331 SimulateSend(new ServiceWorkerHostMsg_InstallEventFinished( | 333 SimulateSend(new ServiceWorkerHostMsg_InstallEventFinished( |
332 embedded_worker_id, request_id, | 334 embedded_worker_id, request_id, |
333 blink::WebServiceWorkerEventResultCompleted, true, base::Time::Now())); | 335 blink::WebServiceWorkerEventResultCompleted, true, base::Time::Now())); |
334 } | 336 } |
335 | 337 |
336 void EmbeddedWorkerTestHelper::OnFetchEvent( | 338 void EmbeddedWorkerTestHelper::OnFetchEvent( |
337 int embedded_worker_id, | 339 int embedded_worker_id, |
338 int fetch_event_id, | 340 int fetch_event_id, |
339 const ServiceWorkerFetchRequest& request, | 341 const ServiceWorkerFetchRequest& request, |
| 342 mojom::FetchEventPreloadHandlePtr preload_handle, |
340 const FetchCallback& callback) { | 343 const FetchCallback& callback) { |
341 SimulateSend(new ServiceWorkerHostMsg_FetchEventResponse( | 344 SimulateSend(new ServiceWorkerHostMsg_FetchEventResponse( |
342 embedded_worker_id, fetch_event_id, | 345 embedded_worker_id, fetch_event_id, |
343 SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, | 346 SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, |
344 ServiceWorkerResponse( | 347 ServiceWorkerResponse( |
345 GURL(), 200, "OK", blink::WebServiceWorkerResponseTypeDefault, | 348 GURL(), 200, "OK", blink::WebServiceWorkerResponseTypeDefault, |
346 ServiceWorkerHeaderMap(), std::string(), 0, GURL(), | 349 ServiceWorkerHeaderMap(), std::string(), 0, GURL(), |
347 blink::WebServiceWorkerResponseErrorUnknown, base::Time(), | 350 blink::WebServiceWorkerResponseErrorUnknown, base::Time(), |
348 false /* is_in_cache_storage */, | 351 false /* is_in_cache_storage */, |
349 std::string() /* cache_storage_cache_name */, | 352 std::string() /* cache_storage_cache_name */, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 base::ThreadTaskRunnerHandle::Get()->PostTask( | 494 base::ThreadTaskRunnerHandle::Get()->PostTask( |
492 FROM_HERE, | 495 FROM_HERE, |
493 base::Bind(&EmbeddedWorkerTestHelper::OnInstallEvent, AsWeakPtr(), | 496 base::Bind(&EmbeddedWorkerTestHelper::OnInstallEvent, AsWeakPtr(), |
494 current_embedded_worker_id_, request_id)); | 497 current_embedded_worker_id_, request_id)); |
495 } | 498 } |
496 | 499 |
497 void EmbeddedWorkerTestHelper::OnFetchEventStub( | 500 void EmbeddedWorkerTestHelper::OnFetchEventStub( |
498 int thread_id, | 501 int thread_id, |
499 int fetch_event_id, | 502 int fetch_event_id, |
500 const ServiceWorkerFetchRequest& request, | 503 const ServiceWorkerFetchRequest& request, |
| 504 mojom::FetchEventPreloadHandlePtr preload_handle, |
501 const FetchCallback& callback) { | 505 const FetchCallback& callback) { |
502 base::ThreadTaskRunnerHandle::Get()->PostTask( | 506 base::ThreadTaskRunnerHandle::Get()->PostTask( |
503 FROM_HERE, | 507 FROM_HERE, |
504 base::Bind(&EmbeddedWorkerTestHelper::OnFetchEvent, AsWeakPtr(), | 508 base::Bind(&EmbeddedWorkerTestHelper::OnFetchEvent, AsWeakPtr(), |
505 thread_id_embedded_worker_id_map_[thread_id], fetch_event_id, | 509 thread_id_embedded_worker_id_map_[thread_id], fetch_event_id, |
506 request, callback)); | 510 request, base::Passed(&preload_handle), callback)); |
507 } | 511 } |
508 | 512 |
509 void EmbeddedWorkerTestHelper::OnPushEventStub( | 513 void EmbeddedWorkerTestHelper::OnPushEventStub( |
510 int request_id, | 514 int request_id, |
511 const PushEventPayload& payload) { | 515 const PushEventPayload& payload) { |
512 base::ThreadTaskRunnerHandle::Get()->PostTask( | 516 base::ThreadTaskRunnerHandle::Get()->PostTask( |
513 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnPushEvent, AsWeakPtr(), | 517 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnPushEvent, AsWeakPtr(), |
514 current_embedded_worker_id_, request_id, payload)); | 518 current_embedded_worker_id_, request_id, payload)); |
515 } | 519 } |
516 | 520 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 registry->Bind(mojo::GetProxy(&interfaces)); | 561 registry->Bind(mojo::GetProxy(&interfaces)); |
558 | 562 |
559 std::unique_ptr<shell::InterfaceProvider> remote_interfaces( | 563 std::unique_ptr<shell::InterfaceProvider> remote_interfaces( |
560 new shell::InterfaceProvider); | 564 new shell::InterfaceProvider); |
561 remote_interfaces->Bind(std::move(interfaces)); | 565 remote_interfaces->Bind(std::move(interfaces)); |
562 rph->SetRemoteInterfaces(std::move(remote_interfaces)); | 566 rph->SetRemoteInterfaces(std::move(remote_interfaces)); |
563 return registry; | 567 return registry; |
564 } | 568 } |
565 | 569 |
566 } // namespace content | 570 } // namespace content |
OLD | NEW |