Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PROVIDER_CONTEXT_H_ | 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ |
| 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ | 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/common/service_worker/service_worker_provider_interfaces.mojom .h" | |
| 16 #include "content/common/service_worker/service_worker_types.h" | 17 #include "content/common/service_worker/service_worker_types.h" |
| 18 #include "mojo/public/cpp/bindings/associated_binding.h" | |
| 17 | 19 |
| 18 namespace base { | 20 namespace base { |
| 19 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace content { | 24 namespace content { |
| 23 | 25 |
| 24 class ServiceWorkerHandleReference; | 26 class ServiceWorkerHandleReference; |
| 25 class ServiceWorkerRegistrationHandleReference; | 27 class ServiceWorkerRegistrationHandleReference; |
| 26 struct ServiceWorkerProviderContextDeleter; | 28 struct ServiceWorkerProviderContextDeleter; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 37 // references to them are kept until OnDisassociateRegistration() is called | 39 // references to them are kept until OnDisassociateRegistration() is called |
| 38 // or OnSetControllerServiceWorker() is called with an invalid worker info. | 40 // or OnSetControllerServiceWorker() is called with an invalid worker info. |
| 39 // - For controllers, this is used for keeping the associated registration and | 41 // - For controllers, this is used for keeping the associated registration and |
| 40 // its versions alive to create controller's ServiceWorkerGlobalScope. The | 42 // its versions alive to create controller's ServiceWorkerGlobalScope. The |
| 41 // references to them are kept until OnDisassociateRegistration() is called. | 43 // references to them are kept until OnDisassociateRegistration() is called. |
| 42 // | 44 // |
| 43 // These operations are actually done in delegate classes owned by this class: | 45 // These operations are actually done in delegate classes owned by this class: |
| 44 // ControlleeDelegate and ControllerDelegate. | 46 // ControlleeDelegate and ControllerDelegate. |
| 45 class CONTENT_EXPORT ServiceWorkerProviderContext | 47 class CONTENT_EXPORT ServiceWorkerProviderContext |
| 46 : public base::RefCountedThreadSafe<ServiceWorkerProviderContext, | 48 : public base::RefCountedThreadSafe<ServiceWorkerProviderContext, |
| 47 ServiceWorkerProviderContextDeleter> { | 49 ServiceWorkerProviderContextDeleter>, |
| 50 NON_EXPORTED_BASE(public mojom::ServiceWorkerProvider) { | |
| 48 public: | 51 public: |
|
falken
2017/05/18 04:13:09
Can you document what |request| is?
shimazu
2017/05/19 08:31:06
Done.
| |
| 49 ServiceWorkerProviderContext(int provider_id, | 52 ServiceWorkerProviderContext( |
| 50 ServiceWorkerProviderType provider_type, | 53 int provider_id, |
| 51 ThreadSafeSender* thread_safe_sender); | 54 ServiceWorkerProviderType provider_type, |
| 55 mojom::ServiceWorkerProviderAssociatedRequest request, | |
| 56 ThreadSafeSender* thread_safe_sender); | |
| 52 | 57 |
| 53 // Called from ServiceWorkerDispatcher. | 58 // Called from ServiceWorkerDispatcher. |
| 54 void OnAssociateRegistration( | 59 void OnAssociateRegistration( |
| 55 std::unique_ptr<ServiceWorkerRegistrationHandleReference> registration, | 60 std::unique_ptr<ServiceWorkerRegistrationHandleReference> registration, |
| 56 std::unique_ptr<ServiceWorkerHandleReference> installing, | 61 std::unique_ptr<ServiceWorkerHandleReference> installing, |
| 57 std::unique_ptr<ServiceWorkerHandleReference> waiting, | 62 std::unique_ptr<ServiceWorkerHandleReference> waiting, |
| 58 std::unique_ptr<ServiceWorkerHandleReference> active); | 63 std::unique_ptr<ServiceWorkerHandleReference> active); |
| 59 void OnDisassociateRegistration(); | 64 void OnDisassociateRegistration(); |
| 60 void OnSetControllerServiceWorker( | 65 void OnSetControllerServiceWorker( |
| 61 std::unique_ptr<ServiceWorkerHandleReference> controller, | 66 std::unique_ptr<ServiceWorkerHandleReference> controller, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 77 private: | 82 private: |
| 78 friend class base::DeleteHelper<ServiceWorkerProviderContext>; | 83 friend class base::DeleteHelper<ServiceWorkerProviderContext>; |
| 79 friend class base::RefCountedThreadSafe<ServiceWorkerProviderContext, | 84 friend class base::RefCountedThreadSafe<ServiceWorkerProviderContext, |
| 80 ServiceWorkerProviderContextDeleter>; | 85 ServiceWorkerProviderContextDeleter>; |
| 81 friend struct ServiceWorkerProviderContextDeleter; | 86 friend struct ServiceWorkerProviderContextDeleter; |
| 82 | 87 |
| 83 class Delegate; | 88 class Delegate; |
| 84 class ControlleeDelegate; | 89 class ControlleeDelegate; |
| 85 class ControllerDelegate; | 90 class ControllerDelegate; |
| 86 | 91 |
| 87 ~ServiceWorkerProviderContext(); | 92 ~ServiceWorkerProviderContext() override; |
| 88 void DestructOnMainThread() const; | 93 void DestructOnMainThread() const; |
| 89 | 94 |
| 90 const int provider_id_; | 95 const int provider_id_; |
| 91 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 96 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 92 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 97 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 98 mojo::AssociatedBinding<mojom::ServiceWorkerProvider> binding_; | |
| 93 | 99 |
| 94 std::unique_ptr<Delegate> delegate_; | 100 std::unique_ptr<Delegate> delegate_; |
| 95 | 101 |
| 96 std::set<uint32_t> used_features_; | 102 std::set<uint32_t> used_features_; |
| 97 | 103 |
| 98 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext); | 104 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext); |
| 99 }; | 105 }; |
| 100 | 106 |
| 101 struct ServiceWorkerProviderContextDeleter { | 107 struct ServiceWorkerProviderContextDeleter { |
| 102 static void Destruct(const ServiceWorkerProviderContext* context) { | 108 static void Destruct(const ServiceWorkerProviderContext* context) { |
| 103 context->DestructOnMainThread(); | 109 context->DestructOnMainThread(); |
| 104 } | 110 } |
| 105 }; | 111 }; |
| 106 | 112 |
| 107 } // namespace content | 113 } // namespace content |
| 108 | 114 |
| 109 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ | 115 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ |
| OLD | NEW |