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

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

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Eliminate unnecessary PostTask Created 3 years, 10 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 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 12 matching lines...) Expand all
23 23
24 class GURL; 24 class GURL;
25 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params; 25 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params;
26 26
27 namespace url { 27 namespace url {
28 class Origin; 28 class Origin;
29 } // namespace url 29 } // namespace url
30 30
31 namespace content { 31 namespace content {
32 32
33 class MessagePortMessageFilter; 33 class MessagePort;
34 class ResourceContext; 34 class ResourceContext;
35 class ServiceWorkerContextCore; 35 class ServiceWorkerContextCore;
36 class ServiceWorkerContextWrapper; 36 class ServiceWorkerContextWrapper;
37 class ServiceWorkerHandle; 37 class ServiceWorkerHandle;
38 class ServiceWorkerProviderHost; 38 class ServiceWorkerProviderHost;
39 class ServiceWorkerRegistration; 39 class ServiceWorkerRegistration;
40 class ServiceWorkerRegistrationHandle; 40 class ServiceWorkerRegistrationHandle;
41 class ServiceWorkerVersion; 41 class ServiceWorkerVersion;
42 struct ServiceWorkerObjectInfo; 42 struct ServiceWorkerObjectInfo;
43 struct ServiceWorkerRegistrationObjectInfo; 43 struct ServiceWorkerRegistrationObjectInfo;
44 struct ServiceWorkerVersionAttributes; 44 struct ServiceWorkerVersionAttributes;
45 45
46 class CONTENT_EXPORT ServiceWorkerDispatcherHost 46 class CONTENT_EXPORT ServiceWorkerDispatcherHost
47 : public mojom::ServiceWorkerDispatcherHost, 47 : public mojom::ServiceWorkerDispatcherHost,
48 public BrowserMessageFilter { 48 public BrowserMessageFilter {
49 public: 49 public:
50 ServiceWorkerDispatcherHost( 50 ServiceWorkerDispatcherHost(
51 int render_process_id, 51 int render_process_id,
52 MessagePortMessageFilter* message_port_message_filter,
53 ResourceContext* resource_context); 52 ResourceContext* resource_context);
54 53
55 void Init(ServiceWorkerContextWrapper* context_wrapper); 54 void Init(ServiceWorkerContextWrapper* context_wrapper);
56 55
57 // BrowserMessageFilter implementation 56 // BrowserMessageFilter implementation
58 void OnFilterAdded(IPC::Channel* channel) override; 57 void OnFilterAdded(IPC::Channel* channel) override;
59 void OnFilterRemoved() override; 58 void OnFilterRemoved() override;
60 void OnDestruct() const override; 59 void OnDestruct() const override;
61 bool OnMessageReceived(const IPC::Message& message) override; 60 bool OnMessageReceived(const IPC::Message& message) override;
62 61
(...skipping 11 matching lines...) Expand all
74 73
75 ServiceWorkerHandle* FindServiceWorkerHandle(int provider_id, 74 ServiceWorkerHandle* FindServiceWorkerHandle(int provider_id,
76 int64_t version_id); 75 int64_t version_id);
77 76
78 // Returns the existing registration handle whose reference count is 77 // Returns the existing registration handle whose reference count is
79 // incremented or a newly created one if it doesn't exist. 78 // incremented or a newly created one if it doesn't exist.
80 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle( 79 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle(
81 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 80 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
82 ServiceWorkerRegistration* registration); 81 ServiceWorkerRegistration* registration);
83 82
84 MessagePortMessageFilter* message_port_message_filter() {
85 return message_port_message_filter_;
86 }
87
88 protected: 83 protected:
89 ~ServiceWorkerDispatcherHost() override; 84 ~ServiceWorkerDispatcherHost() override;
90 85
91 private: 86 private:
92 friend class BrowserThread; 87 friend class BrowserThread;
93 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; 88 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>;
94 friend class ServiceWorkerDispatcherHostTest; 89 friend class ServiceWorkerDispatcherHostTest;
95 friend class TestingServiceWorkerDispatcherHost; 90 friend class TestingServiceWorkerDispatcherHost;
96 91
97 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; 92 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 int line_number, 156 int line_number,
162 int column_number, 157 int column_number,
163 const GURL& source_url); 158 const GURL& source_url);
164 void OnReportConsoleMessage( 159 void OnReportConsoleMessage(
165 int embedded_worker_id, 160 int embedded_worker_id,
166 const EmbeddedWorkerHostMsg_ReportConsoleMessage_Params& params); 161 const EmbeddedWorkerHostMsg_ReportConsoleMessage_Params& params);
167 void OnIncrementServiceWorkerRefCount(int handle_id); 162 void OnIncrementServiceWorkerRefCount(int handle_id);
168 void OnDecrementServiceWorkerRefCount(int handle_id); 163 void OnDecrementServiceWorkerRefCount(int handle_id);
169 void OnIncrementRegistrationRefCount(int registration_handle_id); 164 void OnIncrementRegistrationRefCount(int registration_handle_id);
170 void OnDecrementRegistrationRefCount(int registration_handle_id); 165 void OnDecrementRegistrationRefCount(int registration_handle_id);
171 void OnPostMessageToWorker(int handle_id, 166 void OnPostMessageToWorker(
172 int provider_id, 167 int handle_id,
173 const base::string16& message, 168 int provider_id,
174 const url::Origin& source_origin, 169 const base::string16& message,
175 const std::vector<int>& sent_message_ports); 170 const url::Origin& source_origin,
171 const std::vector<MessagePort>& sent_message_ports);
176 172
177 void OnTerminateWorker(int handle_id); 173 void OnTerminateWorker(int handle_id);
178 174
179 void DispatchExtendableMessageEvent( 175 void DispatchExtendableMessageEvent(
180 scoped_refptr<ServiceWorkerVersion> worker, 176 scoped_refptr<ServiceWorkerVersion> worker,
181 const base::string16& message, 177 const base::string16& message,
182 const url::Origin& source_origin, 178 const url::Origin& source_origin,
183 const std::vector<int>& sent_message_ports, 179 const std::vector<MessagePort>& sent_message_ports,
184 ServiceWorkerProviderHost* sender_provider_host, 180 ServiceWorkerProviderHost* sender_provider_host,
185 const StatusCallback& callback); 181 const StatusCallback& callback);
186 template <typename SourceInfo> 182 template <typename SourceInfo>
187 void DispatchExtendableMessageEventInternal( 183 void DispatchExtendableMessageEventInternal(
188 scoped_refptr<ServiceWorkerVersion> worker, 184 scoped_refptr<ServiceWorkerVersion> worker,
189 const base::string16& message, 185 const base::string16& message,
190 const url::Origin& source_origin, 186 const url::Origin& source_origin,
191 const std::vector<int>& sent_message_ports, 187 const std::vector<MessagePort>& sent_message_ports,
192 const base::Optional<base::TimeDelta>& timeout, 188 const base::Optional<base::TimeDelta>& timeout,
193 const StatusCallback& callback, 189 const StatusCallback& callback,
194 const SourceInfo& source_info); 190 const SourceInfo& source_info);
195 void DispatchExtendableMessageEventAfterStartWorker( 191 void DispatchExtendableMessageEventAfterStartWorker(
196 scoped_refptr<ServiceWorkerVersion> worker, 192 scoped_refptr<ServiceWorkerVersion> worker,
197 const base::string16& message, 193 const base::string16& message,
198 const url::Origin& source_origin, 194 const url::Origin& source_origin,
199 const std::vector<int>& sent_message_ports, 195 const std::vector<MessagePort>& sent_message_ports,
200 const ExtendableMessageEventSource& source, 196 const ExtendableMessageEventSource& source,
201 const base::Optional<base::TimeDelta>& timeout, 197 const base::Optional<base::TimeDelta>& timeout,
202 const StatusCallback& callback); 198 const StatusCallback& callback);
203 template <typename SourceInfo> 199 template <typename SourceInfo>
204 void DidFailToDispatchExtendableMessageEvent( 200 void DidFailToDispatchExtendableMessageEvent(
205 const std::vector<int>& sent_message_ports, 201 const std::vector<MessagePort>& sent_message_ports,
206 const SourceInfo& source_info, 202 const SourceInfo& source_info,
207 const StatusCallback& callback, 203 const StatusCallback& callback,
208 ServiceWorkerStatusCode status); 204 ServiceWorkerStatusCode status);
209 void ReleaseSourceInfo(const ServiceWorkerClientInfo& source_info); 205 void ReleaseSourceInfo(const ServiceWorkerClientInfo& source_info);
210 void ReleaseSourceInfo(const ServiceWorkerObjectInfo& source_info); 206 void ReleaseSourceInfo(const ServiceWorkerObjectInfo& source_info);
211 207
212 ServiceWorkerRegistrationHandle* FindRegistrationHandle( 208 ServiceWorkerRegistrationHandle* FindRegistrationHandle(
213 int provider_id, 209 int provider_id,
214 int64_t registration_handle_id); 210 int64_t registration_handle_id);
215 211
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 int registration_id, 263 int registration_id,
268 bool enable, 264 bool enable,
269 ServiceWorkerStatusCode status); 265 ServiceWorkerStatusCode status);
270 void DidUpdateNavigationPreloadHeader(int thread_id, 266 void DidUpdateNavigationPreloadHeader(int thread_id,
271 int request_id, 267 int request_id,
272 int registration_id, 268 int registration_id,
273 const std::string& value, 269 const std::string& value,
274 ServiceWorkerStatusCode status); 270 ServiceWorkerStatusCode status);
275 271
276 const int render_process_id_; 272 const int render_process_id_;
277 MessagePortMessageFilter* const message_port_message_filter_;
278 ResourceContext* resource_context_; 273 ResourceContext* resource_context_;
279 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; 274 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_;
280 275
281 IDMap<std::unique_ptr<ServiceWorkerHandle>> handles_; 276 IDMap<std::unique_ptr<ServiceWorkerHandle>> handles_;
282 277
283 using RegistrationHandleMap = 278 using RegistrationHandleMap =
284 IDMap<std::unique_ptr<ServiceWorkerRegistrationHandle>>; 279 IDMap<std::unique_ptr<ServiceWorkerRegistrationHandle>>;
285 RegistrationHandleMap registration_handles_; 280 RegistrationHandleMap registration_handles_;
286 281
287 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. 282 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL.
288 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; 283 std::vector<std::unique_ptr<IPC::Message>> pending_messages_;
289 284
290 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_; 285 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_;
291 286
292 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; 287 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_;
293 288
294 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); 289 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost);
295 }; 290 };
296 291
297 } // namespace content 292 } // namespace content
298 293
299 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 294 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698