| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 int thread_id, | 240 int thread_id, |
| 236 int request_id, | 241 int request_id, |
| 237 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 242 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 238 ServiceWorkerRegistration* registration); | 243 ServiceWorkerRegistration* registration); |
| 239 | 244 |
| 240 ServiceWorkerContextCore* GetContext(); | 245 ServiceWorkerContextCore* GetContext(); |
| 241 | 246 |
| 242 const int render_process_id_; | 247 const int render_process_id_; |
| 243 MessagePortMessageFilter* const message_port_message_filter_; | 248 MessagePortMessageFilter* const message_port_message_filter_; |
| 244 ResourceContext* resource_context_; | 249 ResourceContext* resource_context_; |
| 250 const MojoURLLoaderFactoryGetter url_loader_factory_getter_; |
| 245 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; | 251 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; |
| 246 | 252 |
| 247 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; | 253 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; |
| 248 | 254 |
| 249 using RegistrationHandleMap = | 255 using RegistrationHandleMap = |
| 250 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>; | 256 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>; |
| 251 RegistrationHandleMap registration_handles_; | 257 RegistrationHandleMap registration_handles_; |
| 252 | 258 |
| 253 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. | 259 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. |
| 254 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; | 260 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; |
| 255 | 261 |
| 256 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_; | 262 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_; |
| 257 | 263 |
| 258 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; | 264 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; |
| 259 | 265 |
| 260 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); | 266 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); |
| 261 }; | 267 }; |
| 262 | 268 |
| 263 } // namespace content | 269 } // namespace content |
| 264 | 270 |
| 265 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 271 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
| OLD | NEW |