| 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_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
| 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/id_map.h" | 15 #include "base/id_map.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "content/common/service_worker/service_worker_types.h" | 19 #include "content/common/service_worker/service_worker_types.h" |
| 20 #include "content/common/url_loader_factory.mojom.h" |
| 20 #include "content/public/child/worker_thread.h" | 21 #include "content/public/child/worker_thread.h" |
| 21 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerError.h" | 22 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerError.h" |
| 22 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerProvider.h" | 23 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerProvider.h" |
| 23 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerRegistration.h" | 24 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerRegistration.h" |
| 24 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerState.h" | 25 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerState.h" |
| 25 | 26 |
| 26 class GURL; | 27 class GURL; |
| 27 | 28 |
| 28 namespace base { | 29 namespace base { |
| 29 class SingleThreadTaskRunner; | 30 class SingleThreadTaskRunner; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 base::SingleThreadTaskRunner* main_thread_task_runner); | 169 base::SingleThreadTaskRunner* main_thread_task_runner); |
| 169 | 170 |
| 170 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new | 171 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new |
| 171 // instance if thread-local instance doesn't exist. | 172 // instance if thread-local instance doesn't exist. |
| 172 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); | 173 static ServiceWorkerDispatcher* GetThreadSpecificInstance(); |
| 173 | 174 |
| 174 base::SingleThreadTaskRunner* main_thread_task_runner() { | 175 base::SingleThreadTaskRunner* main_thread_task_runner() { |
| 175 return main_thread_task_runner_.get(); | 176 return main_thread_task_runner_.get(); |
| 176 } | 177 } |
| 177 | 178 |
| 179 mojom::URLLoaderFactory* GetURLLoaderFactory() { |
| 180 return url_loader_factory_.get(); |
| 181 } |
| 182 |
| 178 private: | 183 private: |
| 179 using RegistrationCallbackMap = | 184 using RegistrationCallbackMap = |
| 180 IDMap<std::unique_ptr<WebServiceWorkerRegistrationCallbacks>>; | 185 IDMap<std::unique_ptr<WebServiceWorkerRegistrationCallbacks>>; |
| 181 using UpdateCallbackMap = | 186 using UpdateCallbackMap = |
| 182 IDMap<std::unique_ptr<WebServiceWorkerUpdateCallbacks>>; | 187 IDMap<std::unique_ptr<WebServiceWorkerUpdateCallbacks>>; |
| 183 using UnregistrationCallbackMap = | 188 using UnregistrationCallbackMap = |
| 184 IDMap<std::unique_ptr<WebServiceWorkerUnregistrationCallbacks>>; | 189 IDMap<std::unique_ptr<WebServiceWorkerUnregistrationCallbacks>>; |
| 185 using GetRegistrationCallbackMap = | 190 using GetRegistrationCallbackMap = |
| 186 IDMap<std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks>>; | 191 IDMap<std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks>>; |
| 187 using GetRegistrationsCallbackMap = | 192 using GetRegistrationsCallbackMap = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 212 | 217 |
| 213 void OnAssociateRegistration(int thread_id, | 218 void OnAssociateRegistration(int thread_id, |
| 214 int provider_id, | 219 int provider_id, |
| 215 const ServiceWorkerRegistrationObjectInfo& info, | 220 const ServiceWorkerRegistrationObjectInfo& info, |
| 216 const ServiceWorkerVersionAttributes& attrs); | 221 const ServiceWorkerVersionAttributes& attrs); |
| 217 void OnDisassociateRegistration(int thread_id, | 222 void OnDisassociateRegistration(int thread_id, |
| 218 int provider_id); | 223 int provider_id); |
| 219 void OnRegistered(int thread_id, | 224 void OnRegistered(int thread_id, |
| 220 int request_id, | 225 int request_id, |
| 221 const ServiceWorkerRegistrationObjectInfo& info, | 226 const ServiceWorkerRegistrationObjectInfo& info, |
| 222 const ServiceWorkerVersionAttributes& attrs); | 227 const ServiceWorkerVersionAttributes& attrs, |
| 228 const mojo::MessagePipeHandle& url_loader_factory); |
| 223 void OnUpdated(int thread_id, int request_id); | 229 void OnUpdated(int thread_id, int request_id); |
| 224 void OnUnregistered(int thread_id, | 230 void OnUnregistered(int thread_id, |
| 225 int request_id, | 231 int request_id, |
| 226 bool is_success); | 232 bool is_success); |
| 227 void OnDidGetRegistration(int thread_id, | 233 void OnDidGetRegistration(int thread_id, |
| 228 int request_id, | 234 int request_id, |
| 229 const ServiceWorkerRegistrationObjectInfo& info, | 235 const ServiceWorkerRegistrationObjectInfo& info, |
| 230 const ServiceWorkerVersionAttributes& attrs); | 236 const ServiceWorkerVersionAttributes& attrs, |
| 237 const mojo::MessagePipeHandle& url_loader_factory); |
| 231 void OnDidGetRegistrations( | 238 void OnDidGetRegistrations( |
| 232 int thread_id, | 239 int thread_id, |
| 233 int request_id, | 240 int request_id, |
| 234 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, | 241 const std::vector<ServiceWorkerRegistrationObjectInfo>& infos, |
| 235 const std::vector<ServiceWorkerVersionAttributes>& attrs); | 242 const std::vector<ServiceWorkerVersionAttributes>& attrs, |
| 243 const std::vector<mojo::MessagePipeHandle>& url_loade_factories); |
| 236 void OnDidGetRegistrationForReady( | 244 void OnDidGetRegistrationForReady( |
| 237 int thread_id, | 245 int thread_id, |
| 238 int request_id, | 246 int request_id, |
| 239 const ServiceWorkerRegistrationObjectInfo& info, | 247 const ServiceWorkerRegistrationObjectInfo& info, |
| 240 const ServiceWorkerVersionAttributes& attrs); | 248 const ServiceWorkerVersionAttributes& attrs, |
| 249 const mojo::MessagePipeHandle& url_loader_factory); |
| 241 void OnDidEnableNavigationPreload(int thread_id, int request_id); | 250 void OnDidEnableNavigationPreload(int thread_id, int request_id); |
| 242 void OnDidGetNavigationPreloadState(int thread_id, | 251 void OnDidGetNavigationPreloadState(int thread_id, |
| 243 int request_id, | 252 int request_id, |
| 244 const NavigationPreloadState& state); | 253 const NavigationPreloadState& state); |
| 245 void OnDidSetNavigationPreloadHeader(int thread_id, int request_id); | 254 void OnDidSetNavigationPreloadHeader(int thread_id, int request_id); |
| 246 void OnRegistrationError(int thread_id, | 255 void OnRegistrationError(int thread_id, |
| 247 int request_id, | 256 int request_id, |
| 248 blink::WebServiceWorkerError::ErrorType error_type, | 257 blink::WebServiceWorkerError::ErrorType error_type, |
| 249 const base::string16& message); | 258 const base::string16& message); |
| 250 void OnUpdateError(int thread_id, | 259 void OnUpdateError(int thread_id, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 337 |
| 329 ProviderClientMap provider_clients_; | 338 ProviderClientMap provider_clients_; |
| 330 ProviderContextMap provider_contexts_; | 339 ProviderContextMap provider_contexts_; |
| 331 | 340 |
| 332 WorkerObjectMap service_workers_; | 341 WorkerObjectMap service_workers_; |
| 333 RegistrationObjectMap registrations_; | 342 RegistrationObjectMap registrations_; |
| 334 | 343 |
| 335 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 344 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 336 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 345 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 337 | 346 |
| 347 mojom::URLLoaderFactoryPtr url_loader_factory_; |
| 348 |
| 338 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); | 349 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); |
| 339 }; | 350 }; |
| 340 | 351 |
| 341 } // namespace content | 352 } // namespace content |
| 342 | 353 |
| 343 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ | 354 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ |
| OLD | NEW |