| 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/optional.h" | 18 #include "base/optional.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "content/common/service_worker/embedded_worker.mojom.h" | 20 #include "content/common/service_worker/embedded_worker.mojom.h" |
| 21 #include "content/common/service_worker/fetch_event_dispatcher.mojom.h" |
| 21 #include "content/common/service_worker/service_worker_status_code.h" | 22 #include "content/common/service_worker/service_worker_status_code.h" |
| 22 #include "ipc/ipc_listener.h" | 23 #include "ipc/ipc_listener.h" |
| 23 #include "ipc/ipc_test_sink.h" | 24 #include "ipc/ipc_test_sink.h" |
| 24 #include "mojo/public/cpp/bindings/binding.h" | 25 #include "mojo/public/cpp/bindings/binding.h" |
| 25 #include "services/shell/public/interfaces/interface_provider.mojom.h" | 26 #include "services/shell/public/interfaces/interface_provider.mojom.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 28 | 29 |
| 29 class GURL; | 30 class GURL; |
| 30 struct ServiceWorkerMsg_ExtendableMessageEvent_Params; | 31 struct ServiceWorkerMsg_ExtendableMessageEvent_Params; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // On*Event handlers. Called by the default implementation of | 174 // On*Event handlers. Called by the default implementation of |
| 174 // OnMessageToWorker when events are sent to the embedded | 175 // OnMessageToWorker when events are sent to the embedded |
| 175 // worker. By default they just return success via | 176 // worker. By default they just return success via |
| 176 // SimulateSendReplyToBrowser. | 177 // SimulateSendReplyToBrowser. |
| 177 virtual void OnActivateEvent(int embedded_worker_id, int request_id); | 178 virtual void OnActivateEvent(int embedded_worker_id, int request_id); |
| 178 virtual void OnExtendableMessageEvent(int embedded_worker_id, int request_id); | 179 virtual void OnExtendableMessageEvent(int embedded_worker_id, int request_id); |
| 179 virtual void OnInstallEvent(int embedded_worker_id, int request_id); | 180 virtual void OnInstallEvent(int embedded_worker_id, int request_id); |
| 180 virtual void OnFetchEvent(int embedded_worker_id, | 181 virtual void OnFetchEvent(int embedded_worker_id, |
| 181 int fetch_event_id, | 182 int fetch_event_id, |
| 182 const ServiceWorkerFetchRequest& request, | 183 const ServiceWorkerFetchRequest& request, |
| 184 mojom::FetchEventPreloadHandlePtr preload_handle, |
| 183 const FetchCallback& callback); | 185 const FetchCallback& callback); |
| 184 virtual void OnPushEvent(int embedded_worker_id, | 186 virtual void OnPushEvent(int embedded_worker_id, |
| 185 int request_id, | 187 int request_id, |
| 186 const PushEventPayload& payload); | 188 const PushEventPayload& payload); |
| 187 | 189 |
| 188 // These functions simulate sending an EmbeddedHostMsg message to the | 190 // These functions simulate sending an EmbeddedHostMsg message to the |
| 189 // browser. | 191 // browser. |
| 190 void SimulateWorkerReadyForInspection(int embedded_worker_id); | 192 void SimulateWorkerReadyForInspection(int embedded_worker_id); |
| 191 void SimulateWorkerScriptCached(int embedded_worker_id); | 193 void SimulateWorkerScriptCached(int embedded_worker_id); |
| 192 void SimulateWorkerScriptLoaded(int embedded_worker_id); | 194 void SimulateWorkerScriptLoaded(int embedded_worker_id); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 213 int embedded_worker_id, | 215 int embedded_worker_id, |
| 214 const IPC::Message& message); | 216 const IPC::Message& message); |
| 215 void OnActivateEventStub(int request_id); | 217 void OnActivateEventStub(int request_id); |
| 216 void OnExtendableMessageEventStub( | 218 void OnExtendableMessageEventStub( |
| 217 int request_id, | 219 int request_id, |
| 218 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params); | 220 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params); |
| 219 void OnInstallEventStub(int request_id); | 221 void OnInstallEventStub(int request_id); |
| 220 void OnFetchEventStub(int thread_id, | 222 void OnFetchEventStub(int thread_id, |
| 221 int fetch_event_id, | 223 int fetch_event_id, |
| 222 const ServiceWorkerFetchRequest& request, | 224 const ServiceWorkerFetchRequest& request, |
| 225 mojom::FetchEventPreloadHandlePtr preload_handle, |
| 223 const FetchCallback& callback); | 226 const FetchCallback& callback); |
| 224 void OnPushEventStub(int request_id, const PushEventPayload& payload); | 227 void OnPushEventStub(int request_id, const PushEventPayload& payload); |
| 225 void OnSetupMojoStub(int thread_id, | 228 void OnSetupMojoStub(int thread_id, |
| 226 shell::mojom::InterfaceProviderRequest services, | 229 shell::mojom::InterfaceProviderRequest services, |
| 227 shell::mojom::InterfaceProviderPtr exposed_services); | 230 shell::mojom::InterfaceProviderPtr exposed_services); |
| 228 | 231 |
| 229 MessagePortMessageFilter* NewMessagePortMessageFilter(); | 232 MessagePortMessageFilter* NewMessagePortMessageFilter(); |
| 230 | 233 |
| 231 std::unique_ptr<shell::InterfaceRegistry> CreateInterfaceRegistry( | 234 std::unique_ptr<shell::InterfaceRegistry> CreateInterfaceRegistry( |
| 232 MockRenderProcessHost* rph); | 235 MockRenderProcessHost* rph); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 message_port_message_filters_; | 271 message_port_message_filters_; |
| 269 | 272 |
| 270 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 273 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
| 271 | 274 |
| 272 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 275 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
| 273 }; | 276 }; |
| 274 | 277 |
| 275 } // namespace content | 278 } // namespace content |
| 276 | 279 |
| 277 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 280 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| OLD | NEW |