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 <tuple> | 5 #include <tuple> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/service_worker/embedded_worker_registry.h" | 10 #include "content/browser/service_worker/embedded_worker_registry.h" |
11 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 11 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
12 #include "content/browser/service_worker/service_worker_context_core.h" | 12 #include "content/browser/service_worker/service_worker_context_core.h" |
13 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 13 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
14 #include "content/browser/service_worker/service_worker_handle.h" | 14 #include "content/browser/service_worker/service_worker_handle.h" |
15 #include "content/browser/service_worker/service_worker_registration.h" | 15 #include "content/browser/service_worker/service_worker_registration.h" |
16 #include "content/browser/service_worker/service_worker_test_utils.h" | 16 #include "content/browser/service_worker/service_worker_test_utils.h" |
17 #include "content/browser/service_worker/service_worker_version.h" | 17 #include "content/browser/service_worker/service_worker_version.h" |
18 #include "content/common/service_worker/embedded_worker_messages.h" | 18 #include "content/common/service_worker/embedded_worker_messages.h" |
19 #include "content/common/service_worker/service_worker_messages.h" | 19 #include "content/common/service_worker/service_worker_messages.h" |
| 20 #include "content/common/service_worker/service_worker_types.h" |
20 #include "content/public/test/mock_resource_context.h" | 21 #include "content/public/test/mock_resource_context.h" |
21 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
22 #include "ipc/ipc_message.h" | 23 #include "ipc/ipc_message.h" |
23 #include "ipc/ipc_test_sink.h" | 24 #include "ipc/ipc_test_sink.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerState.h" | 26 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerState.h" |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 | 29 |
29 namespace { | 30 namespace { |
(...skipping 13 matching lines...) Expand all Loading... |
43 | 44 |
44 } // namespace | 45 } // namespace |
45 | 46 |
46 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { | 47 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { |
47 public: | 48 public: |
48 TestingServiceWorkerDispatcherHost( | 49 TestingServiceWorkerDispatcherHost( |
49 int process_id, | 50 int process_id, |
50 ServiceWorkerContextWrapper* context_wrapper, | 51 ServiceWorkerContextWrapper* context_wrapper, |
51 ResourceContext* resource_context, | 52 ResourceContext* resource_context, |
52 EmbeddedWorkerTestHelper* helper) | 53 EmbeddedWorkerTestHelper* helper) |
53 : ServiceWorkerDispatcherHost(process_id, nullptr, resource_context), | 54 : ServiceWorkerDispatcherHost(process_id, |
| 55 nullptr, |
| 56 resource_context, |
| 57 MojoURLLoaderFactoryGetter()), |
54 bad_message_received_count_(0), | 58 bad_message_received_count_(0), |
55 helper_(helper) { | 59 helper_(helper) { |
56 Init(context_wrapper); | 60 Init(context_wrapper); |
57 } | 61 } |
58 | 62 |
59 bool Send(IPC::Message* message) override { return helper_->Send(message); } | 63 bool Send(IPC::Message* message) override { return helper_->Send(message); } |
60 | 64 |
61 void ShutdownForBadMessage() override { ++bad_message_received_count_; } | 65 void ShutdownForBadMessage() override { ++bad_message_received_count_; } |
62 | 66 |
63 int bad_message_received_count_; | 67 int bad_message_received_count_; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // We should be sending 1. StartWorker, | 166 // We should be sending 1. StartWorker, |
163 EXPECT_EQ(EmbeddedWorkerMsg_StartWorker::ID, | 167 EXPECT_EQ(EmbeddedWorkerMsg_StartWorker::ID, |
164 ipc_sink()->GetMessageAt(0)->type()); | 168 ipc_sink()->GetMessageAt(0)->type()); |
165 // 2. StateChanged (state == Installed). | 169 // 2. StateChanged (state == Installed). |
166 VerifyStateChangedMessage(handle->handle_id(), | 170 VerifyStateChangedMessage(handle->handle_id(), |
167 blink::WebServiceWorkerStateInstalled, | 171 blink::WebServiceWorkerStateInstalled, |
168 ipc_sink()->GetMessageAt(1)); | 172 ipc_sink()->GetMessageAt(1)); |
169 } | 173 } |
170 | 174 |
171 } // namespace content | 175 } // namespace content |
OLD | NEW |