Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: content/browser/service_worker/embedded_worker_test_helper.h

Issue 2420253002: Rename shell namespace to service_manager (Closed)
Patch Set: . Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 #include "ipc/ipc_listener.h" 22 #include "ipc/ipc_listener.h"
23 #include "ipc/ipc_test_sink.h" 23 #include "ipc/ipc_test_sink.h"
24 #include "mojo/public/cpp/bindings/binding.h" 24 #include "mojo/public/cpp/bindings/binding.h"
25 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" 25 #include "services/service_manager/public/interfaces/interface_provider.mojom.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "url/gurl.h" 27 #include "url/gurl.h"
28 28
29 class GURL; 29 class GURL;
30 struct ServiceWorkerMsg_ExtendableMessageEvent_Params; 30 struct ServiceWorkerMsg_ExtendableMessageEvent_Params;
31 31
32 namespace shell { 32 namespace service_manager {
33 class InterfaceProvider; 33 class InterfaceProvider;
34 class InterfaceRegistry; 34 class InterfaceRegistry;
35 } 35 }
36 36
37 namespace content { 37 namespace content {
38 38
39 class EmbeddedWorkerRegistry; 39 class EmbeddedWorkerRegistry;
40 class EmbeddedWorkerTestHelper; 40 class EmbeddedWorkerTestHelper;
41 class MessagePortMessageFilter; 41 class MessagePortMessageFilter;
42 class MockRenderProcessHost; 42 class MockRenderProcessHost;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 const GURL& script_url, 160 const GURL& script_url,
161 bool pause_after_download); 161 bool pause_after_download);
162 virtual void OnResumeAfterDownload(int embedded_worker_id); 162 virtual void OnResumeAfterDownload(int embedded_worker_id);
163 virtual void OnStopWorker(int embedded_worker_id); 163 virtual void OnStopWorker(int embedded_worker_id);
164 virtual bool OnMessageToWorker(int thread_id, 164 virtual bool OnMessageToWorker(int thread_id,
165 int embedded_worker_id, 165 int embedded_worker_id,
166 const IPC::Message& message); 166 const IPC::Message& message);
167 167
168 // Called to setup mojo for a new embedded worker. Override to register 168 // Called to setup mojo for a new embedded worker. Override to register
169 // interfaces the worker should expose to the browser. 169 // interfaces the worker should expose to the browser.
170 virtual void OnSetupMojo(int thread_id, 170 virtual void OnSetupMojo(
171 shell::InterfaceRegistry* interface_registry); 171 int thread_id,
172 service_manager::InterfaceRegistry* interface_registry);
172 173
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,
(...skipping 11 matching lines...) Expand all
193 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); 194 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id);
194 void SimulateWorkerScriptEvaluated(int embedded_worker_id, bool success); 195 void SimulateWorkerScriptEvaluated(int embedded_worker_id, bool success);
195 void SimulateWorkerStarted(int embedded_worker_id); 196 void SimulateWorkerStarted(int embedded_worker_id);
196 void SimulateWorkerStopped(int embedded_worker_id); 197 void SimulateWorkerStopped(int embedded_worker_id);
197 void SimulateSend(IPC::Message* message); 198 void SimulateSend(IPC::Message* message);
198 199
199 EmbeddedWorkerRegistry* registry(); 200 EmbeddedWorkerRegistry* registry();
200 201
201 private: 202 private:
202 using InterfaceRegistryAndProvider = 203 using InterfaceRegistryAndProvider =
203 std::pair<std::unique_ptr<shell::InterfaceRegistry>, 204 std::pair<std::unique_ptr<service_manager::InterfaceRegistry>,
204 std::unique_ptr<shell::InterfaceProvider>>; 205 std::unique_ptr<service_manager::InterfaceProvider>>;
205 206
206 class MockEmbeddedWorkerSetup; 207 class MockEmbeddedWorkerSetup;
207 class MockFetchEventDispatcher; 208 class MockFetchEventDispatcher;
208 209
209 void OnStartWorkerStub(const EmbeddedWorkerStartParams& params); 210 void OnStartWorkerStub(const EmbeddedWorkerStartParams& params);
210 void OnResumeAfterDownloadStub(int embedded_worker_id); 211 void OnResumeAfterDownloadStub(int embedded_worker_id);
211 void OnStopWorkerStub(int embedded_worker_id); 212 void OnStopWorkerStub(int embedded_worker_id);
212 void OnMessageToWorkerStub(int thread_id, 213 void OnMessageToWorkerStub(int thread_id,
213 int embedded_worker_id, 214 int embedded_worker_id,
214 const IPC::Message& message); 215 const IPC::Message& message);
215 void OnActivateEventStub(int request_id); 216 void OnActivateEventStub(int request_id);
216 void OnExtendableMessageEventStub( 217 void OnExtendableMessageEventStub(
217 int request_id, 218 int request_id,
218 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params); 219 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params);
219 void OnInstallEventStub(int request_id); 220 void OnInstallEventStub(int request_id);
220 void OnFetchEventStub(int thread_id, 221 void OnFetchEventStub(int thread_id,
221 int fetch_event_id, 222 int fetch_event_id,
222 const ServiceWorkerFetchRequest& request, 223 const ServiceWorkerFetchRequest& request,
223 const FetchCallback& callback); 224 const FetchCallback& callback);
224 void OnPushEventStub(int request_id, const PushEventPayload& payload); 225 void OnPushEventStub(int request_id, const PushEventPayload& payload);
225 void OnSetupMojoStub(int thread_id, 226 void OnSetupMojoStub(
226 shell::mojom::InterfaceProviderRequest services, 227 int thread_id,
227 shell::mojom::InterfaceProviderPtr exposed_services); 228 service_manager::mojom::InterfaceProviderRequest services,
229 service_manager::mojom::InterfaceProviderPtr exposed_services);
228 230
229 MessagePortMessageFilter* NewMessagePortMessageFilter(); 231 MessagePortMessageFilter* NewMessagePortMessageFilter();
230 232
231 std::unique_ptr<shell::InterfaceRegistry> CreateInterfaceRegistry( 233 std::unique_ptr<service_manager::InterfaceRegistry> CreateInterfaceRegistry(
232 MockRenderProcessHost* rph); 234 MockRenderProcessHost* rph);
233 235
234 std::unique_ptr<TestBrowserContext> browser_context_; 236 std::unique_ptr<TestBrowserContext> browser_context_;
235 std::unique_ptr<MockRenderProcessHost> render_process_host_; 237 std::unique_ptr<MockRenderProcessHost> render_process_host_;
236 std::unique_ptr<MockRenderProcessHost> new_render_process_host_; 238 std::unique_ptr<MockRenderProcessHost> new_render_process_host_;
237 239
238 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; 240 scoped_refptr<ServiceWorkerContextWrapper> wrapper_;
239 241
240 IPC::TestSink sink_; 242 IPC::TestSink sink_;
241 IPC::TestSink inner_sink_; 243 IPC::TestSink inner_sink_;
242 244
243 std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>> 245 std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>
244 mock_instance_clients_; 246 mock_instance_clients_;
245 size_t mock_instance_clients_next_index_; 247 size_t mock_instance_clients_next_index_;
246 248
247 int next_thread_id_; 249 int next_thread_id_;
248 int mock_render_process_id_; 250 int mock_render_process_id_;
249 int new_mock_render_process_id_; 251 int new_mock_render_process_id_;
250 252
251 std::unique_ptr<shell::InterfaceRegistry> render_process_interface_registry_; 253 std::unique_ptr<service_manager::InterfaceRegistry>
252 std::unique_ptr<shell::InterfaceRegistry> 254 render_process_interface_registry_;
255 std::unique_ptr<service_manager::InterfaceRegistry>
253 new_render_process_interface_registry_; 256 new_render_process_interface_registry_;
254 257
255 std::map<int, int64_t> embedded_worker_id_service_worker_version_id_map_; 258 std::map<int, int64_t> embedded_worker_id_service_worker_version_id_map_;
256 std::map<int /* thread_id */, int /* embedded_worker_id */> 259 std::map<int /* thread_id */, int /* embedded_worker_id */>
257 thread_id_embedded_worker_id_map_; 260 thread_id_embedded_worker_id_map_;
258 261
259 // Stores the InterfaceRegistry/InterfaceProviders that are associated with 262 // Stores the InterfaceRegistry/InterfaceProviders that are associated with
260 // each individual service worker. 263 // each individual service worker.
261 base::hash_map<int, InterfaceRegistryAndProvider> 264 base::hash_map<int, InterfaceRegistryAndProvider>
262 thread_id_service_registry_map_; 265 thread_id_service_registry_map_;
263 266
264 // Updated each time MessageToWorker message is received. 267 // Updated each time MessageToWorker message is received.
265 int current_embedded_worker_id_; 268 int current_embedded_worker_id_;
266 269
267 std::vector<scoped_refptr<MessagePortMessageFilter>> 270 std::vector<scoped_refptr<MessagePortMessageFilter>>
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698