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/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "content/browser/browser_thread_impl.h" | 16 #include "content/browser/browser_thread_impl.h" |
17 #include "content/browser/message_port_service.h" | 17 #include "content/browser/message_port_service.h" |
18 #include "content/browser/service_worker/embedded_worker_instance.h" | 18 #include "content/browser/service_worker/embedded_worker_instance.h" |
19 #include "content/browser/service_worker/embedded_worker_registry.h" | 19 #include "content/browser/service_worker/embedded_worker_registry.h" |
20 #include "content/browser/service_worker/embedded_worker_status.h" | 20 #include "content/browser/service_worker/embedded_worker_status.h" |
21 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 21 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
22 #include "content/browser/service_worker/service_worker_context_core.h" | 22 #include "content/browser/service_worker/service_worker_context_core.h" |
23 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 23 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
24 #include "content/browser/service_worker/service_worker_handle.h" | 24 #include "content/browser/service_worker/service_worker_handle.h" |
25 #include "content/common/service_worker/embedded_worker_messages.h" | 25 #include "content/common/service_worker/embedded_worker_messages.h" |
26 #include "content/common/service_worker/service_worker_messages.h" | 26 #include "content/common/service_worker/service_worker_messages.h" |
| 27 #include "content/common/service_worker/service_worker_types.h" |
27 #include "content/common/service_worker/service_worker_utils.h" | 28 #include "content/common/service_worker/service_worker_utils.h" |
28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
29 #include "content/public/test/mock_resource_context.h" | 30 #include "content/public/test/mock_resource_context.h" |
30 #include "content/public/test/test_browser_thread_bundle.h" | 31 #include "content/public/test/test_browser_thread_bundle.h" |
31 #include "content/test/test_content_browser_client.h" | 32 #include "content/test/test_content_browser_client.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
33 | 34 |
34 namespace content { | 35 namespace content { |
35 | 36 |
36 namespace { | 37 namespace { |
(...skipping 16 matching lines...) Expand all Loading... |
53 | 54 |
54 static const int kRenderFrameId = 1; | 55 static const int kRenderFrameId = 1; |
55 | 56 |
56 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { | 57 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { |
57 public: | 58 public: |
58 TestingServiceWorkerDispatcherHost( | 59 TestingServiceWorkerDispatcherHost( |
59 int process_id, | 60 int process_id, |
60 ServiceWorkerContextWrapper* context_wrapper, | 61 ServiceWorkerContextWrapper* context_wrapper, |
61 ResourceContext* resource_context, | 62 ResourceContext* resource_context, |
62 EmbeddedWorkerTestHelper* helper) | 63 EmbeddedWorkerTestHelper* helper) |
63 : ServiceWorkerDispatcherHost(process_id, NULL, resource_context), | 64 : ServiceWorkerDispatcherHost(process_id, |
| 65 nullptr, |
| 66 resource_context, |
| 67 MojoURLLoaderFactoryGetter()), |
64 bad_messages_received_count_(0), | 68 bad_messages_received_count_(0), |
65 helper_(helper) { | 69 helper_(helper) { |
66 Init(context_wrapper); | 70 Init(context_wrapper); |
67 } | 71 } |
68 | 72 |
69 bool Send(IPC::Message* message) override { return helper_->Send(message); } | 73 bool Send(IPC::Message* message) override { return helper_->Send(message); } |
70 | 74 |
71 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } | 75 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } |
72 | 76 |
73 void ShutdownForBadMessage() override { ++bad_messages_received_count_; } | 77 void ShutdownForBadMessage() override { ++bad_messages_received_count_; } |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse( | 831 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse( |
828 version_->embedded_worker()->embedded_worker_id(), kFetchEventId, | 832 version_->embedded_worker()->embedded_worker_id(), kFetchEventId, |
829 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse(), | 833 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse(), |
830 base::Time::Now())); | 834 base::Time::Now())); |
831 | 835 |
832 base::RunLoop().RunUntilIdle(); | 836 base::RunLoop().RunUntilIdle(); |
833 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_); | 837 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_); |
834 } | 838 } |
835 | 839 |
836 } // namespace content | 840 } // namespace content |
OLD | NEW |