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> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); | |
55 | 54 |
56 void Init(ServiceWorkerContextWrapper* context_wrapper); | 55 void Init(ServiceWorkerContextWrapper* context_wrapper); |
57 | 56 |
58 // BrowserMessageFilter implementation | 57 // BrowserMessageFilter implementation |
59 void OnFilterAdded(IPC::Channel* channel) override; | 58 void OnFilterAdded(IPC::Channel* channel) override; |
60 void OnFilterRemoved() override; | 59 void OnFilterRemoved() override; |
61 void OnDestruct() const override; | 60 void OnDestruct() const override; |
62 bool OnMessageReceived(const IPC::Message& message) override; | 61 bool OnMessageReceived(const IPC::Message& message) override; |
63 | 62 |
64 // IPC::Sender implementation | 63 // IPC::Sender implementation |
(...skipping 14 matching lines...) Expand all Loading... |
79 // Returns the existing registration handle whose reference count is | 78 // Returns the existing registration handle whose reference count is |
80 // incremented or a newly created one if it doesn't exist. | 79 // incremented or a newly created one if it doesn't exist. |
81 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle( | 80 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle( |
82 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 81 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
83 ServiceWorkerRegistration* registration); | 82 ServiceWorkerRegistration* registration); |
84 | 83 |
85 MessagePortMessageFilter* message_port_message_filter() { | 84 MessagePortMessageFilter* message_port_message_filter() { |
86 return message_port_message_filter_; | 85 return message_port_message_filter_; |
87 } | 86 } |
88 | 87 |
89 MojoURLLoaderFactoryGetter url_loader_factory_getter() const { | |
90 return url_loader_factory_getter_; | |
91 } | |
92 | |
93 protected: | 88 protected: |
94 ~ServiceWorkerDispatcherHost() override; | 89 ~ServiceWorkerDispatcherHost() override; |
95 | 90 |
96 private: | 91 private: |
97 friend class BrowserThread; | 92 friend class BrowserThread; |
98 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; | 93 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; |
99 friend class ServiceWorkerDispatcherHostTest; | 94 friend class ServiceWorkerDispatcherHostTest; |
100 friend class TestingServiceWorkerDispatcherHost; | 95 friend class TestingServiceWorkerDispatcherHost; |
101 | 96 |
102 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; | 97 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // Returns the provider host with id equal to |provider_id|, or nullptr | 251 // Returns the provider host with id equal to |provider_id|, or nullptr |
257 // if the provider host could not be found or is not appropriate for | 252 // if the provider host could not be found or is not appropriate for |
258 // initiating a request such as register/unregister/update. | 253 // initiating a request such as register/unregister/update. |
259 ServiceWorkerProviderHost* GetProviderHostForRequest( | 254 ServiceWorkerProviderHost* GetProviderHostForRequest( |
260 ProviderStatus* out_status, | 255 ProviderStatus* out_status, |
261 int provider_id); | 256 int provider_id); |
262 | 257 |
263 const int render_process_id_; | 258 const int render_process_id_; |
264 MessagePortMessageFilter* const message_port_message_filter_; | 259 MessagePortMessageFilter* const message_port_message_filter_; |
265 ResourceContext* resource_context_; | 260 ResourceContext* resource_context_; |
266 const MojoURLLoaderFactoryGetter url_loader_factory_getter_; | |
267 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; | 261 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; |
268 | 262 |
269 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; | 263 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; |
270 | 264 |
271 using RegistrationHandleMap = | 265 using RegistrationHandleMap = |
272 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>; | 266 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>; |
273 RegistrationHandleMap registration_handles_; | 267 RegistrationHandleMap registration_handles_; |
274 | 268 |
275 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. | 269 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. |
276 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; | 270 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; |
277 | 271 |
278 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_; | 272 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_; |
279 | 273 |
280 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; | 274 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; |
281 | 275 |
282 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); | 276 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); |
283 }; | 277 }; |
284 | 278 |
285 } // namespace content | 279 } // namespace content |
286 | 280 |
287 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 281 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
OLD | NEW |