OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_instance.h" | 5 #include "content/browser/service_worker/embedded_worker_instance.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 worker->AddListener(this); | 685 worker->AddListener(this); |
686 | 686 |
687 // Attempt to start the worker. | 687 // Attempt to start the worker. |
688 std::unique_ptr<EmbeddedWorkerStartParams> params = | 688 std::unique_ptr<EmbeddedWorkerStartParams> params = |
689 CreateStartParams(version_id, pattern, url); | 689 CreateStartParams(version_id, pattern, url); |
690 worker->Start(std::move(params), CreateEventDispatcher(), | 690 worker->Start(std::move(params), CreateEventDispatcher(), |
691 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 691 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
692 base::RunLoop().RunUntilIdle(); | 692 base::RunLoop().RunUntilIdle(); |
693 | 693 |
694 // Worker should handle the failure of binding as detach. | 694 // Worker should handle the failure of binding as detach. |
695 ASSERT_EQ(3u, events_.size()); | 695 ASSERT_EQ(2u, events_.size()); |
696 EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type); | 696 EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type); |
697 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); | 697 EXPECT_EQ(DETACHED, events_[1].type); |
698 EXPECT_EQ(DETACHED, events_[2].type); | 698 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[1].status); |
699 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); | |
700 } | 699 } |
701 | 700 |
702 class FailEmbeddedWorkerInstanceClientImpl | 701 class FailEmbeddedWorkerInstanceClientImpl |
703 : public EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient { | 702 : public EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient { |
704 public: | 703 public: |
705 explicit FailEmbeddedWorkerInstanceClientImpl( | 704 explicit FailEmbeddedWorkerInstanceClientImpl( |
706 base::WeakPtr<EmbeddedWorkerTestHelper> helper) | 705 base::WeakPtr<EmbeddedWorkerTestHelper> helper) |
707 : EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient(helper) {} | 706 : EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient(helper) {} |
708 | 707 |
709 private: | 708 private: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 ASSERT_EQ(1UL, instance_client_rawptr->message().size()); | 810 ASSERT_EQ(1UL, instance_client_rawptr->message().size()); |
812 EXPECT_EQ(test_message, instance_client_rawptr->message()[0]); | 811 EXPECT_EQ(test_message, instance_client_rawptr->message()[0]); |
813 | 812 |
814 // Ensure the worker is stopped. | 813 // Ensure the worker is stopped. |
815 worker->Stop(); | 814 worker->Stop(); |
816 base::RunLoop().RunUntilIdle(); | 815 base::RunLoop().RunUntilIdle(); |
817 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, worker->status()); | 816 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, worker->status()); |
818 } | 817 } |
819 | 818 |
820 } // namespace content | 819 } // namespace content |
OLD | NEW |