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> |
(...skipping 12 matching lines...) Expand all Loading... | |
23 | 23 |
24 struct EmbeddedWorkerMsg_StartWorker_Params; | 24 struct EmbeddedWorkerMsg_StartWorker_Params; |
25 class GURL; | 25 class GURL; |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 class EmbeddedWorkerRegistry; | 29 class EmbeddedWorkerRegistry; |
30 class EmbeddedWorkerTestHelper; | 30 class EmbeddedWorkerTestHelper; |
31 class MessagePortMessageFilter; | 31 class MessagePortMessageFilter; |
32 class MockRenderProcessHost; | 32 class MockRenderProcessHost; |
33 struct PushEventPayload; | |
33 class ServiceWorkerContextCore; | 34 class ServiceWorkerContextCore; |
34 class ServiceWorkerContextWrapper; | 35 class ServiceWorkerContextWrapper; |
35 struct ServiceWorkerFetchRequest; | 36 struct ServiceWorkerFetchRequest; |
36 class TestBrowserContext; | 37 class TestBrowserContext; |
37 | 38 |
38 // In-Process EmbeddedWorker test helper. | 39 // In-Process EmbeddedWorker test helper. |
39 // | 40 // |
40 // Usage: create an instance of this class to test browser-side embedded worker | 41 // Usage: create an instance of this class to test browser-side embedded worker |
41 // code without creating a child process. This class will create a | 42 // code without creating a child process. This class will create a |
42 // ServiceWorkerContextWrapper and ServiceWorkerContextCore for you. | 43 // ServiceWorkerContextWrapper and ServiceWorkerContextCore for you. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // OnMessageToWorker when events are sent to the embedded | 110 // OnMessageToWorker when events are sent to the embedded |
110 // worker. By default they just return success via | 111 // worker. By default they just return success via |
111 // SimulateSendReplyToBrowser. | 112 // SimulateSendReplyToBrowser. |
112 virtual void OnActivateEvent(int embedded_worker_id, int request_id); | 113 virtual void OnActivateEvent(int embedded_worker_id, int request_id); |
113 virtual void OnInstallEvent(int embedded_worker_id, int request_id); | 114 virtual void OnInstallEvent(int embedded_worker_id, int request_id); |
114 virtual void OnFetchEvent(int embedded_worker_id, | 115 virtual void OnFetchEvent(int embedded_worker_id, |
115 int request_id, | 116 int request_id, |
116 const ServiceWorkerFetchRequest& request); | 117 const ServiceWorkerFetchRequest& request); |
117 virtual void OnPushEvent(int embedded_worker_id, | 118 virtual void OnPushEvent(int embedded_worker_id, |
118 int request_id, | 119 int request_id, |
119 const std::string& data); | 120 const PushEventPayload& data); |
Peter Beverloo
2016/01/25 17:39:06
note that the following CL will create a conflict
harkness
2016/01/26 12:07:19
Acknowledged.
| |
120 | 121 |
121 // These functions simulate sending an EmbeddedHostMsg message to the | 122 // These functions simulate sending an EmbeddedHostMsg message to the |
122 // browser. | 123 // browser. |
123 void SimulateWorkerReadyForInspection(int embedded_worker_id); | 124 void SimulateWorkerReadyForInspection(int embedded_worker_id); |
124 void SimulateWorkerScriptCached(int embedded_worker_id); | 125 void SimulateWorkerScriptCached(int embedded_worker_id); |
125 void SimulateWorkerScriptLoaded(int embedded_worker_id); | 126 void SimulateWorkerScriptLoaded(int embedded_worker_id); |
126 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); | 127 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); |
127 void SimulateWorkerScriptEvaluated(int embedded_worker_id); | 128 void SimulateWorkerScriptEvaluated(int embedded_worker_id); |
128 void SimulateWorkerStarted(int embedded_worker_id); | 129 void SimulateWorkerStarted(int embedded_worker_id); |
129 void SimulateWorkerStopped(int embedded_worker_id); | 130 void SimulateWorkerStopped(int embedded_worker_id); |
130 void SimulateSend(IPC::Message* message); | 131 void SimulateSend(IPC::Message* message); |
131 | 132 |
132 EmbeddedWorkerRegistry* registry(); | 133 EmbeddedWorkerRegistry* registry(); |
133 | 134 |
134 private: | 135 private: |
135 class MockEmbeddedWorkerSetup; | 136 class MockEmbeddedWorkerSetup; |
136 | 137 |
137 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); | 138 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); |
138 void OnStopWorkerStub(int embedded_worker_id); | 139 void OnStopWorkerStub(int embedded_worker_id); |
139 void OnMessageToWorkerStub(int thread_id, | 140 void OnMessageToWorkerStub(int thread_id, |
140 int embedded_worker_id, | 141 int embedded_worker_id, |
141 const IPC::Message& message); | 142 const IPC::Message& message); |
142 void OnActivateEventStub(int request_id); | 143 void OnActivateEventStub(int request_id); |
143 void OnInstallEventStub(int request_id); | 144 void OnInstallEventStub(int request_id); |
144 void OnFetchEventStub(int request_id, | 145 void OnFetchEventStub(int request_id, |
145 const ServiceWorkerFetchRequest& request); | 146 const ServiceWorkerFetchRequest& request); |
146 void OnPushEventStub(int request_id, const std::string& data); | 147 void OnPushEventStub(int request_id, const PushEventPayload& payload); |
147 void OnSetupMojoStub(int thread_id, | 148 void OnSetupMojoStub(int thread_id, |
148 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 149 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
149 mojo::ServiceProviderPtr exposed_services); | 150 mojo::ServiceProviderPtr exposed_services); |
150 | 151 |
151 MessagePortMessageFilter* NewMessagePortMessageFilter(); | 152 MessagePortMessageFilter* NewMessagePortMessageFilter(); |
152 | 153 |
153 scoped_ptr<TestBrowserContext> browser_context_; | 154 scoped_ptr<TestBrowserContext> browser_context_; |
154 scoped_ptr<MockRenderProcessHost> render_process_host_; | 155 scoped_ptr<MockRenderProcessHost> render_process_host_; |
155 | 156 |
156 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; | 157 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; |
(...skipping 20 matching lines...) Expand all Loading... | |
177 message_port_message_filters_; | 178 message_port_message_filters_; |
178 | 179 |
179 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 180 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
180 | 181 |
181 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 182 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
182 }; | 183 }; |
183 | 184 |
184 } // namespace content | 185 } // namespace content |
185 | 186 |
186 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 187 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
OLD | NEW |