| 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 <set> | 9 #include <set> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
| 14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 15 #include "content/common/service_worker/service_worker_types.h" | 16 #include "content/common/service_worker/service_worker_types.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 44 class CONTENT_EXPORT ServiceWorkerProviderContext | 45 class CONTENT_EXPORT ServiceWorkerProviderContext |
| 45 : public base::RefCountedThreadSafe<ServiceWorkerProviderContext, | 46 : public base::RefCountedThreadSafe<ServiceWorkerProviderContext, |
| 46 ServiceWorkerProviderContextDeleter> { | 47 ServiceWorkerProviderContextDeleter> { |
| 47 public: | 48 public: |
| 48 ServiceWorkerProviderContext(int provider_id, | 49 ServiceWorkerProviderContext(int provider_id, |
| 49 ServiceWorkerProviderType provider_type, | 50 ServiceWorkerProviderType provider_type, |
| 50 ThreadSafeSender* thread_safe_sender); | 51 ThreadSafeSender* thread_safe_sender); |
| 51 | 52 |
| 52 // Called from ServiceWorkerDispatcher. | 53 // Called from ServiceWorkerDispatcher. |
| 53 void OnAssociateRegistration( | 54 void OnAssociateRegistration( |
| 54 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, | 55 std::unique_ptr<ServiceWorkerRegistrationHandleReference> registration, |
| 55 scoped_ptr<ServiceWorkerHandleReference> installing, | 56 std::unique_ptr<ServiceWorkerHandleReference> installing, |
| 56 scoped_ptr<ServiceWorkerHandleReference> waiting, | 57 std::unique_ptr<ServiceWorkerHandleReference> waiting, |
| 57 scoped_ptr<ServiceWorkerHandleReference> active); | 58 std::unique_ptr<ServiceWorkerHandleReference> active); |
| 58 void OnDisassociateRegistration(); | 59 void OnDisassociateRegistration(); |
| 59 void OnSetControllerServiceWorker( | 60 void OnSetControllerServiceWorker( |
| 60 scoped_ptr<ServiceWorkerHandleReference> controller); | 61 std::unique_ptr<ServiceWorkerHandleReference> controller); |
| 61 | 62 |
| 62 // Called on the worker thread. Used for initializing | 63 // Called on the worker thread. Used for initializing |
| 63 // ServiceWorkerGlobalScope. | 64 // ServiceWorkerGlobalScope. |
| 64 void GetAssociatedRegistration(ServiceWorkerRegistrationObjectInfo* info, | 65 void GetAssociatedRegistration(ServiceWorkerRegistrationObjectInfo* info, |
| 65 ServiceWorkerVersionAttributes* attrs); | 66 ServiceWorkerVersionAttributes* attrs); |
| 66 | 67 |
| 67 int provider_id() const { return provider_id_; } | 68 int provider_id() const { return provider_id_; } |
| 68 | 69 |
| 69 ServiceWorkerHandleReference* controller(); | 70 ServiceWorkerHandleReference* controller(); |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 friend class base::DeleteHelper<ServiceWorkerProviderContext>; | 73 friend class base::DeleteHelper<ServiceWorkerProviderContext>; |
| 73 friend class base::RefCountedThreadSafe<ServiceWorkerProviderContext, | 74 friend class base::RefCountedThreadSafe<ServiceWorkerProviderContext, |
| 74 ServiceWorkerProviderContextDeleter>; | 75 ServiceWorkerProviderContextDeleter>; |
| 75 friend struct ServiceWorkerProviderContextDeleter; | 76 friend struct ServiceWorkerProviderContextDeleter; |
| 76 | 77 |
| 77 class Delegate; | 78 class Delegate; |
| 78 class ControlleeDelegate; | 79 class ControlleeDelegate; |
| 79 class ControllerDelegate; | 80 class ControllerDelegate; |
| 80 | 81 |
| 81 ~ServiceWorkerProviderContext(); | 82 ~ServiceWorkerProviderContext(); |
| 82 void DestructOnMainThread() const; | 83 void DestructOnMainThread() const; |
| 83 | 84 |
| 84 const int provider_id_; | 85 const int provider_id_; |
| 85 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 86 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 86 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 87 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 87 | 88 |
| 88 scoped_ptr<Delegate> delegate_; | 89 std::unique_ptr<Delegate> delegate_; |
| 89 | 90 |
| 90 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext); | 91 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext); |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 struct ServiceWorkerProviderContextDeleter { | 94 struct ServiceWorkerProviderContextDeleter { |
| 94 static void Destruct(const ServiceWorkerProviderContext* context) { | 95 static void Destruct(const ServiceWorkerProviderContext* context) { |
| 95 context->DestructOnMainThread(); | 96 context->DestructOnMainThread(); |
| 96 } | 97 } |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 } // namespace content | 100 } // namespace content |
| 100 | 101 |
| 101 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ | 102 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ |
| OLD | NEW |