| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "content/child/service_worker/service_worker_dispatcher.h" | 6 #include "content/child/service_worker/service_worker_dispatcher.h" |
| 7 #include "content/child/service_worker/service_worker_handle_reference.h" | 7 #include "content/child/service_worker/service_worker_handle_reference.h" |
| 8 #include "content/child/service_worker/service_worker_provider_context.h" | 8 #include "content/child/service_worker/service_worker_provider_context.h" |
| 9 #include "content/child/service_worker/web_service_worker_impl.h" | 9 #include "content/child/service_worker/web_service_worker_impl.h" |
| 10 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 10 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 ServiceWorkerRegistrationObjectInfo info; | 428 ServiceWorkerRegistrationObjectInfo info; |
| 429 ServiceWorkerVersionAttributes attrs; | 429 ServiceWorkerVersionAttributes attrs; |
| 430 CreateObjectInfoAndVersionAttributes(&info, &attrs); | 430 CreateObjectInfoAndVersionAttributes(&info, &attrs); |
| 431 | 431 |
| 432 // Should return a registration object newly created with incrementing | 432 // Should return a registration object newly created with incrementing |
| 433 // the refcounts. | 433 // the refcounts. |
| 434 scoped_refptr<WebServiceWorkerRegistrationImpl> registration1( | 434 scoped_refptr<WebServiceWorkerRegistrationImpl> registration1( |
| 435 dispatcher()->GetOrCreateRegistration(info, attrs)); | 435 dispatcher()->GetOrCreateRegistration(info, attrs)); |
| 436 EXPECT_TRUE(registration1); | 436 EXPECT_TRUE(registration1); |
| 437 EXPECT_TRUE(ContainsRegistration(info.handle_id)); | 437 EXPECT_TRUE(ContainsRegistration(info.handle_id)); |
| 438 EXPECT_EQ(info.registration_id, registration1->registration_id()); | 438 EXPECT_EQ(info.registration_id, registration1->registrationId()); |
| 439 ASSERT_EQ(4UL, ipc_sink()->message_count()); | 439 ASSERT_EQ(4UL, ipc_sink()->message_count()); |
| 440 EXPECT_EQ(ServiceWorkerHostMsg_IncrementRegistrationRefCount::ID, | 440 EXPECT_EQ(ServiceWorkerHostMsg_IncrementRegistrationRefCount::ID, |
| 441 ipc_sink()->GetMessageAt(0)->type()); | 441 ipc_sink()->GetMessageAt(0)->type()); |
| 442 EXPECT_EQ(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount::ID, | 442 EXPECT_EQ(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount::ID, |
| 443 ipc_sink()->GetMessageAt(1)->type()); | 443 ipc_sink()->GetMessageAt(1)->type()); |
| 444 EXPECT_EQ(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount::ID, | 444 EXPECT_EQ(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount::ID, |
| 445 ipc_sink()->GetMessageAt(2)->type()); | 445 ipc_sink()->GetMessageAt(2)->type()); |
| 446 EXPECT_EQ(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount::ID, | 446 EXPECT_EQ(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount::ID, |
| 447 ipc_sink()->GetMessageAt(3)->type()); | 447 ipc_sink()->GetMessageAt(3)->type()); |
| 448 | 448 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 476 ServiceWorkerRegistrationObjectInfo info; | 476 ServiceWorkerRegistrationObjectInfo info; |
| 477 ServiceWorkerVersionAttributes attrs; | 477 ServiceWorkerVersionAttributes attrs; |
| 478 CreateObjectInfoAndVersionAttributes(&info, &attrs); | 478 CreateObjectInfoAndVersionAttributes(&info, &attrs); |
| 479 | 479 |
| 480 // Should return a registration object newly created with adopting the | 480 // Should return a registration object newly created with adopting the |
| 481 // refcounts. | 481 // refcounts. |
| 482 scoped_refptr<WebServiceWorkerRegistrationImpl> registration1( | 482 scoped_refptr<WebServiceWorkerRegistrationImpl> registration1( |
| 483 dispatcher()->GetOrAdoptRegistration(info, attrs)); | 483 dispatcher()->GetOrAdoptRegistration(info, attrs)); |
| 484 EXPECT_TRUE(registration1); | 484 EXPECT_TRUE(registration1); |
| 485 EXPECT_TRUE(ContainsRegistration(info.handle_id)); | 485 EXPECT_TRUE(ContainsRegistration(info.handle_id)); |
| 486 EXPECT_EQ(info.registration_id, registration1->registration_id()); | 486 EXPECT_EQ(info.registration_id, registration1->registrationId()); |
| 487 EXPECT_EQ(0UL, ipc_sink()->message_count()); | 487 EXPECT_EQ(0UL, ipc_sink()->message_count()); |
| 488 | 488 |
| 489 ipc_sink()->ClearMessages(); | 489 ipc_sink()->ClearMessages(); |
| 490 | 490 |
| 491 // Should return the same registration object without incrementing the | 491 // Should return the same registration object without incrementing the |
| 492 // refcounts. | 492 // refcounts. |
| 493 scoped_refptr<WebServiceWorkerRegistrationImpl> registration2( | 493 scoped_refptr<WebServiceWorkerRegistrationImpl> registration2( |
| 494 dispatcher()->GetOrAdoptRegistration(info, attrs)); | 494 dispatcher()->GetOrAdoptRegistration(info, attrs)); |
| 495 EXPECT_TRUE(registration2); | 495 EXPECT_TRUE(registration2); |
| 496 EXPECT_EQ(registration1, registration2); | 496 EXPECT_EQ(registration1, registration2); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 514 ipc_sink()->GetMessageAt(0)->type()); | 514 ipc_sink()->GetMessageAt(0)->type()); |
| 515 EXPECT_EQ(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount::ID, | 515 EXPECT_EQ(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount::ID, |
| 516 ipc_sink()->GetMessageAt(1)->type()); | 516 ipc_sink()->GetMessageAt(1)->type()); |
| 517 EXPECT_EQ(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount::ID, | 517 EXPECT_EQ(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount::ID, |
| 518 ipc_sink()->GetMessageAt(2)->type()); | 518 ipc_sink()->GetMessageAt(2)->type()); |
| 519 EXPECT_EQ(ServiceWorkerHostMsg_DecrementRegistrationRefCount::ID, | 519 EXPECT_EQ(ServiceWorkerHostMsg_DecrementRegistrationRefCount::ID, |
| 520 ipc_sink()->GetMessageAt(3)->type()); | 520 ipc_sink()->GetMessageAt(3)->type()); |
| 521 } | 521 } |
| 522 | 522 |
| 523 } // namespace content | 523 } // namespace content |
| OLD | NEW |