| 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 <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/sequenced_task_runner_helpers.h" | 12 #include "base/sequenced_task_runner_helpers.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "content/common/service_worker/service_worker_types.h" | 14 #include "content/common/service_worker/service_worker_types.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class MessageLoopProxy; | 17 class MessageLoopProxy; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace IPC { | 20 namespace IPC { |
| 21 class Message; | 21 class Message; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 class ServiceWorkerHandleReference; | 26 class ServiceWorkerHandleReference; |
| 27 class ServiceWorkerMessageSender; | |
| 28 class ServiceWorkerRegistrationHandleReference; | 27 class ServiceWorkerRegistrationHandleReference; |
| 29 struct ServiceWorkerProviderContextDeleter; | 28 struct ServiceWorkerProviderContextDeleter; |
| 29 class ThreadSafeSender; |
| 30 | 30 |
| 31 // An instance of this class holds information related to Document/Worker. | 31 // An instance of this class holds information related to Document/Worker. |
| 32 // Created and destructed on the main thread. Some functions can be called | 32 // Created and destructed on the main thread. Some functions can be called |
| 33 // on the worker thread (eg. GetVersionAttributes). | 33 // on the worker thread (eg. GetVersionAttributes). |
| 34 class ServiceWorkerProviderContext | 34 class ServiceWorkerProviderContext |
| 35 : public base::RefCountedThreadSafe<ServiceWorkerProviderContext, | 35 : public base::RefCountedThreadSafe<ServiceWorkerProviderContext, |
| 36 ServiceWorkerProviderContextDeleter> { | 36 ServiceWorkerProviderContextDeleter> { |
| 37 public: | 37 public: |
| 38 explicit ServiceWorkerProviderContext(int provider_id); | 38 explicit ServiceWorkerProviderContext(int provider_id); |
| 39 | 39 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 friend class base::DeleteHelper<ServiceWorkerProviderContext>; | 84 friend class base::DeleteHelper<ServiceWorkerProviderContext>; |
| 85 friend class base::RefCountedThreadSafe<ServiceWorkerProviderContext, | 85 friend class base::RefCountedThreadSafe<ServiceWorkerProviderContext, |
| 86 ServiceWorkerProviderContextDeleter>; | 86 ServiceWorkerProviderContextDeleter>; |
| 87 friend struct ServiceWorkerProviderContextDeleter; | 87 friend struct ServiceWorkerProviderContextDeleter; |
| 88 | 88 |
| 89 ~ServiceWorkerProviderContext(); | 89 ~ServiceWorkerProviderContext(); |
| 90 void DestructOnMainThread() const; | 90 void DestructOnMainThread() const; |
| 91 | 91 |
| 92 const int provider_id_; | 92 const int provider_id_; |
| 93 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_; | 93 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_; |
| 94 scoped_refptr<ServiceWorkerMessageSender> sender_; | 94 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 95 | 95 |
| 96 // Protects (installing, waiting, active) worker and registration references. | 96 // Protects (installing, waiting, active) worker and registration references. |
| 97 base::Lock lock_; | 97 base::Lock lock_; |
| 98 | 98 |
| 99 // Used on both the main thread and the worker thread. | 99 // Used on both the main thread and the worker thread. |
| 100 scoped_ptr<ServiceWorkerHandleReference> installing_; | 100 scoped_ptr<ServiceWorkerHandleReference> installing_; |
| 101 scoped_ptr<ServiceWorkerHandleReference> waiting_; | 101 scoped_ptr<ServiceWorkerHandleReference> waiting_; |
| 102 scoped_ptr<ServiceWorkerHandleReference> active_; | 102 scoped_ptr<ServiceWorkerHandleReference> active_; |
| 103 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration_; | 103 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration_; |
| 104 | 104 |
| 105 // Used only on the main thread. | 105 // Used only on the main thread. |
| 106 scoped_ptr<ServiceWorkerHandleReference> controller_; | 106 scoped_ptr<ServiceWorkerHandleReference> controller_; |
| 107 | 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext); | 108 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 struct ServiceWorkerProviderContextDeleter { | 111 struct ServiceWorkerProviderContextDeleter { |
| 112 static void Destruct(const ServiceWorkerProviderContext* context) { | 112 static void Destruct(const ServiceWorkerProviderContext* context) { |
| 113 context->DestructOnMainThread(); | 113 context->DestructOnMainThread(); |
| 114 } | 114 } |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 } // namespace content | 117 } // namespace content |
| 118 | 118 |
| 119 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ | 119 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ |
| OLD | NEW |