| 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_types.h" | 19 #include "content/common/service_worker/service_worker_types.h" |
| 19 #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" |
| 20 | 22 |
| 21 class GURL; | 23 class GURL; |
| 22 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params; | 24 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params; |
| 23 | 25 |
| 24 namespace url { | 26 namespace url { |
| 25 class Origin; | 27 class Origin; |
| 26 } | 28 } |
| 27 | 29 |
| 28 namespace content { | 30 namespace content { |
| 29 | 31 |
| 30 class MessagePortMessageFilter; | 32 class MessagePortMessageFilter; |
| 31 class ResourceContext; | 33 class ResourceContext; |
| 32 class ServiceWorkerContextCore; | 34 class ServiceWorkerContextCore; |
| 33 class ServiceWorkerContextWrapper; | 35 class ServiceWorkerContextWrapper; |
| 34 class ServiceWorkerHandle; | 36 class ServiceWorkerHandle; |
| 35 class ServiceWorkerProviderHost; | 37 class ServiceWorkerProviderHost; |
| 36 class ServiceWorkerRegistration; | 38 class ServiceWorkerRegistration; |
| 37 class ServiceWorkerRegistrationHandle; | 39 class ServiceWorkerRegistrationHandle; |
| 38 class ServiceWorkerVersion; | 40 class ServiceWorkerVersion; |
| 39 struct ServiceWorkerObjectInfo; | 41 struct ServiceWorkerObjectInfo; |
| 40 struct ServiceWorkerRegistrationInfo; | 42 struct ServiceWorkerRegistrationInfo; |
| 41 struct ServiceWorkerRegistrationObjectInfo; | 43 struct ServiceWorkerRegistrationObjectInfo; |
| 42 struct ServiceWorkerVersionAttributes; | 44 struct ServiceWorkerVersionAttributes; |
| 43 | 45 |
| 44 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { | 46 class CONTENT_EXPORT ServiceWorkerDispatcherHost |
| 47 : public mojom::ServiceWorkerDispatcherHost, |
| 48 public BrowserMessageFilter { |
| 45 public: | 49 public: |
| 46 ServiceWorkerDispatcherHost( | 50 ServiceWorkerDispatcherHost( |
| 47 int render_process_id, | 51 int render_process_id, |
| 48 MessagePortMessageFilter* message_port_message_filter, | 52 MessagePortMessageFilter* message_port_message_filter, |
| 49 ResourceContext* resource_context); | 53 ResourceContext* resource_context); |
| 50 | 54 |
| 51 void Init(ServiceWorkerContextWrapper* context_wrapper); | 55 void Init(ServiceWorkerContextWrapper* context_wrapper); |
| 52 | 56 |
| 53 // BrowserMessageFilter implementation | 57 // BrowserMessageFilter implementation |
| 54 void OnFilterAdded(IPC::Channel* channel) override; | 58 void OnFilterAdded(IPC::Channel* channel) override; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 85 ~ServiceWorkerDispatcherHost() override; | 89 ~ServiceWorkerDispatcherHost() override; |
| 86 | 90 |
| 87 private: | 91 private: |
| 88 friend class BrowserThread; | 92 friend class BrowserThread; |
| 89 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; | 93 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; |
| 90 friend class ServiceWorkerDispatcherHostTest; | 94 friend class ServiceWorkerDispatcherHostTest; |
| 91 friend class TestingServiceWorkerDispatcherHost; | 95 friend class TestingServiceWorkerDispatcherHost; |
| 92 | 96 |
| 93 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; | 97 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; |
| 94 | 98 |
| 99 // Called when mojom::ServiceWorkerDispatcherHostPtr is created on the |
| 100 // renderer-side. |
| 101 void AddMojoBinding(mojo::ScopedInterfaceEndpointHandle handle); |
| 102 |
| 103 // mojom::ServiceWorkerDispatcherHost implementation |
| 104 void OnProviderCreated(int provider_id, |
| 105 int route_id, |
| 106 ServiceWorkerProviderType provider_type, |
| 107 bool is_parent_frame_secure) override; |
| 108 |
| 95 // IPC Message handlers | 109 // IPC Message handlers |
| 96 void OnRegisterServiceWorker(int thread_id, | 110 void OnRegisterServiceWorker(int thread_id, |
| 97 int request_id, | 111 int request_id, |
| 98 int provider_id, | 112 int provider_id, |
| 99 const GURL& pattern, | 113 const GURL& pattern, |
| 100 const GURL& script_url); | 114 const GURL& script_url); |
| 101 void OnUpdateServiceWorker(int thread_id, | 115 void OnUpdateServiceWorker(int thread_id, |
| 102 int request_id, | 116 int request_id, |
| 103 int provider_id, | 117 int provider_id, |
| 104 int64_t registration_id); | 118 int64_t registration_id); |
| 105 void OnUnregisterServiceWorker(int thread_id, | 119 void OnUnregisterServiceWorker(int thread_id, |
| 106 int request_id, | 120 int request_id, |
| 107 int provider_id, | 121 int provider_id, |
| 108 int64_t registration_id); | 122 int64_t registration_id); |
| 109 void OnGetRegistration(int thread_id, | 123 void OnGetRegistration(int thread_id, |
| 110 int request_id, | 124 int request_id, |
| 111 int provider_id, | 125 int provider_id, |
| 112 const GURL& document_url); | 126 const GURL& document_url); |
| 113 void OnGetRegistrations(int thread_id, int request_id, int provider_id); | 127 void OnGetRegistrations(int thread_id, int request_id, int provider_id); |
| 114 void OnGetRegistrationForReady(int thread_id, | 128 void OnGetRegistrationForReady(int thread_id, |
| 115 int request_id, | 129 int request_id, |
| 116 int provider_id); | 130 int provider_id); |
| 117 void OnProviderCreated(int provider_id, | |
| 118 int route_id, | |
| 119 ServiceWorkerProviderType provider_type, | |
| 120 bool is_parent_frame_secure); | |
| 121 void OnProviderDestroyed(int provider_id); | 131 void OnProviderDestroyed(int provider_id); |
| 122 void OnSetHostedVersionId(int provider_id, | 132 void OnSetHostedVersionId(int provider_id, |
| 123 int64_t version_id, | 133 int64_t version_id, |
| 124 int embedded_worker_id); | 134 int embedded_worker_id); |
| 125 void OnWorkerReadyForInspection(int embedded_worker_id); | 135 void OnWorkerReadyForInspection(int embedded_worker_id); |
| 126 void OnWorkerScriptLoaded(int embedded_worker_id); | 136 void OnWorkerScriptLoaded(int embedded_worker_id); |
| 127 void OnWorkerThreadStarted(int embedded_worker_id, | 137 void OnWorkerThreadStarted(int embedded_worker_id, |
| 128 int thread_id, | 138 int thread_id, |
| 129 int provider_id); | 139 int provider_id); |
| 130 void OnWorkerScriptLoadFailed(int embedded_worker_id); | 140 void OnWorkerScriptLoadFailed(int embedded_worker_id); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 246 |
| 237 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; | 247 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; |
| 238 | 248 |
| 239 using RegistrationHandleMap = | 249 using RegistrationHandleMap = |
| 240 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>; | 250 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>; |
| 241 RegistrationHandleMap registration_handles_; | 251 RegistrationHandleMap registration_handles_; |
| 242 | 252 |
| 243 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. | 253 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. |
| 244 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; | 254 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; |
| 245 | 255 |
| 256 mojo::AssociatedBindingSet<mojom::ServiceWorkerDispatcherHost> bindings_; |
| 257 |
| 258 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; |
| 259 |
| 246 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); | 260 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); |
| 247 }; | 261 }; |
| 248 | 262 |
| 249 } // namespace content | 263 } // namespace content |
| 250 | 264 |
| 251 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 265 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
| OLD | NEW |