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

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

Issue 1799413002: ServiceWorker: Release a reference when it fails to dispatch ExtendableMessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_dispatch_extendable_message_event
Patch Set: fix build failures Created 4 years, 9 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>
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/scoped_ptr_hash_map.h" 15 #include "base/containers/scoped_ptr_hash_map.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 "content/common/mojo/service_registry_impl.h" 18 #include "content/common/mojo/service_registry_impl.h"
19 #include "ipc/ipc_listener.h" 19 #include "ipc/ipc_listener.h"
20 #include "ipc/ipc_test_sink.h" 20 #include "ipc/ipc_test_sink.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 class GURL;
24 struct EmbeddedWorkerMsg_StartWorker_Params; 25 struct EmbeddedWorkerMsg_StartWorker_Params;
25 class GURL; 26 struct ServiceWorkerMsg_ExtendableMessageEvent_Params;
26 27
27 namespace content { 28 namespace content {
28 29
29 class EmbeddedWorkerRegistry; 30 class EmbeddedWorkerRegistry;
30 class EmbeddedWorkerTestHelper; 31 class EmbeddedWorkerTestHelper;
31 class MessagePortMessageFilter; 32 class MessagePortMessageFilter;
32 class MockRenderProcessHost; 33 class MockRenderProcessHost;
33 struct PushEventPayload;
34 class ServiceWorkerContextCore; 34 class ServiceWorkerContextCore;
35 class ServiceWorkerContextWrapper; 35 class ServiceWorkerContextWrapper;
36 class TestBrowserContext;
37 struct PushEventPayload;
36 struct ServiceWorkerFetchRequest; 38 struct ServiceWorkerFetchRequest;
37 class TestBrowserContext;
38 39
39 // In-Process EmbeddedWorker test helper. 40 // In-Process EmbeddedWorker test helper.
40 // 41 //
41 // Usage: create an instance of this class to test browser-side embedded worker 42 // Usage: create an instance of this class to test browser-side embedded worker
42 // code without creating a child process. This class will create a 43 // code without creating a child process. This class will create a
43 // ServiceWorkerContextWrapper and ServiceWorkerContextCore for you. 44 // ServiceWorkerContextWrapper and ServiceWorkerContextCore for you.
44 // 45 //
45 // By default this class just notifies back WorkerStarted and WorkerStopped 46 // By default this class just notifies back WorkerStarted and WorkerStopped
46 // for StartWorker and StopWorker requests. The default implementation 47 // for StartWorker and StopWorker requests. The default implementation
47 // also returns success for event messages (e.g. InstallEvent, FetchEvent). 48 // also returns success for event messages (e.g. InstallEvent, FetchEvent).
(...skipping 25 matching lines...) Expand all
73 IPC::TestSink* ipc_sink() { return &sink_; } 74 IPC::TestSink* ipc_sink() { return &sink_; }
74 // Inner IPC sink for script context messages sent via EmbeddedWorker. 75 // Inner IPC sink for script context messages sent via EmbeddedWorker.
75 IPC::TestSink* inner_ipc_sink() { return &inner_sink_; } 76 IPC::TestSink* inner_ipc_sink() { return &inner_sink_; }
76 77
77 ServiceWorkerContextCore* context(); 78 ServiceWorkerContextCore* context();
78 ServiceWorkerContextWrapper* context_wrapper() { return wrapper_.get(); } 79 ServiceWorkerContextWrapper* context_wrapper() { return wrapper_.get(); }
79 void ShutdownContext(); 80 void ShutdownContext();
80 81
81 int GetNextThreadId() { return next_thread_id_++; } 82 int GetNextThreadId() { return next_thread_id_++; }
82 83
83 int mock_render_process_id() const { return mock_render_process_id_;} 84 int mock_render_process_id() const { return mock_render_process_id_; }
84 MockRenderProcessHost* mock_render_process_host() { 85 MockRenderProcessHost* mock_render_process_host() {
85 return render_process_host_.get(); 86 return render_process_host_.get();
86 } 87 }
87 88
88 std::map<int, int64_t> embedded_worker_id_service_worker_version_id_map() { 89 std::map<int, int64_t> embedded_worker_id_service_worker_version_id_map() {
89 return embedded_worker_id_service_worker_version_id_map_; 90 return embedded_worker_id_service_worker_version_id_map_;
90 } 91 }
91 92
92 // Only used for tests that force creating a new render process. There is no 93 // Only used for tests that force creating a new render process. There is no
93 // corresponding MockRenderProcessHost. 94 // corresponding MockRenderProcessHost.
(...skipping 21 matching lines...) Expand all
115 116
116 // Called to setup mojo for a new embedded worker. Override to register 117 // Called to setup mojo for a new embedded worker. Override to register
117 // services the worker should expose to the browser. 118 // services the worker should expose to the browser.
118 virtual void OnSetupMojo(ServiceRegistry* service_registry); 119 virtual void OnSetupMojo(ServiceRegistry* service_registry);
119 120
120 // On*Event handlers. Called by the default implementation of 121 // On*Event handlers. Called by the default implementation of
121 // OnMessageToWorker when events are sent to the embedded 122 // OnMessageToWorker when events are sent to the embedded
122 // worker. By default they just return success via 123 // worker. By default they just return success via
123 // SimulateSendReplyToBrowser. 124 // SimulateSendReplyToBrowser.
124 virtual void OnActivateEvent(int embedded_worker_id, int request_id); 125 virtual void OnActivateEvent(int embedded_worker_id, int request_id);
126 virtual void OnExtendableMessageEvent(int embedded_worker_id, int request_id);
125 virtual void OnInstallEvent(int embedded_worker_id, int request_id); 127 virtual void OnInstallEvent(int embedded_worker_id, int request_id);
126 virtual void OnFetchEvent(int embedded_worker_id, 128 virtual void OnFetchEvent(int embedded_worker_id,
127 int request_id, 129 int request_id,
128 const ServiceWorkerFetchRequest& request); 130 const ServiceWorkerFetchRequest& request);
129 virtual void OnPushEvent(int embedded_worker_id, 131 virtual void OnPushEvent(int embedded_worker_id,
130 int request_id, 132 int request_id,
131 const PushEventPayload& payload); 133 const PushEventPayload& payload);
132 134
133 // These functions simulate sending an EmbeddedHostMsg message to the 135 // These functions simulate sending an EmbeddedHostMsg message to the
134 // browser. 136 // browser.
(...skipping 11 matching lines...) Expand all
146 private: 148 private:
147 class MockEmbeddedWorkerSetup; 149 class MockEmbeddedWorkerSetup;
148 150
149 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); 151 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params);
150 void OnResumeAfterDownloadStub(int embedded_worker_id); 152 void OnResumeAfterDownloadStub(int embedded_worker_id);
151 void OnStopWorkerStub(int embedded_worker_id); 153 void OnStopWorkerStub(int embedded_worker_id);
152 void OnMessageToWorkerStub(int thread_id, 154 void OnMessageToWorkerStub(int thread_id,
153 int embedded_worker_id, 155 int embedded_worker_id,
154 const IPC::Message& message); 156 const IPC::Message& message);
155 void OnActivateEventStub(int request_id); 157 void OnActivateEventStub(int request_id);
158 void OnExtendableMessageEventStub(
159 int request_id,
160 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params);
156 void OnInstallEventStub(int request_id); 161 void OnInstallEventStub(int request_id);
157 void OnFetchEventStub(int request_id, 162 void OnFetchEventStub(int request_id,
158 const ServiceWorkerFetchRequest& request); 163 const ServiceWorkerFetchRequest& request);
159 void OnPushEventStub(int request_id, const PushEventPayload& payload); 164 void OnPushEventStub(int request_id, const PushEventPayload& payload);
160 void OnSetupMojoStub( 165 void OnSetupMojoStub(
161 int thread_id, 166 int thread_id,
162 mojo::shell::mojom::InterfaceProviderRequest services, 167 mojo::shell::mojom::InterfaceProviderRequest services,
163 mojo::shell::mojom::InterfaceProviderPtr exposed_services); 168 mojo::shell::mojom::InterfaceProviderPtr exposed_services);
164 169
165 MessagePortMessageFilter* NewMessagePortMessageFilter(); 170 MessagePortMessageFilter* NewMessagePortMessageFilter();
(...skipping 25 matching lines...) Expand all
191 message_port_message_filters_; 196 message_port_message_filters_;
192 197
193 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; 198 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_;
194 199
195 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); 200 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper);
196 }; 201 };
197 202
198 } // namespace content 203 } // namespace content
199 204
200 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 205 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « content/browser/message_port_service.cc ('k') | content/browser/service_worker/embedded_worker_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698