OLD | NEW |
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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "content/browser/service_worker/service_worker_registration_status.h" | 17 #include "content/browser/service_worker/service_worker_registration_status.h" |
18 #include "content/common/service_worker/service_worker.mojom.h" | 18 #include "content/common/service_worker/service_worker.mojom.h" |
19 #include "content/common/service_worker/service_worker_types.h" | 19 #include "content/common/service_worker/service_worker_types.h" |
20 #include "content/public/browser/browser_message_filter.h" | 20 #include "content/public/browser/browser_message_filter.h" |
21 #include "mojo/public/cpp/bindings/associated_binding_set.h" | 21 #include "mojo/public/cpp/bindings/associated_binding_set.h" |
22 | 22 |
23 class GURL; | 23 class GURL; |
24 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params; | 24 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params; |
25 | 25 |
26 namespace url { | 26 namespace url { |
27 class Origin; | 27 class Origin; |
28 } | 28 } // namespace url |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 class MessagePortMessageFilter; | 32 class MessagePortMessageFilter; |
33 class ResourceContext; | 33 class ResourceContext; |
34 class ServiceWorkerContextCore; | 34 class ServiceWorkerContextCore; |
35 class ServiceWorkerContextWrapper; | 35 class ServiceWorkerContextWrapper; |
36 class ServiceWorkerHandle; | 36 class ServiceWorkerHandle; |
37 class ServiceWorkerProviderHost; | 37 class ServiceWorkerProviderHost; |
38 class ServiceWorkerRegistration; | 38 class ServiceWorkerRegistration; |
39 class ServiceWorkerRegistrationHandle; | 39 class ServiceWorkerRegistrationHandle; |
40 class ServiceWorkerVersion; | 40 class ServiceWorkerVersion; |
41 struct ServiceWorkerObjectInfo; | 41 struct ServiceWorkerObjectInfo; |
42 struct ServiceWorkerRegistrationInfo; | 42 struct ServiceWorkerRegistrationInfo; |
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, | 52 MessagePortMessageFilter* message_port_message_filter, |
53 ResourceContext* resource_context); | 53 ResourceContext* resource_context, |
| 54 const MojoURLLoaderFactoryGetter& url_loader_factory_getter); |
54 | 55 |
55 void Init(ServiceWorkerContextWrapper* context_wrapper); | 56 void Init(ServiceWorkerContextWrapper* context_wrapper); |
56 | 57 |
57 // BrowserMessageFilter implementation | 58 // BrowserMessageFilter implementation |
58 void OnFilterAdded(IPC::Channel* channel) override; | 59 void OnFilterAdded(IPC::Channel* channel) override; |
59 void OnFilterRemoved() override; | 60 void OnFilterRemoved() override; |
60 void OnDestruct() const override; | 61 void OnDestruct() const override; |
61 bool OnMessageReceived(const IPC::Message& message) override; | 62 bool OnMessageReceived(const IPC::Message& message) override; |
62 | 63 |
63 // IPC::Sender implementation | 64 // IPC::Sender implementation |
(...skipping 14 matching lines...) Expand all Loading... |
78 // Returns the existing registration handle whose reference count is | 79 // Returns the existing registration handle whose reference count is |
79 // incremented or a newly created one if it doesn't exist. | 80 // incremented or a newly created one if it doesn't exist. |
80 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle( | 81 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle( |
81 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 82 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
82 ServiceWorkerRegistration* registration); | 83 ServiceWorkerRegistration* registration); |
83 | 84 |
84 MessagePortMessageFilter* message_port_message_filter() { | 85 MessagePortMessageFilter* message_port_message_filter() { |
85 return message_port_message_filter_; | 86 return message_port_message_filter_; |
86 } | 87 } |
87 | 88 |
| 89 MojoURLLoaderFactoryGetter url_loader_factory_getter() const { |
| 90 return url_loader_factory_getter_; |
| 91 } |
| 92 |
88 protected: | 93 protected: |
89 ~ServiceWorkerDispatcherHost() override; | 94 ~ServiceWorkerDispatcherHost() override; |
90 | 95 |
91 private: | 96 private: |
92 friend class BrowserThread; | 97 friend class BrowserThread; |
93 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; | 98 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; |
94 friend class ServiceWorkerDispatcherHostTest; | 99 friend class ServiceWorkerDispatcherHostTest; |
95 friend class TestingServiceWorkerDispatcherHost; | 100 friend class TestingServiceWorkerDispatcherHost; |
96 | 101 |
97 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; | 102 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // Returns the provider host with id equal to |provider_id|, or nullptr | 247 // Returns the provider host with id equal to |provider_id|, or nullptr |
243 // if the provider host could not be found or is not appropriate for | 248 // if the provider host could not be found or is not appropriate for |
244 // initiating a request such as register/unregister/update. | 249 // initiating a request such as register/unregister/update. |
245 ServiceWorkerProviderHost* GetProviderHostForRequest( | 250 ServiceWorkerProviderHost* GetProviderHostForRequest( |
246 ProviderStatus* out_status, | 251 ProviderStatus* out_status, |
247 int provider_id); | 252 int provider_id); |
248 | 253 |
249 const int render_process_id_; | 254 const int render_process_id_; |
250 MessagePortMessageFilter* const message_port_message_filter_; | 255 MessagePortMessageFilter* const message_port_message_filter_; |
251 ResourceContext* resource_context_; | 256 ResourceContext* resource_context_; |
| 257 const MojoURLLoaderFactoryGetter url_loader_factory_getter_; |
252 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; | 258 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; |
253 | 259 |
254 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; | 260 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; |
255 | 261 |
256 using RegistrationHandleMap = | 262 using RegistrationHandleMap = |
257 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>; | 263 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>; |
258 RegistrationHandleMap registration_handles_; | 264 RegistrationHandleMap registration_handles_; |
259 | 265 |
260 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. | 266 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. |
261 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; | 267 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; |
262 | 268 |
263 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_; | 269 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_; |
264 | 270 |
265 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; | 271 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; |
266 | 272 |
267 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); | 273 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); |
268 }; | 274 }; |
269 | 275 |
270 } // namespace content | 276 } // namespace content |
271 | 277 |
272 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 278 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
OLD | NEW |